diff --git a/nginx_proxy.py b/nginx_proxy.py index 84de4b8..aaafb94 100755 --- a/nginx_proxy.py +++ b/nginx_proxy.py @@ -18,8 +18,9 @@ server { location / { client_max_body_size $body_size; client_body_timeout 300s; - proxy_set_header X-Real-IP $$remote_addr; - proxy_set_header X-Forwarded-For $$remote_addr; + if ($$http_x_forwarded_for = "") { + add_header X-Forwarded-For $$remote_addr; + } proxy_set_header Host $$host; proxy_pass http://$ip:$port/; } @@ -36,8 +37,9 @@ server { location /$location { client_max_body_size $body_size; client_body_timeout 300s; - proxy_set_header X-Real-IP $$remote_addr; - proxy_set_header X-Forwarded-For $$remote_addr; + if ($$http_x_forwarded_for = "") { + add_header X-Forwarded-For $$remote_addr; + } proxy_set_header Host $$host; proxy_pass http://$ip:$port/; }