nginx real_ip if behind haproxy.

This commit is contained in:
Andrea Dell'Amico 2022-01-10 23:17:39 +01:00
parent 88d2432cf6
commit 22dfe8eab4
Signed by: adellam
GPG Key ID: 147ABE6CEB9E20FF
1 changed files with 8 additions and 0 deletions

View File

@ -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.