mirror of https://gitee.com/xiaonuobase/snowy
添加Dockerfile 与nginx反向代理文件
parent
60addecd54
commit
0dddcc8b37
|
@ -0,0 +1,11 @@
|
||||||
|
FROM registry.cn-beijing.aliyuncs.com/mojiong/openjdk:17
|
||||||
|
|
||||||
|
# 将本地的 jar 文件添加到容器中并重命名为 app.jar
|
||||||
|
ADD snowy-web-app/target/snowy-web-app-3.0.0.jar app.jar
|
||||||
|
|
||||||
|
# 暴露容器的端口,Spring Boot 默认端口为 8080
|
||||||
|
EXPOSE 82
|
||||||
|
|
||||||
|
# 设置容器启动时运行的命令
|
||||||
|
ENTRYPOINT ["java","-jar","/app.jar"]
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
FROM registry.cn-beijing.aliyuncs.com/mojiong/nginx:latest
|
||||||
|
ENV VAR_HOST Snowy-API
|
||||||
|
#RUN apt-get update && apt-get install -y vim
|
||||||
|
# 将本地的 html 文件添加到容器中并
|
||||||
|
COPY snowy-admin-web/dist/ /usr/share/nginx/html
|
||||||
|
# 复制反向代理文件
|
||||||
|
COPY snowy-admin-web/nginx.conf /etc/nginx/conf.d/default.conf
|
||||||
|
# 反向代理的域名替换
|
||||||
|
RUN sed -i "s/\CONTAINER-HOST/${VAR_HOST}/g" /etc/nginx/conf.d/default.conf
|
||||||
|
# 暴露容器的端口,nginx默认端口为 80
|
||||||
|
EXPOSE 80
|
||||||
|
|
||||||
|
# 设置容器启动时运行的命令
|
||||||
|
CMD ["nginx", "-g", "daemon off;"]
|
|
@ -0,0 +1,41 @@
|
||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
server_name localhost;
|
||||||
|
gzip on;
|
||||||
|
gzip_min_length 1k;
|
||||||
|
gzip_comp_level 9;
|
||||||
|
gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;
|
||||||
|
gzip_vary on;
|
||||||
|
gzip_disable "MSIE [1-6]\.";
|
||||||
|
|
||||||
|
location / {
|
||||||
|
root /usr/share/nginx/html;
|
||||||
|
index index.html index.htm;
|
||||||
|
try_files $uri $uri/ @router;
|
||||||
|
error_page 405 =200 http://$host$request_uri;
|
||||||
|
}
|
||||||
|
|
||||||
|
location @router {
|
||||||
|
rewrite ^.*$ /index.html last;
|
||||||
|
}
|
||||||
|
|
||||||
|
location /api {
|
||||||
|
proxy_pass http://CONTAINER-HOST:82;
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_set_header REMOTE-HOST $remote_addr;
|
||||||
|
|
||||||
|
add_header X-Cache $upstream_cache_status;
|
||||||
|
|
||||||
|
#Set Nginx Cache
|
||||||
|
rewrite ^/api/(.*)$ /$1 break;
|
||||||
|
add_header Cache-Control no-cache;
|
||||||
|
expires 12h;
|
||||||
|
}
|
||||||
|
|
||||||
|
error_page 500 502 503 504 /50x.html;
|
||||||
|
location = /50x.html {
|
||||||
|
root html;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue