From a2d9c6e48be809c2eab67ae9deed6182a50cc353 Mon Sep 17 00:00:00 2001 From: Manuel de Brito Fontes Date: Tue, 5 Jul 2016 12:37:54 -0400 Subject: [PATCH] Fix duplicated real_ip_header --- controllers/nginx/nginx.tmpl | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/controllers/nginx/nginx.tmpl b/controllers/nginx/nginx.tmpl index 3b2cf1f58..1f178a636 100644 --- a/controllers/nginx/nginx.tmpl +++ b/controllers/nginx/nginx.tmpl @@ -17,8 +17,14 @@ events { http { {{/* we use the value of the header X-Forwarded-For to be able to use the geo_ip module */}} + {{ if $cfg.useProxyProtocol -}} + set_real_ip_from {{ $cfg.proxyRealIpCidr }}; + real_ip_header proxy_protocol; + {{ else }} real_ip_header X-Forwarded-For; set_real_ip_from 0.0.0.0/0; + {{ end -}} + real_ip_recursive on; {{/* databases used to determine the country depending on the client IP address */}} @@ -67,11 +73,6 @@ http { client_max_body_size "{{ $cfg.bodySize }}"; - {{ if $cfg.useProxyProtocol -}} - set_real_ip_from {{ $cfg.proxyRealIpCidr }}; - real_ip_header proxy_protocol; - {{ end -}} - log_format upstreaminfo '{{ if $cfg.useProxyProtocol }}$proxy_protocol_addr{{ else }}$remote_addr{{ end }} - ' '[$proxy_add_x_forwarded_for] - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent" ' '$request_length $request_time $upstream_addr $upstream_response_length $upstream_response_time $upstream_status';