2026-05-20 16:13:04 +08:00
|
|
|
|
server {
|
|
|
|
|
|
listen 80;
|
|
|
|
|
|
server_name _;
|
|
|
|
|
|
|
|
|
|
|
|
charset utf-8;
|
|
|
|
|
|
client_max_body_size 100m;
|
|
|
|
|
|
|
2026-05-21 11:17:25 +08:00
|
|
|
|
# Docker 内置 DNS resolver + 变量化 proxy_pass:
|
|
|
|
|
|
# nginx 对静态 proxy_pass 在启动时静态解析主机名,容器重建后 IP 变更即失效。
|
|
|
|
|
|
# 改为变量写法后,resolver 每 10s 重新解析,容器重建无需重启/reload nginx。
|
2026-05-21 11:13:10 +08:00
|
|
|
|
resolver 127.0.0.11 valid=10s ipv6=off;
|
|
|
|
|
|
|
2026-05-20 16:13:04 +08:00
|
|
|
|
# 健康检查(宿主机 nginx 探活用)
|
|
|
|
|
|
location /health {
|
|
|
|
|
|
return 200 "ok\n";
|
|
|
|
|
|
add_header Content-Type text/plain;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# 版本管理 — 必须在通用 /api/ 之前
|
|
|
|
|
|
location /api/v1/updates/ {
|
2026-05-21 11:17:25 +08:00
|
|
|
|
set $svc update-service;
|
|
|
|
|
|
proxy_pass http://$svc:8084;
|
2026-05-20 16:13:04 +08:00
|
|
|
|
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_read_timeout 60s;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
location /api/v1/rn/ {
|
2026-05-21 11:17:25 +08:00
|
|
|
|
set $svc update-service;
|
|
|
|
|
|
proxy_pass http://$svc:8084;
|
2026-05-20 16:13:04 +08:00
|
|
|
|
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_read_timeout 120s;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# IM HTTP — 必须在通用 /api/ 之前
|
|
|
|
|
|
location /api/im/ {
|
2026-05-21 11:17:25 +08:00
|
|
|
|
set $svc im-service;
|
|
|
|
|
|
proxy_pass http://$svc:8082;
|
2026-05-20 16:13:04 +08:00
|
|
|
|
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_read_timeout 60s;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# IM WebSocket
|
|
|
|
|
|
location /ws/im {
|
2026-05-21 11:17:25 +08:00
|
|
|
|
set $svc im-service;
|
|
|
|
|
|
proxy_pass http://$svc:8082;
|
2026-05-20 16:13:04 +08:00
|
|
|
|
proxy_http_version 1.1;
|
|
|
|
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
|
|
|
|
proxy_set_header Connection "upgrade";
|
|
|
|
|
|
proxy_set_header Host $host;
|
|
|
|
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
|
|
|
|
proxy_read_timeout 3600s;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# License — 必须在通用 /api/ 之前
|
|
|
|
|
|
location /api/license/ {
|
2026-05-21 11:17:25 +08:00
|
|
|
|
set $svc license-service;
|
|
|
|
|
|
proxy_pass http://$svc:8085;
|
2026-05-20 16:13:04 +08:00
|
|
|
|
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_read_timeout 60s;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-05-21 17:00:08 +08:00
|
|
|
|
# 文件上传下载 — 必须在通用 /api/ 之前
|
|
|
|
|
|
location /api/file/ {
|
2026-05-21 11:17:25 +08:00
|
|
|
|
set $svc file-service;
|
|
|
|
|
|
proxy_pass http://$svc:8086;
|
2026-05-20 16:13:04 +08:00
|
|
|
|
proxy_set_header Host $host;
|
|
|
|
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
|
|
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
|
|
|
|
client_max_body_size 500m;
|
|
|
|
|
|
proxy_read_timeout 300s;
|
|
|
|
|
|
proxy_send_timeout 300s;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-05-22 16:49:42 +08:00
|
|
|
|
# 一键更新/重置:操作耗时较长,需要更长超时(精确匹配,优先于 /api/ 前缀)
|
|
|
|
|
|
location ~ ^/api/system/(update|reset)$ {
|
2026-05-21 17:19:46 +08:00
|
|
|
|
set $svc tenant-service;
|
|
|
|
|
|
proxy_pass http://$svc:9001;
|
|
|
|
|
|
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_read_timeout 600s;
|
|
|
|
|
|
proxy_send_timeout 600s;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-05-20 16:13:04 +08:00
|
|
|
|
# 核心 API(兜底,在所有具体 /api/xxx/ 之后)
|
|
|
|
|
|
location /api/ {
|
2026-05-21 11:17:25 +08:00
|
|
|
|
set $svc tenant-service;
|
|
|
|
|
|
proxy_pass http://$svc:9001;
|
2026-05-20 16:13:04 +08:00
|
|
|
|
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_read_timeout 60s;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
location /actuator/ {
|
2026-05-21 11:17:25 +08:00
|
|
|
|
set $svc tenant-service;
|
|
|
|
|
|
proxy_pass http://$svc:9001;
|
2026-05-20 16:13:04 +08:00
|
|
|
|
proxy_set_header Host $host;
|
|
|
|
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# 控制台前端(兜底路由,必须最后)
|
2026-05-20 18:25:12 +08:00
|
|
|
|
# sub_filter 替换前端 JS bundle 中硬编码的公有平台地址为私有部署地址
|
2026-05-20 16:13:04 +08:00
|
|
|
|
location / {
|
2026-05-21 11:17:25 +08:00
|
|
|
|
set $svc tenant-web;
|
|
|
|
|
|
proxy_pass http://$svc:80;
|
2026-05-20 18:25:12 +08:00
|
|
|
|
proxy_set_header Host $host;
|
|
|
|
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
|
|
|
|
proxy_set_header Accept-Encoding "";
|
|
|
|
|
|
sub_filter 'wss://im.dev.xuqinmin.com/ws/im' 'wss://$host/ws/im';
|
|
|
|
|
|
sub_filter 'https://im.dev.xuqinmin.com' 'https://$host';
|
|
|
|
|
|
sub_filter 'https://dev.xuqinmin.com' 'https://$host';
|
|
|
|
|
|
sub_filter_once off;
|
|
|
|
|
|
sub_filter_types text/html text/javascript application/javascript;
|
2026-05-20 16:13:04 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|