From 0d00202a80e168cc3ea1c0c8b467f7eeacfbf2a5 Mon Sep 17 00:00:00 2001 From: yidl Date: Tue, 1 Jul 2025 01:39:35 +0800 Subject: [PATCH] connect --- nginx.conf.gateway | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/nginx.conf.gateway b/nginx.conf.gateway index aa51156..8920835 100644 --- a/nginx.conf.gateway +++ b/nginx.conf.gateway @@ -132,6 +132,27 @@ http { proxy_redirect https://sys_api:19902/ http://$host:$server_port/auth/; proxy_redirect https://sys_api/ http://$host:$server_port/auth/; } + location /connect/ { + # 关键 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 + + 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/ http://$host:$server_port/auth/; + proxy_redirect https://sys_api/ http://$host:$server_port/auth/; + } location = /auth/.well-known/openid-configuration { proxy_pass https://sys_api/.well-known/openid-configuration;