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';