From f4d3393235d8bbf932f53e045aefcf61f9783bd1 Mon Sep 17 00:00:00 2001 From: Andrea Dell'Amico Date: Mon, 3 Oct 2016 18:35:07 +0200 Subject: [PATCH] library/roles/smartgears/smartgears-nginx-frontend/templates/generic-smartgears-virtualhost.j2: Manage the real_ip scenario when we are behind haproxy. --- .../templates/generic-smartgears-virtualhost.j2 | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/smartgears/smartgears-nginx-frontend/templates/generic-smartgears-virtualhost.j2 b/smartgears/smartgears-nginx-frontend/templates/generic-smartgears-virtualhost.j2 index 90260d49..15ecd3e7 100644 --- a/smartgears/smartgears-nginx-frontend/templates/generic-smartgears-virtualhost.j2 +++ b/smartgears/smartgears-nginx-frontend/templates/generic-smartgears-virtualhost.j2 @@ -86,6 +86,14 @@ server { client_max_body_size 100M; + {% 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 %} + include /etc/nginx/snippets/nginx-server-ssl.conf; # redirect server error pages to the static page /50x.html