add ids router

This commit is contained in:
易栋梁 2025-06-29 15:06:38 +08:00
parent b2c24799f2
commit 4b15df695e
1 changed files with 21 additions and 0 deletions

View File

@ -97,6 +97,27 @@ http {
proxy_redirect https://sys-api:19902/ https://$host:$server_port/auth/;
}
location /ids/ {
# 关键 1: 移除路径中的 /auth/ 前缀
proxy_pass https://sys_api/; # 末尾的 / 确保路径替换
proxy_ssl_server_name on;
proxy_ssl_session_reuse off;
proxy_ssl_verify off;
# 关键 2: 覆盖 Host 头,模拟 Vite 的 changeOrigin=true
proxy_set_header Host $proxy_host; # 设置为目标地址的 Host (192.168.1.100:19901)
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Host $host:$server_port;
proxy_set_header Authorization $http_authorization; # 传递 Authorization 头
# 其他标准代理头
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# 关键 4: 重写后端返回的 Location 头(解决重定向端口丢失)
proxy_redirect https://sys-api:19902/ https://$host:$server_port/auth/;
}
location /connect/ {
# 关键 1: 移除路径中的 /auth/ 前缀
proxy_pass https://sys_api/connect/; # 末尾的 / 确保路径替换