Files
Nexus/docs/changelog/2026-05-30-nginx-redirect-fix.md
T
2026-07-08 22:31:31 +08:00

1014 B

2026-05-30 Nginx 静态文件路径重定向 + 部署文档更新

背景

FastAPI 静态文件挂在 /app/ 路径下,访问不带 /app/ 前缀的 URL(如 /login.html)时,FastAPI 返回 JSON {"detail":"Not Found"},浏览器直接渲染白屏显示该错误。

变更内容

1. Nginx 配置 (远程)

location / 前插入重定向规则,15 个页面路径自动 301 到 /app/ 下:

location ~ ^/(login|index|servers|files|push|scripts|script-executions|credentials|schedules|retries|commands|alerts|audit|settings|install|terminal|assets)\.html$ {
    return 301 /app/$1.html;
}

2. 部署模板更新

deploy/nginx_https.conf 新增注释块,提示反代部署时取消注释该重定向规则。

涉及文件

  • deploy/nginx_https.conf — 模板注释
  • /www/server/panel/vhost/nginx/api.synaglobal.vip.conf — 实际生效

验证

  • nginx -t 通过
  • 浏览器访问 /login.html → 301 → /app/login.html,不再显示 JSON 错误