fix(nginx): admin 对齐 assets 配置;443 显式 /admin/assets/ 反代
Made-with: Cursor
This commit is contained in:
@@ -1,9 +1,22 @@
|
||||
# 供 compose 中 admin 容器使用:宿主机挂载 admin/dist,SPA 回退
|
||||
# 外层 Nginx 把 /admin/ 转成 / 转发到本容器
|
||||
# 与 deploy/admin/default.conf、admin/nginx.conf 保持一致(勿再使用仅含 location / 的旧版,否则 /assets/*.js 会回退成 index.html → 白屏)
|
||||
# 外层 Nginx 已把 /admin/ 转成 / 转发到本容器
|
||||
server {
|
||||
listen 80;
|
||||
root /usr/share/nginx/html;
|
||||
index index.html;
|
||||
|
||||
location = /index.html {
|
||||
add_header Cache-Control "no-cache, no-store, must-revalidate";
|
||||
expires -1;
|
||||
}
|
||||
|
||||
location ^~ /assets/ {
|
||||
try_files $uri =404;
|
||||
access_log off;
|
||||
expires 7d;
|
||||
add_header Cache-Control "public, immutable";
|
||||
}
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
|
||||
@@ -26,6 +26,18 @@ server {
|
||||
add_header Cache-Control "no-store";
|
||||
}
|
||||
|
||||
# ^~ 优先于 location /:strip /admin 后反代(rewrite+break 与变量 upstream 兼容,避免误走 web)
|
||||
location ^~ /admin/assets/ {
|
||||
rewrite ^/admin/(.*)$ /$1 break;
|
||||
set $upstream_admin admin;
|
||||
proxy_pass http://$upstream_admin:80;
|
||||
proxy_http_version 1.1;
|
||||
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;
|
||||
}
|
||||
|
||||
location / {
|
||||
set $upstream_web web;
|
||||
proxy_pass http://$upstream_web:80;
|
||||
|
||||
Reference in New Issue
Block a user