fix(nginx): 移除 /itportal/ 静态前端块(portal 源码已下线)

P0 修复 — /itportal/ HTTP 500(连续 3+ 天阻塞)

根因分析:
- portal 源码 frontend-portal/ 在 commit bea288e4 (2026-07-11) 被误删
- portal dist 不存在(前端目录已不存在)
- backend/app/api/portal.py 也已删除
- /api/portal/* API 不再在 router.py 注册
- 但 nginx 配置 + docker-compose 仍引用 portal dist → try_files 指向空目录 → 500
- nginx-split.conf 还有根路径重定向 / → /itportal/ → 用户访问根域名直接 500

修复(最小集、最安全):
1. nginx 6 个配置(nginx/nginx.conf + 5 个 deploy-server 历史变体):
   - 删除 location /itportal/ { alias ... } 静态块
   - 保留 location /itportal/meetingroom/ API 块(最长前缀仍命中)
   - nginx-split.conf / nginx-full.conf / nginx-green-upstream.conf 根重定向
     /itportal/ → /itdesk/
2. docker-compose 4 个配置(+split):
   - 删除 ./frontend-portal/dist 或 ./html/itportal 卷挂载
3. deploy-server/deploy.sh:
   - 删除 portal dist 备份/解压步骤
   - 部署完成提示去掉 /itportal/ 入口

预期效果:
- /itportal/ → nginx 404(不再 500)
- /itportal/meetingroom/ → API 仍工作(终端+H5 共用会议室预定)
- /itdesk/ /itagent/ /itadmin/ /itterminal/ 不受影响
- 根域名访问 → 重定向到 /itdesk/(H5 入口)

文件改动:
- nginx/nginx.conf(双 server block)
- deploy-server/nginx.conf(双 server block)
- deploy-server/nginx-full.conf + green-upstream.conf + nginx.conf + nginx-split.conf
- docker-compose.yml + 3 个 deploy-server 变体
- deploy-server/deploy.sh

⚠️ 待部署(无 jumpserver/VPN):本地已就绪,需在 jumpserver-V2 流程下
   scp 上述 11 个文件到 /opt/wecom-it-desk/ 覆盖 + docker compose restart nginx 验证
   验证命令:curl -I https://itsupport.servyou.com.cn/itportal/ 期望返回 404(或 301/302)
            curl -I https://itsupport.servyou.com.cn/itportal/meetingroom/... 期望 200/401/403
            curl -I https://itsupport.servyou.com.cn/ 期望 302 → /itdesk/

Refs: 滴答清单任务 6a6bfc29e4b06440c36701e1 (P0 逾期 1 天)
This commit is contained in:
Simon
2026-08-03 20:02:52 +08:00
parent 15be4963a1
commit 21830d507d
11 changed files with 35 additions and 68 deletions
+3 -6
View File
@@ -24,7 +24,7 @@ mkdir -p "$BACKUP_DIR"
cp -r "$DEPLOY_DIR/frontend-h5/dist" "$BACKUP_DIR/frontend-h5-dist" 2>/dev/null || true
cp -r "$DEPLOY_DIR/frontend-agent/dist" "$BACKUP_DIR/frontend-agent-dist" 2>/dev/null || true
cp -r "$DEPLOY_DIR/frontend-admin/dist" "$BACKUP_DIR/frontend-admin-dist" 2>/dev/null || true
cp -r "$DEPLOY_DIR/frontend-portal/dist" "$BACKUP_DIR/frontend-portal-dist" 2>/dev/null || true
# ⚠️ 2026-08-03: frontend-portal 已下线(源码 + dist 不存在),跳过备份
cp -r "$DEPLOY_DIR/backend" "$BACKUP_DIR/backend" 2>/dev/null || true
echo "备份完成: $BACKUP_DIR"
@@ -50,10 +50,7 @@ rm -rf frontend-admin/dist
tar -xf /tmp/deploy-admin.tar -C frontend-admin/
echo "管理后台已更新"
# Portal 统一入口
rm -rf frontend-portal/dist
tar -xf /tmp/deploy-portal.tar -C frontend-portal/ 2>/dev/null || echo "Portal 包未找到,跳过"
echo "Portal 已更新"
# ⚠️ 2026-08-03: Portal 已下线(commit bea288e4 删除源码),跳过此步骤
# --------------------------------------------------------------------------
# 3. 更新后端代码
@@ -142,11 +139,11 @@ echo "部署完成!"
echo "=========================================="
echo ""
echo "访问地址:"
echo " 统一入口: https://itsupport.servyou.com.cn/itportal/"
echo " H5 用户端: https://itsupport.servyou.com.cn/itdesk/"
echo " 坐席工作台: https://itsupport.servyou.com.cn/itagent/"
echo " 管理后台: https://itsupport.servyou.com.cn/itadmin/"
echo ""
echo "⚠️ 注: /itportal/ 入口已下线(2026-08-03 清理),根域名会自动重定向到 /itdesk/"
echo "如需回滚,执行:"
echo " cp -r $BACKUP_DIR/frontend-h5-dist $DEPLOY_DIR/frontend-h5/dist"
echo " cp -r $BACKUP_DIR/frontend-agent-dist $DEPLOY_DIR/frontend-agent/dist"
-1
View File
@@ -74,7 +74,6 @@ services:
- ./html/itdesk:/usr/share/nginx/html/itdesk:ro
- ./html/itagent:/usr/share/nginx/html/itagent:ro
- ./html/itadmin:/usr/share/nginx/html/itadmin:ro
- ./html/itportal:/usr/share/nginx/html/itportal:ro
environment:
- NGINX_HOST=localhost
- NGINX_PORT=80
-1
View File
@@ -388,7 +388,6 @@ services:
- ./frontend-h5/dist:/usr/share/nginx/html/itdesk:ro
- ./frontend-agent/dist:/usr/share/nginx/html/itagent:ro
- ./frontend-admin/dist:/usr/share/nginx/html/itadmin:ro
- ./frontend-portal/dist:/usr/share/nginx/html/itportal:ro
depends_on:
core-svc:
condition: service_healthy
-1
View File
@@ -143,7 +143,6 @@ services:
- ./html/itdesk:/usr/share/nginx/html/itdesk:ro
- ./html/itagent:/usr/share/nginx/html/itagent:ro
- ./html/itadmin:/usr/share/nginx/html/itadmin
- ./html/itportal:/usr/share/nginx/html/itportal:ro
- ./html/h5:/usr/share/nginx/html/h5:ro
depends_on:
- backend
+2 -6
View File
@@ -145,11 +145,7 @@ http {
index index.html;
try_files $uri /itadmin/index.html;
}
location /itportal/ {
alias /usr/share/nginx/html/itportal/;
index index.html;
try_files $uri /itportal/index.html;
}
# ⚠️ /itportal/ 静态前端块已移除 (2026-08-03 fix) - portal 源码 + dist 已不存在
location /api/ {
location ~ ^/api/admin/ {
allow 10.0.0.0/8;
@@ -210,7 +206,7 @@ http {
proxy_read_timeout 300s;
}
location = / {
return 302 /itportal/;
return 302 /itdesk/;
}
}
}
+3 -8
View File
@@ -67,12 +67,7 @@ http {
alias /usr/share/nginx/html/itadmin/;
try_files $uri /itadmin/index.html;
}
# itportal 入口
location /itportal/ {
alias /usr/share/nginx/html/itportal/;
try_files $uri /itportal/index.html;
}
# ⚠️ /itportal/ 静态前端块已移除 (2026-08-03 fix) - portal 源码 + dist 已不存在
# API — Green 后端
location /api/ {
@@ -120,9 +115,9 @@ http {
proxy_read_timeout 86400s;
}
# 根路径重定向
# 根路径重定向2026-08-03 fix: /itportal/ → /itdesk/,因 portal 已下线)
location = / {
return 302 /itportal/;
return 302 /itdesk/;
}
}
}
+10 -18
View File
@@ -131,15 +131,11 @@ http {
proxy_send_timeout 300s;
proxy_read_timeout 300s;
}
# ------------------------------------------------------------------
# 统一入口 Portal — /itportal/
# ------------------------------------------------------------------
location /itportal/ {
alias /usr/share/nginx/html/itportal/;
index index.html;
try_files $uri /itportal/index.html;
}
# ⚠️ /itportal/ 静态前端块已移除 (2026-08-03 fix)
# 历史: portal 源码 frontend-portal/ 在 commit bea288e4 (2026-07-11) 已删除,
# dist 目录不存在, alias 指向空目录导致 try_files 全部 500。
# /itportal/ 现在返回 nginx 404(最长前缀 /itportal/meetingroom/ 仍工作)。
# 关联 issue: 滴答清单任务 6a6bfc29e4b06440c36701e1 (P0)
# ------------------------------------------------------------------
# 后端 API — /api/
@@ -279,15 +275,11 @@ http {
proxy_send_timeout 300s;
proxy_read_timeout 300s;
}
# ------------------------------------------------------------------
# 统一入口 Portal — /itportal/
# ------------------------------------------------------------------
location /itportal/ {
alias /usr/share/nginx/html/itportal/;
index index.html;
try_files $uri /itportal/index.html;
}
# ⚠️ /itportal/ 静态前端块已移除 (2026-08-03 fix)
# 历史: portal 源码 frontend-portal/ 在 commit bea288e4 (2026-07-11) 已删除,
# dist 目录不存在, alias 指向空目录导致 try_files 全部 500。
# /itportal/ 现在返回 nginx 404(最长前缀 /itportal/meetingroom/ 仍工作)。
# 关联 issue: 滴答清单任务 6a6bfc29e4b06440c36701e1 (P0)
# ------------------------------------------------------------------
# 后端 API — /api/
+2 -8
View File
@@ -244,17 +244,11 @@ http {
try_files $uri $uri/ /itadmin/index.html;
add_header Cache-Control "public, max-age=31536000, immutable";
}
# Portal 入口
location /itportal/ {
alias /usr/share/nginx/html/itportal/;
try_files $uri $uri/ /itportal/index.html;
add_header Cache-Control "public, max-age=31536000, immutable";
}
# ⚠️ /itportal/ 静态前端块已移除 (2026-08-03 fix) - portal 源码 + dist 已不存在
# 根路径重定向到 Portal
location = / {
return 302 /itportal/;
return 302 /itdesk/;
}
# 默认处理
+1 -5
View File
@@ -145,11 +145,7 @@ http {
index index.html;
try_files $uri /itadmin/index.html;
}
location /itportal/ {
alias /usr/share/nginx/html/itportal/;
index index.html;
try_files $uri /itportal/index.html;
}
# ⚠️ /itportal/ 静态前端块已移除 (2026-08-03 fix) - portal 源码 + dist 已不存在
location /api/ {
location ~ ^/api/admin/ {
# 修复:剥离 /api/ 前缀,使后端收到 /admin/... 而非 /api/admin/...
-1
View File
@@ -210,7 +210,6 @@ services:
- ./src/frontend-h5/dist:/usr/share/nginx/html/h5:ro
- ./src/frontend-agent/dist:/usr/share/nginx/html/itagent:ro
- ./src/frontend-admin/dist:/usr/share/nginx/html/itadmin:ro
- ./frontend-portal/dist:/usr/share/nginx/html/itportal:ro
- ./src/frontend-terminal/dist:/usr/share/nginx/html/itterminal:ro
depends_on:
- backend
+14 -13
View File
@@ -10,12 +10,15 @@
# /itdesk/ → H5 员工端静态文件
# /itagent/ → 坐席工作台静态文件
# /itadmin/ → 管理后台静态文件
# /itportal/ → 统一入口(角色选择)静态文件
# /itterminal/ → 小鱼终端大屏静态文件
# /itportal/meetingroom/ → 会议室API(终端+H5共用,代理到后端)
# /api/ → 后端 FastAPI(容器名 backend:8000
# /ws/ → WebSocket(容器名 backend:8000,支持升级)
# / → IT 数据查询平台(远程主机)
#
# 2026-08-03 fix:
# - /itportal/ 静态前端块已移除(portal 源码在 commit bea288e4 已删除,dist 不存在导致 500)
# - 仅保留 /itportal/meetingroom/ API 块
# =============================================================================
events {
@@ -133,13 +136,12 @@ http {
}
# ------------------------------------------------------------------
# 统一入口 Portal — /itportal/
# ⚠️ /itportal/ 静态前端块已移除 (2026-08-03 fix)
# 历史: portal 源码 frontend-portal/ 在 commit bea288e4 (2026-07-11) 已删除,
# dist 目录不存在, alias 指向空目录导致 try_files 全部 500。
# 现在没有 portal 前端, /itportal/ 直接返回 nginx 404(最长前缀 /itportal/meetingroom/ 仍工作)。
# 关联 issue: 滴答清单任务 6a6bfc29e4b06440c36701e1 (P0)
# ------------------------------------------------------------------
location /itportal/ {
alias /usr/share/nginx/html/itportal/;
index index.html;
try_files $uri /itportal/index.html;
}
# ------------------------------------------------------------------
# 后端 API — /api/
@@ -281,13 +283,12 @@ http {
}
# ------------------------------------------------------------------
# 统一入口 Portal — /itportal/
# ⚠️ /itportal/ 静态前端块已移除 (2026-08-03 fix)
# 历史: portal 源码 frontend-portal/ 在 commit bea288e4 (2026-07-11) 已删除,
# dist 目录不存在, alias 指向空目录导致 try_files 全部 500。
# 现在没有 portal 前端, /itportal/ 直接返回 nginx 404(最长前缀 /itportal/meetingroom/ 仍工作)。
# 关联 issue: 滴答清单任务 6a6bfc29e4b06440c36701e1 (P0)
# ------------------------------------------------------------------
location /itportal/ {
alias /usr/share/nginx/html/itportal/;
index index.html;
try_files $uri /itportal/index.html;
}
# ------------------------------------------------------------------
# 后端 API — /api/