fix(nginx): /admin 不再重定向,改用精确反代直接 200
上一版把 /admin 改成相对 301,但 301 会被浏览器**永久缓存**,用户即使 服务端已修好仍被旧的 http://<域名>:8080/admin/ 带走。现在精确匹配 location = /admin 直接反代(无 Location 头),并加 Cache-Control: no-store, 彻底消除这条跳转。其余前缀改 302(不被永久记住),/extension 直接给安装页。
This commit is contained in:
31
nginx.conf
31
nginx.conf
@ -69,16 +69,24 @@ http {
|
||||
|
||||
# Admin WebUI(内部 3005)
|
||||
#
|
||||
# 必须显式处理不带尾斜杠的 /admin:否则它会落到 `location /` 的
|
||||
# try_files $uri/ 分支,nginx 自动补斜杠时按 $host:$server_port 拼出
|
||||
# 绝对地址,于是公网被跳到 http://<域名>:8080/admin/(容器内部端口泄漏)。
|
||||
# 这里返回相对地址,浏览器沿用当前的协议/主机/端口。
|
||||
# 不带尾斜杠的 /admin 必须**直接返回页面**,不能靠重定向:
|
||||
# 1) 它会落到 `location /` 的 try_files $uri/ 分支,nginx 自动补斜杠时按
|
||||
# $host:$server_port 拼绝对地址,把内部端口 8080 泄到公网;
|
||||
# 2) 即便改成相对重定向,301 会被浏览器**永久缓存**,用户改好后仍被旧跳转带走。
|
||||
# 所以这里精确匹配并直接反代(尾斜杠由 proxy_pass 的 / 吸收)。
|
||||
location = /admin {
|
||||
return 301 /admin/;
|
||||
proxy_pass http://127.0.0.1:3005/;
|
||||
# 管理页不缓存:避免旧的跳转/旧页面被浏览器长期记住
|
||||
add_header Cache-Control "no-store" always;
|
||||
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 /admin/ {
|
||||
proxy_pass http://127.0.0.1:3005/;
|
||||
add_header Cache-Control "no-store" always;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
@ -98,8 +106,9 @@ http {
|
||||
}
|
||||
|
||||
# item-icons 从 data volume 提供
|
||||
# 用 302(不是 301):这两个目录不需要浏览器永久记住跳转。
|
||||
location = /item-icons {
|
||||
return 301 /item-icons/;
|
||||
return 302 /item-icons/;
|
||||
}
|
||||
|
||||
location /item-icons/ {
|
||||
@ -108,7 +117,7 @@ http {
|
||||
|
||||
# 自定义壁纸(后台「外观」上传,目录也在 data 卷)
|
||||
location = /wallpapers {
|
||||
return 301 /wallpapers/;
|
||||
return 302 /wallpapers/;
|
||||
}
|
||||
|
||||
location /wallpapers/ {
|
||||
@ -116,9 +125,13 @@ http {
|
||||
add_header Cache-Control "public, max-age=31536000, immutable";
|
||||
}
|
||||
|
||||
# 浏览器扩展安装包目录
|
||||
# 浏览器扩展安装目录:/extension 和 /extension/ 都直接给安装页,不靠重定向
|
||||
location = /extension {
|
||||
return 301 /extension/;
|
||||
rewrite ^ /extension/install.html last;
|
||||
}
|
||||
|
||||
location = /extension/ {
|
||||
rewrite ^ /extension/install.html last;
|
||||
}
|
||||
|
||||
# Dashy SPA 路由兜底
|
||||
|
||||
Reference in New Issue
Block a user