diff --git a/templates/nginx-virthost.conf.j2 b/templates/nginx-virthost.conf.j2 index 5938850..e0e8bcf 100644 --- a/templates/nginx-virthost.conf.j2 +++ b/templates/nginx-virthost.conf.j2 @@ -29,6 +29,14 @@ server { include /etc/nginx/snippets/nginx-server-ssl.conf; server_tokens off; + {% if haproxy_ips is defined %} + # We are behind haproxy + {% for ip in haproxy_ips %} + set_real_ip_from {{ ip }}; + {% endfor %} + real_ip_header X-Forwarded-For; + {% endif %} + # Add headers to serve security related headers # Before enabling Strict-Transport-Security headers please read into this # topic first.