From ca543dcb5b1b49c6814e9e4c2e3b456e2de161e2 Mon Sep 17 00:00:00 2001 From: Joachim Lusiardi Date: Fri, 30 Dec 2016 14:42:31 +0100 Subject: [PATCH] fixed handling of X-Forwarded-For, removed X-Real-IP stuff --- nginx_proxy.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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/; }