From 1cc1f240bbcdc3a2249336fd5850aaabd4df2be5 Mon Sep 17 00:00:00 2001 From: Andrea Dell'Amico Date: Fri, 28 May 2021 19:00:52 +0200 Subject: [PATCH] nginx_proxy_define_header_host --- defaults/main.yml | 1 + templates/nginx-proxy-params.conf.j2 | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/defaults/main.yml b/defaults/main.yml index 16d9897..0d2b15a 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -57,6 +57,7 @@ nginx_css_js_cache_expire: -1 nginx_reverse_proxy: False nginx_define_x_real_ip: False +nginx_proxy_define_header_host: True nginx_set_original_uri: True nginx_proxy_buffering: "on" nginx_proxy_redirect: "off" diff --git a/templates/nginx-proxy-params.conf.j2 b/templates/nginx-proxy-params.conf.j2 index ea32c99..900ce90 100644 --- a/templates/nginx-proxy-params.conf.j2 +++ b/templates/nginx-proxy-params.conf.j2 @@ -3,14 +3,18 @@ proxy_http_version 1.1; proxy_set_header Connection ""; {% if haproxy_ips is defined %} +{% if not nginx_proxy_define_header_host %} proxy_set_header Host $http_host; +{% endif %} {% if nginx_behind_haproxy_settings %} proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-Host {{ nginx_x_forwarded_host }}; proxy_set_header X-Forwarded-Server $host; {% endif %} {% else %} +{% if not nginx_proxy_define_header_host %} proxy_set_header Host $host; +{% endif %} {% if nginx_define_x_real_ip %} proxy_set_header X-Real-IP $remote_addr; {% endif %}