From 8ff9baf0506fdcd64437b548d0c9ef8e2dcea69c Mon Sep 17 00:00:00 2001 From: cli Date: Tue, 26 May 2026 23:20:13 -0400 Subject: [PATCH] =?UTF-8?q?fix(nginx):=20=E8=AF=B7=E6=B1=82=E7=9A=84?= =?UTF-8?q?=E7=AB=AF=E5=8F=A3=E6=9C=AA=E8=BD=AC=E5=8F=91=E5=88=B0=E5=90=8E?= =?UTF-8?q?=E7=AB=AF,=20=E5=AF=BC=E8=87=B4App=E6=8A=A51003=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 转发协议之后, Spring同时会设置端口, 若不转发请求端口, 会变成协议的默认端口, 导致后端接收到请求的端口和App发送请求的端口不一致 2. request_port为1.29.3新增变量, 故升级nginx成最新稳定版 https://nginx.org/en/docs/http/ngx_http_core_module.html#var_request_port --- nginx/compose.yml | 2 +- nginx/conf/conf.d/track.conf.template | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/nginx/compose.yml b/nginx/compose.yml index 41fa83e..25f586d 100644 --- a/nginx/compose.yml +++ b/nginx/compose.yml @@ -1,6 +1,6 @@ services: nginx: - image: nginx:1.27.4 + image: nginx:1.30.2 restart: always ports: - ${WEB_PORT_HTTPS:-443}:443 diff --git a/nginx/conf/conf.d/track.conf.template b/nginx/conf/conf.d/track.conf.template index fe68e10..b103ceb 100644 --- a/nginx/conf/conf.d/track.conf.template +++ b/nginx/conf/conf.d/track.conf.template @@ -76,6 +76,7 @@ server { 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_set_header X-Forwarded-Port $request_port; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade; } @@ -86,6 +87,7 @@ server { 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_set_header X-Forwarded-Port $request_port; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade; }