[看板+nginx] v1.9.4 P0-NEW9/10 闭环同步 + f2fd4fa 推送记录 + nginx.conf 回归修复(恢复 /docs/、/api/dev/ 闸门、/h5 v20260811 版本化、/itportal 移除,并补 NEW9/10 404)

This commit is contained in:
Simon
2026-08-11 15:00:51 +08:00
parent ba07c03d11
commit a4a9c3b260
3 changed files with 549 additions and 117 deletions
+389 -22
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,18 +136,51 @@ 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/
# ------------------------------------------------------------------
location /api/ {
# ------------------------------------------------------------------
# P0-NEW11 安全加固:禁止公网访问 API 文档端点(字典级暴露止血)
# 仅对精确路径返回 404;业务 /api/ 其余路径不受影响
# ------------------------------------------------------------------
location = /api/openapi.json { return 404; }
location = /api/docs { return 404; }
location = /api/redoc { return 404; }
location = /api/docs/oauth2-redirect { return 404; }
# ============================================================
# 预生产测试通道 (REQ-通用-006) - nginx 内网闸门
# 仅内网可访问 /api/dev/*,公网 403。部署后须双向 curl 验证
# ============================================================
location /api/dev/ {
allow 10.0.0.0/8;
allow 172.16.0.0/12;
allow 192.168.0.0/16;
deny all;
proxy_pass http://backend_api/;
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;
}
# ------------------------------------------------------------------
# P0-NEW9/10 安全加固:禁止公网访问调试/诊断端点
# 与 P0-NEW11 同源治理:nginx 边缘层兜底
# 仅 test-/debug- 与 metrics/version 返回 404/health、/ready 保留供探针
# ------------------------------------------------------------------
location ~ ^/api/(test-|debug/) { return 404; }
location = /api/metrics { return 404; }
location = /api/version { return 404; }
location /api/ {
proxy_pass http://backend_api/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
@@ -157,13 +193,190 @@ http {
# ------------------------------------------------------------------
# H5 用户端 — /h5/
# 说明:H5 是静态前端应用,必须配置为静态文件服务(alias)!
# ⚠️ 禁止改为 proxy_pass,否则返回 404(后端无 /h5/ 路由)
# 关联 CASECASE-20260714-02 / CASE-20260716-01
# ------------------------------------------------------------------
location /h5/ {
proxy_pass http://backend_api/;
# === 2026-08-06 WAF path-cache bypass: versioned entry ===
# 精确匹配 /h5(无斜杠)→ 302 到 /h5/go,防 404
location = /h5 {
return 302 /h5/go;
}
location = /h5/go {
add_header Cache-Control "no-store" always;
return 302 /h5/v20260811/$is_args$args;
add_header Strict-Transport-Security "max-age=31536000" always;
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-XSS-Protection "1; mode=block" always;
add_header Referrer-Policy "no-referrer-when-downgrade" always;
add_header Permissions-Policy "geolocation=(), microphone=(), camera=()" always;
add_header Cross-Origin-Opener-Policy "same-origin" always;
add_header X-Content-Type-Options "nosniff" always;
}
# === /itservice/ 前缀(替换 /h5/,绕开 WAF 旧缓存) ===
location = /itservice/go {
add_header Cache-Control "no-store" always;
return 302 /itservice/v20260811/$is_args$args;
add_header Strict-Transport-Security "max-age=31536000" always;
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-XSS-Protection "1; mode=block" always;
add_header Referrer-Policy "no-referrer-when-downgrade" always;
add_header Permissions-Policy "geolocation=(), microphone=(), camera=()" always;
add_header Cross-Origin-Opener-Policy "same-origin" always;
add_header X-Content-Type-Options "nosniff" always;
}
location /itservice/v20260807f/ {
alias /usr/share/nginx/html/h5/;
index index.html;
try_files $uri /itservice/v20260807f/index.html;
add_header Cache-Control "no-store" always;
add_header Strict-Transport-Security "max-age=31536000" always;
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-XSS-Protection "1; mode=block" always;
add_header Referrer-Policy "no-referrer-when-downgrade" always;
add_header Permissions-Policy "geolocation=(), microphone=(), camera=()" always;
add_header Cross-Origin-Opener-Policy "same-origin" always;
add_header X-Content-Type-Options "nosniff" always;
}
location /itservice/v20260808/ {
alias /usr/share/nginx/html/h5/;
index index.html;
try_files $uri /itservice/v20260808/index.html;
add_header Cache-Control "no-store" always;
add_header Strict-Transport-Security "max-age=31536000" always;
add_header X-Frame-Options "SAMEORIGIN" always;
}
location /itservice/v20260811/ {
alias /usr/share/nginx/html/h5/;
index index.html;
try_files $uri /itservice/v20260811/index.html;
add_header Cache-Control "no-store" always;
add_header Strict-Transport-Security "max-age=31536000" always;
add_header X-Frame-Options "SAMEORIGIN" always;
}
location /itservice/ {
alias /usr/share/nginx/html/h5/;
index index.html;
try_files $uri $uri/ /itservice/index.html =404;
add_header Cache-Control "no-store" always;
add_header Strict-Transport-Security "max-age=31536000" always;
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-XSS-Protection "1; mode=block" always;
add_header Referrer-Policy "no-referrer-when-downgrade" always;
add_header Permissions-Policy "geolocation=(), microphone=(), camera=()" always;
add_header Cross-Origin-Opener-Policy "same-origin" always;
add_header X-Content-Type-Options "nosniff" always;
}
location = /itservice {
return 302 /itservice/go;
}
location /h5/v20260807f/ {
alias /usr/share/nginx/html/h5/;
index index.html;
try_files $uri /h5/v20260807f/index.html;
add_header Cache-Control "no-store" always;
add_header Strict-Transport-Security "max-age=31536000" always;
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-XSS-Protection "1; mode=block" always;
add_header Referrer-Policy "no-referrer-when-downgrade" always;
add_header Permissions-Policy "geolocation=(), microphone=(), camera=()" always;
add_header Cross-Origin-Opener-Policy "same-origin" always;
add_header X-Content-Type-Options "nosniff" always;
}
location /h5/v20260808/ {
alias /usr/share/nginx/html/h5/;
index index.html;
try_files $uri /h5/v20260808/index.html;
add_header Cache-Control "no-store" always;
add_header Strict-Transport-Security "max-age=31536000" always;
add_header X-Frame-Options "SAMEORIGIN" always;
}
location /h5/v20260811/ {
alias /usr/share/nginx/html/h5/;
index index.html;
try_files $uri /h5/v20260811/index.html;
add_header Cache-Control "no-store" always;
add_header Strict-Transport-Security "max-age=31536000" always;
add_header X-Frame-Options "SAMEORIGIN" always;
}
location /h5/ {
alias /usr/share/nginx/html/h5/;
index index.html;
try_files $uri $uri/ /h5/index.html =404;
add_header Cache-Control "no-cache, must-revalidate" always;
add_header Strict-Transport-Security "max-age=31536000" always;
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-XSS-Protection "1; mode=block" always;
add_header Referrer-Policy "no-referrer-when-downgrade" always;
add_header Permissions-Policy "geolocation=(), microphone=(), camera=()" always;
add_header Cross-Origin-Opener-Policy "same-origin" always;
add_header X-Content-Type-Options "nosniff" always;
}
# ------------------------------------------------------------------
# 静态媒体文件 — /media/ (企微下载的图片/H5上传的文件)
# 代理到后端 /api/media/ 接口(容器内路径 /app/uploads/
# ------------------------------------------------------------------
location /media/ {
proxy_pass http://backend_api/media/;
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;
expires 30d;
add_header Cache-Control "public, immutable";
add_header Strict-Transport-Security "max-age=31536000" always;
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-XSS-Protection "1; mode=block" always;
add_header Referrer-Policy "no-referrer-when-downgrade" always;
add_header Permissions-Policy "geolocation=(), microphone=(), camera=()" always;
add_header Cross-Origin-Opener-Policy "same-origin" always;
add_header X-Content-Type-Options "nosniff" always;
}
# ------------------------------------------------------------------
@@ -193,6 +406,38 @@ http {
proxy_send_timeout 60s;
proxy_read_timeout 60s;
}
# ------------------------------------------------------------------
# 看板 / 巡检 HTML 静态目录 — /docs/
# 2026-08-06 P0-NEW7 修复(看板-部署脱节):
# - 来源:宿主 /opt/wecom-it-desk/docs-public/(由 docker-compose.yml 挂载)
# - 子目录:kanban/ 项目状态看板;inspection/YYYY-MM/ 巡检报告
# - charset utf-8 解决中文文件名编码
# - 不缓存 HTML,确保看板/报告更新后用户立即看到
# 关联:看板 v1.9.0-FROZEN 顶部服务发布策略 + scripts/deploy_kanban_to_jumpserver.sh
# ------------------------------------------------------------------
location /docs/ {
alias /opt/wecom-it-desk/docs-public/;
charset utf-8;
add_header Cache-Control "no-cache, must-revalidate" always;
add_header Content-Type "text/html; charset=utf-8" always;
try_files $uri $uri/ $uri.html =404;
autoindex off;
add_header Strict-Transport-Security "max-age=31536000" always;
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-XSS-Protection "1; mode=block" always;
add_header Referrer-Policy "no-referrer-when-downgrade" always;
add_header Permissions-Policy "geolocation=(), microphone=(), camera=()" always;
add_header Cross-Origin-Opener-Policy "same-origin" always;
add_header X-Content-Type-Options "nosniff" always;
}
add_header Strict-Transport-Security "max-age=31536000" always;
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-XSS-Protection "1; mode=block" always;
add_header Referrer-Policy "no-referrer-when-downgrade" always;
add_header Permissions-Policy "geolocation=(), microphone=(), camera=()" always;
add_header Cross-Origin-Opener-Policy "same-origin" always;
add_header X-Content-Type-Options "nosniff" always;
}
# =================================================================
@@ -209,6 +454,13 @@ http {
access_log off;
return 200 "healthy\n";
add_header Content-Type text/plain;
add_header Strict-Transport-Security "max-age=31536000" always;
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-XSS-Protection "1; mode=block" always;
add_header Referrer-Policy "no-referrer-when-downgrade" always;
add_header Permissions-Policy "geolocation=(), microphone=(), camera=()" always;
add_header Cross-Origin-Opener-Policy "same-origin" always;
add_header X-Content-Type-Options "nosniff" always;
}
# ------------------------------------------------------------------
@@ -266,17 +518,25 @@ 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/
# ------------------------------------------------------------------
# ------------------------------------------------------------------
# P0-NEW9/10 安全加固:禁止公网访问调试/诊断端点
# 与 P0-NEW11 同源治理:nginx 边缘层兜底
# 仅 test-/debug- 与 metrics/version 返回 404/health、/ready 保留供探针
# ------------------------------------------------------------------
location ~ ^/api/(test-|debug/) { return 404; }
location = /api/metrics { return 404; }
location = /api/version { return 404; }
location /api/ {
proxy_pass http://backend_api/;
proxy_set_header Host $host;
@@ -292,13 +552,93 @@ http {
# ------------------------------------------------------------------
# H5 用户端 — /h5/
# 说明:H5 是静态前端应用,必须配置为静态文件服务(alias)!
# ⚠️ 禁止改为 proxy_pass,否则返回 404(后端无 /h5/ 路由)
# 关联 CASECASE-20260714-02 / CASE-20260716-01
# ------------------------------------------------------------------
location /h5/ {
proxy_pass http://backend_api/;
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;
# === 2026-08-06 WAF path-cache bypass: versioned entry ===
# 精确匹配 /h5(无斜杠)→ 302 到 /h5/go,防 404
location = /h5 {
return 302 /h5/go;
}
location = /h5/go {
add_header Cache-Control "no-store" always;
return 302 /h5/v20260808/$is_args$args;
add_header Strict-Transport-Security "max-age=31536000" always;
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-XSS-Protection "1; mode=block" always;
add_header Referrer-Policy "no-referrer-when-downgrade" always;
add_header Permissions-Policy "geolocation=(), microphone=(), camera=()" always;
add_header Cross-Origin-Opener-Policy "same-origin" always;
add_header X-Content-Type-Options "nosniff" always;
}
location /itservice/v20260808/ {
alias /usr/share/nginx/html/h5/;
index index.html;
try_files $uri /itservice/v20260808/index.html;
add_header Cache-Control "no-store" always;
add_header Strict-Transport-Security "max-age=31536000" always;
add_header X-Frame-Options "SAMEORIGIN" always;
}
location /itservice/ {
alias /usr/share/nginx/html/h5/;
index index.html;
try_files $uri $uri/ /itservice/index.html =404;
add_header Cache-Control "no-store" always;
add_header Strict-Transport-Security "max-age=31536000" always;
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-XSS-Protection "1; mode=block" always;
add_header Referrer-Policy "no-referrer-when-downgrade" always;
add_header Permissions-Policy "geolocation=(), microphone=(), camera=()" always;
add_header Cross-Origin-Opener-Policy "same-origin" always;
add_header X-Content-Type-Options "nosniff" always;
}
location = /itservice {
return 302 /itservice/go;
}
location /h5/v20260808/ {
alias /usr/share/nginx/html/h5/;
index index.html;
try_files $uri /h5/v20260808/index.html;
add_header Cache-Control "no-store" always;
add_header Strict-Transport-Security "max-age=31536000" always;
add_header X-Frame-Options "SAMEORIGIN" always;
}
location /h5/ {
alias /usr/share/nginx/html/h5/;
index index.html;
try_files $uri $uri/ /h5/index.html =404;
add_header Cache-Control "no-cache, must-revalidate" always;
add_header Strict-Transport-Security "max-age=31536000" always;
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-XSS-Protection "1; mode=block" always;
add_header Referrer-Policy "no-referrer-when-downgrade" always;
add_header Permissions-Policy "geolocation=(), microphone=(), camera=()" always;
add_header Cross-Origin-Opener-Policy "same-origin" always;
add_header X-Content-Type-Options "nosniff" always;
}
# ------------------------------------------------------------------
@@ -337,5 +677,32 @@ http {
proxy_send_timeout 60s;
proxy_read_timeout 60s;
}
# ------------------------------------------------------------------
# 看板 / 巡检 HTML 静态目录 — /docs/(备用 server 也支持)
# 2026-08-06 P0-NEW7 修复:与主 server 一致
# ------------------------------------------------------------------
location /docs/ {
alias /opt/wecom-it-desk/docs-public/;
charset utf-8;
add_header Cache-Control "no-cache, must-revalidate" always;
add_header Content-Type "text/html; charset=utf-8" always;
try_files $uri $uri/ $uri.html =404;
autoindex off;
add_header Strict-Transport-Security "max-age=31536000" always;
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-XSS-Protection "1; mode=block" always;
add_header Referrer-Policy "no-referrer-when-downgrade" always;
add_header Permissions-Policy "geolocation=(), microphone=(), camera=()" always;
add_header Cross-Origin-Opener-Policy "same-origin" always;
add_header X-Content-Type-Options "nosniff" always;
}
add_header Strict-Transport-Security "max-age=31536000" always;
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-XSS-Protection "1; mode=block" always;
add_header Referrer-Policy "no-referrer-when-downgrade" always;
add_header Permissions-Policy "geolocation=(), microphone=(), camera=()" always;
add_header Cross-Origin-Opener-Policy "same-origin" always;
add_header X-Content-Type-Options "nosniff" always;
}
}