Skip to content

Commit

Permalink
Merge pull request #1109 from aledbf/fix-forward-headers
Browse files Browse the repository at this point in the history
Cleanup remote address in nginx template
  • Loading branch information
aledbf committed Aug 10, 2017
2 parents cc5c370 + fb3c7c3 commit 45e43f8
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions controllers/nginx/rootfs/etc/nginx/template/nginx.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,15 @@ events {
http {
{{/* we use the value of the header X-Forwarded-For to be able to use the geo_ip module */}}
{{ if $cfg.UseProxyProtocol }}
{{ range $trusted_ip := $cfg.ProxyRealIPCIDR }}
set_real_ip_from {{ $trusted_ip }};
{{ end }}
real_ip_header proxy_protocol;
{{ else }}
{{ range $trusted_ip := $cfg.ProxyRealIPCIDR }}
set_real_ip_from {{ $trusted_ip }};
{{ end }}
real_ip_header X-Forwarded-For;
{{ end }}

real_ip_recursive on;
{{ range $trusted_ip := $cfg.ProxyRealIPCIDR }}
set_real_ip_from {{ $trusted_ip }};
{{ end }}

{{/* databases used to determine the country depending on the client IP address */}}
{{/* http://nginx.org/en/docs/http/ngx_http_geoip_module.html */}}
Expand Down Expand Up @@ -155,7 +152,7 @@ http {
{{ else }}
map $http_x_forwarded_for $the_real_ip {
default $http_x_forwarded_for;
'' $remote_addr;
'' $realip_remote_addr;
}
{{ end }}

Expand Down

0 comments on commit 45e43f8

Please sign in to comment.