2026-07-30 21:52:18 +08:00
|
|
|
server {
|
|
|
|
|
listen 80;
|
|
|
|
|
listen [::]:80;
|
|
|
|
|
server_name _;
|
|
|
|
|
|
|
|
|
|
root /usr/share/nginx/html;
|
|
|
|
|
index index.html;
|
|
|
|
|
|
|
|
|
|
location = /healthz {
|
|
|
|
|
default_type text/plain;
|
|
|
|
|
return 200 "ok\n";
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-02 20:41:51 +08:00
|
|
|
# SPA 入口每次重新校验,避免发布后浏览器继续运行旧资源清单。
|
|
|
|
|
location = /index.html {
|
|
|
|
|
add_header Cache-Control "no-store, no-cache, must-revalidate" always;
|
|
|
|
|
add_header Pragma "no-cache" always;
|
|
|
|
|
add_header Expires "0" always;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Vite 产物文件名带内容哈希,可安全长期缓存。
|
|
|
|
|
location /assets/ {
|
|
|
|
|
try_files $uri =404;
|
|
|
|
|
add_header Cache-Control "public, max-age=31536000, immutable" always;
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-30 21:52:18 +08:00
|
|
|
# 前端统一请求 /api,保持原始路径转发给 Gateway。
|
|
|
|
|
location /api/ {
|
2026-08-28 22:12:09 +08:00
|
|
|
client_max_body_size 55m;
|
2026-07-30 21:52:18 +08:00
|
|
|
proxy_pass ${API_UPSTREAM};
|
|
|
|
|
proxy_http_version 1.1;
|
2026-08-27 10:44:14 +08:00
|
|
|
proxy_set_header Host $proxy_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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# 海外业务使用独立 Gateway;浏览器前缀只在此处改写一次为 /api。
|
|
|
|
|
location /overseas-api/ {
|
2026-08-28 22:12:09 +08:00
|
|
|
client_max_body_size 55m;
|
2026-08-27 10:44:14 +08:00
|
|
|
rewrite ^/overseas-api/(.*)$ /api/$1 break;
|
|
|
|
|
proxy_pass ${OVERSEAS_API_UPSTREAM};
|
|
|
|
|
proxy_http_version 1.1;
|
|
|
|
|
proxy_set_header Host $proxy_host;
|
2026-07-30 21:52:18 +08:00
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# 支持 Vue Router history 路由直接刷新。
|
|
|
|
|
location / {
|
2026-09-02 20:41:51 +08:00
|
|
|
add_header Cache-Control "no-store, no-cache, must-revalidate" always;
|
2026-07-30 21:52:18 +08:00
|
|
|
try_files $uri $uri/ /index.html;
|
|
|
|
|
}
|
|
|
|
|
}
|