feat: admin前端改用nginx反向代理,API地址部署时可配置
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
10d89a85c8
commit
8f0056c9b2
|
|
@ -1,12 +1,10 @@
|
||||||
# 生产环境配置
|
# 生产环境配置
|
||||||
ENV = 'production'
|
ENV = 'production'
|
||||||
|
|
||||||
|
# 生产环境 — 使用 /api 前缀,由 nginx 反向代理转发到后端
|
||||||
|
VITE_APP_API_HOST = '/api'
|
||||||
|
|
||||||
# 生产环境
|
VITE_APP_BASE_API = '/api'
|
||||||
VITE_APP_API_HOST = 'https://admin.api.skzhijia.com'
|
|
||||||
|
|
||||||
VITE_APP_BASE_API = 'https://admin.api.skzhijia.com'
|
|
||||||
|
|
||||||
|
|
||||||
# 路由前缀
|
# 路由前缀
|
||||||
VITE_APP_ROUTER_PREFIX = '/'
|
VITE_APP_ROUTER_PREFIX = '/'
|
||||||
|
|
@ -14,8 +12,8 @@ VITE_APP_ROUTER_PREFIX = '/'
|
||||||
# 默认上传地址
|
# 默认上传地址
|
||||||
VITE_APP_UPLOAD_URL = '/Common/UploadFile'
|
VITE_APP_UPLOAD_URL = '/Common/UploadFile'
|
||||||
|
|
||||||
#socket API
|
#socket API — nginx 代理 WebSocket
|
||||||
VITE_APP_SOCKET_API = 'https://admin.api.skzhijia.com/msghub'
|
VITE_APP_SOCKET_API = '/api/msghub'
|
||||||
|
|
||||||
# 是否在打包时开启压缩,支持 gzip 和 brotli
|
# 是否在打包时开启压缩,支持 gzip 和 brotli
|
||||||
VITE_BUILD_COMPRESS = gzip
|
VITE_BUILD_COMPRESS = gzip
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ FROM 192.168.195.25:19900/library/nginx:alpine
|
||||||
# 复制构建产物到nginx目录
|
# 复制构建产物到nginx目录
|
||||||
COPY --from=builder /app/dist /usr/share/nginx/html
|
COPY --from=builder /app/dist /usr/share/nginx/html
|
||||||
|
|
||||||
# 复制nginx配置文件
|
# 复制nginx配置文件(部署时可替换)
|
||||||
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
||||||
|
|
||||||
# 暴露端口
|
# 暴露端口
|
||||||
|
|
@ -31,4 +31,3 @@ EXPOSE 80
|
||||||
|
|
||||||
# 启动nginx
|
# 启动nginx
|
||||||
CMD ["nginx", "-g", "daemon off;"]
|
CMD ["nginx", "-g", "daemon off;"]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,34 @@ server {
|
||||||
gzip_min_length 1024;
|
gzip_min_length 1024;
|
||||||
gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml+rss application/javascript application/json;
|
gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml+rss application/javascript application/json;
|
||||||
|
|
||||||
|
# ========== 反向代理到后端 API ==========
|
||||||
|
# 部署时替换此文件,修改 proxy_pass 指向实际后端地址即可
|
||||||
|
|
||||||
|
# SignalR WebSocket(/api/msghub -> /msghub)
|
||||||
|
location /api/msghub {
|
||||||
|
rewrite ^/api/(.*) /$1 break;
|
||||||
|
proxy_pass http://admin-api:8080;
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
|
proxy_set_header Connection "upgrade";
|
||||||
|
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 X-Forwarded-Proto $scheme;
|
||||||
|
}
|
||||||
|
|
||||||
|
# 通用 API 代理(/api/xxx -> /xxx)
|
||||||
|
location /api/ {
|
||||||
|
rewrite ^/api/(.*) /$1 break;
|
||||||
|
proxy_pass http://admin-api:8080;
|
||||||
|
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 X-Forwarded-Proto $scheme;
|
||||||
|
client_max_body_size 50m;
|
||||||
|
}
|
||||||
|
|
||||||
|
# ========== 前端静态资源 ==========
|
||||||
# 处理Vue Router的history模式
|
# 处理Vue Router的history模式
|
||||||
location / {
|
location / {
|
||||||
try_files $uri $uri/ /index.html;
|
try_files $uri $uri/ /index.html;
|
||||||
|
|
@ -29,4 +57,3 @@ server {
|
||||||
# 错误页面
|
# 错误页面
|
||||||
error_page 404 /index.html;
|
error_page 404 /index.html;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user