80 lines
2.5 KiB
Nginx Configuration File
80 lines
2.5 KiB
Nginx Configuration File
server {
|
|
listen 8901;
|
|
server_name localhost;
|
|
|
|
root /usr/share/nginx/html;
|
|
index index.html;
|
|
|
|
# gzip 压缩
|
|
gzip on;
|
|
gzip_types text/plain text/css application/json application/javascript text/xml application/xml text/javascript image/svg+xml;
|
|
gzip_min_length 256;
|
|
|
|
# 后端 API 反向代理(支持 SSE 长连接)
|
|
location /api/v1/ {
|
|
proxy_pass ${BACKEND_URL}/api/v1/;
|
|
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;
|
|
|
|
# SSE 支持
|
|
proxy_buffering off;
|
|
proxy_cache off;
|
|
proxy_read_timeout 300s;
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Connection "";
|
|
|
|
# 禁止浏览器缓存 API 响应
|
|
add_header Cache-Control "no-cache, no-store, must-revalidate" always;
|
|
add_header Pragma "no-cache" always;
|
|
}
|
|
|
|
# 健康检查
|
|
location /health {
|
|
proxy_pass ${BACKEND_URL}/health;
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
}
|
|
|
|
# Bexell 排程 API 反向代理
|
|
location /bexapi/ {
|
|
proxy_pass http://10.100.154.100:8003/api/;
|
|
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;
|
|
}
|
|
|
|
# 鼎捷云 IAM 登录服务反向代理(与 vite.config.ts 中 /iam-api 代理一致)
|
|
location /iam-api/ {
|
|
proxy_pass https://iam.digiwincloud.com.cn/;
|
|
proxy_set_header Host iam.digiwincloud.com.cn;
|
|
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;
|
|
proxy_ssl_server_name on;
|
|
|
|
# 禁止浏览器缓存 API 响应
|
|
add_header Cache-Control "no-cache, no-store, must-revalidate" always;
|
|
add_header Pragma "no-cache" always;
|
|
}
|
|
|
|
# SPA 路由 fallback:所有非文件请求回退到 index.html
|
|
location / {
|
|
try_files $uri $uri/ /index.html;
|
|
}
|
|
|
|
# 静态资源长缓存(Vite 构建产物带 hash)
|
|
location /assets/ {
|
|
expires 1y;
|
|
add_header Cache-Control "public, immutable";
|
|
}
|
|
|
|
# SVG / 图片缓存
|
|
location ~* \.(svg|png|jpg|jpeg|gif|ico|webp)$ {
|
|
expires 30d;
|
|
add_header Cache-Control "public";
|
|
}
|
|
}
|