From 029a3820bb6a30a3c50cf77b9e202fb33b5e7132 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 26 Feb 2026 10:08:11 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E6=AD=A3=20nginx=20trailing=20?= =?UTF-8?q?slash=20=E5=AF=BC=E8=87=B4=E8=B7=AF=E7=94=B1=E4=BB=A3=E7=90=86?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - location 使用 /login/qrcode (不带尾部斜杠) - proxy_pass 使用 http://127.0.0.1:8787 (不带路径) - 这样可以完整传递 URI 到后端 Co-Authored-By: Claude Opus 4.6 --- nginx/x-server-api.conf | 60 ++++++----------------------------------- 1 file changed, 8 insertions(+), 52 deletions(-) diff --git a/nginx/x-server-api.conf b/nginx/x-server-api.conf index 315ada3..d73ddc6 100644 --- a/nginx/x-server-api.conf +++ b/nginx/x-server-api.conf @@ -1,53 +1,9 @@ -server { - listen 80; - server_name api.x-server.local; # 本地测试域名 - - # API 反向代理 - location /api/ { - proxy_pass http://127.0.0.1:8787/api/; - proxy_http_version 1.1; - - # 传递真实IP - 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; - - # CORS 头部(用于开发调试) - add_header Access-Control-Allow-Origin *; - add_header Access-Control-Allow-Methods 'GET, POST, PUT, DELETE, OPTIONS'; - add_header Access-Control-Allow-Headers 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization'; - - # 处理 OPTIONS 预检请求 - if ($request_method = 'OPTIONS') { - return 204; - } - - # 超时设置 - proxy_connect_timeout 60s; - proxy_send_timeout 60s; - proxy_read_timeout 60s; - } - - # 飞书登录回调代理 - location /login/qrcode/ { - proxy_pass http://127.0.0.1:8787/login/qrcode/; - proxy_http_version 1.1; - - # 传递真实IP - 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; - - # 超时设置 - proxy_connect_timeout 60s; - proxy_send_timeout 60s; - proxy_read_timeout 60s; - } - - # 健康检查端点 - location /health { - access_log off; - return 200 "healthy\n"; - add_header Content-Type text/plain; - } +# 飞书登录回调代理 +# 注意:location 不带 trailing slash,proxy_pass 不带路径 +location /login/qrcode { + proxy_pass http://127.0.0.1:8787; + proxy_http_version 1.1; + 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; }