Add support for not passing host header to proxy upstream

This commit is contained in:
uumas
2025-04-05 03:58:48 +03:00
parent 6234c0c459
commit d9f8733c39
4 changed files with 15 additions and 0 deletions

View File

@@ -15,6 +15,7 @@ vhost_proxy_target_netproto: tcp
vhost_proxy_target_protocol: http
vhost_proxy_target_host: localhost
vhost_proxy_delete_headers: []
vhost_proxy_pass_host_header: true
vhost_redirect_type: temporary
vhost_redirect_preserve_path: false

View File

@@ -109,6 +109,11 @@ argument_specs:
elements: str
required: false
default: []
vhost_proxy_pass_host_header:
description: Whether to pass the host header unchanged (true) or change it to the proxy target host (false)
trpe: bool
required: false
default: true
vhost_redirect_target:
description: "Only applicable if vhost_type is redirect. Example: https://www.domain.tld/location"
@@ -230,6 +235,11 @@ argument_specs:
elements: str
required: false
default: "{{ vhost_proxy_delete_headers }}"
proxy_pass_host_header:
description: Whether to pass the host header unchanged (true) or change it to the proxy target host (false)
trpe: bool
required: false
default: "{{ vhost_proxy_pass_host_header }}"
redirect_target:
description: "Only applicable if vhost_type is redirect. Example: https://www.domain.tld/location"

View File

@@ -33,6 +33,9 @@
{% for header in location.proxy_delete_headers %}
header_up -{{ header }}
{% endfor %}
{% if not location.proxy_pass_host_header %}
header_up Host {upstream_hostport}
{% endif %}
}
{% elif location.type == 'redirect' %}
redir * {{ location.redirect_target }}{{ '{path}' if location.redirect_preserve_path }}{{ '?{query}' if location.redirect_preserve_query }} {{ location.redirect_type }}

View File

@@ -15,6 +15,7 @@ _vhost_location_defaults:
proxy_target_socket: "{{ vhost_proxy_target_socket if
vhost_type == 'reverse_proxy' and vhost_proxy_target_netproto == 'unix' else '' }}"
proxy_delete_headers: "{{ vhost_proxy_delete_headers }}"
proxy_pass_host_header: "{{ vhost_proxy_pass_host_header }}"
redirect_target: "{{ vhost_redirect_target if vhost_type == 'redirect' else '' }}"
redirect_preserve_path: "{{ vhost_redirect_preserve_path }}"