ae22db4b3e
nginx_https.conf 新增注释化重定向规则,将裸页面路径 301 到 /app/ 前缀; main.py 添加 StarletteHTTPExceptionHandler,404 返回空白 HTML 而非 JSON, 避免泄露后端框架标识。 Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
1014 B
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 错误