From 15ad3fb2001d4eed0fa74e195177e5084ba73ab2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B5=85=E5=BF=B5?= Date: Wed, 16 Sep 2026 14:18:25 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20nginx=20XFF=20=E6=94=B9=E9=80=8F?= =?UTF-8?q?=E4=BC=A0=E2=80=94=E2=80=94=E5=8F=8C=E5=B1=82=E4=BB=A3=E7=90=86?= =?UTF-8?q?=E4=B8=8B=E8=BF=BD=E5=8A=A0=E8=87=AA=E8=BA=AB=E4=BC=9A=E6=8E=A9?= =?UTF-8?q?=E7=9B=96=E7=9C=9F=E5=AE=9E=E5=AE=A2=E6=88=B7=E7=AB=AFIP?= =?UTF-8?q?=EF=BC=88=E7=94=9F=E4=BA=A7=E8=B8=A9=E5=9D=91=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Code --- deploy/nginx.conf | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/deploy/nginx.conf b/deploy/nginx.conf index c56244f..5904789 100644 --- a/deploy/nginx.conf +++ b/deploy/nginx.conf @@ -14,8 +14,9 @@ server { location /api/ { client_max_body_size 256k; proxy_pass http://web:8000; - # X-Forwarded-For 必传:DRF NUM_PROXIES=1 取末段还原真实客户端 IP - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + # XFF 透传上层(1Panel OpenResty 已追加真实客户端IP),勿再追加自身—— + # 否则 Django 取末段会拿到 Docker 网关 IP(172.20.x.1),真实IP与地理位置全丢 + proxy_set_header X-Forwarded-For $http_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header Host $host; }