diff --git a/nginx.conf.gateway b/nginx.conf.gateway index 824bdc6..69b15f2 100644 --- a/nginx.conf.gateway +++ b/nginx.conf.gateway @@ -80,10 +80,24 @@ http { proxy_set_header X-Forwarded-Host $host; # --- 路由规则 (Locations) --- + # 1. 认证中心 (IdentityServer4) 路由 - 专门处理并移除 'auth' 前缀 + # 匹配 /auth/ 开头的请求 + location ~ ^/auth/ { + # rewrite 规则: + # ^/auth(/.*)$ : 匹配以 /auth 开头,并捕获 / 后面的所有路径到 \$1 + # \$1 : 替换为 \$1,即只保留 /auth 后面的路径 + # break : 停止处理当前的 rewrite 规则,然后处理 proxy_pass + rewrite ^/auth(/.*)$ \$1 break; + proxy_pass https://auth_server; + 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; + } # 1. 认证中心 (IdentityServer4) 路由 # 匹配所有认证相关的路径 - location ~ ^/(auth|connect|Account|\\.well-known)/ { + location ~ ^/(connect|Account|\\.well-known)/ { proxy_pass https://auth_server; }