vhost: Support manipulating headers

This commit is contained in:
uumas
2024-07-28 00:45:37 +03:00
parent 1dbb9eac4c
commit 3331a96cbc
4 changed files with 37 additions and 3 deletions

View File

@@ -8,6 +8,9 @@
{{ vhost_domains | join(' ') }} {
{% for location in vhost_locations_all %}
handle {{ location.path }} {
{% for header in location.delete_headers %}
header -{{ header }}
{% endfor %}
{% for header in location.headers | dict2items %}
header {{ header.key }} `{{ header.value }}`
{% endfor %}
@@ -26,6 +29,9 @@
}
{% endif %}
}
{% for header in location.proxy_delete_headers %}
request_header -{{ header }}
{% endfor %}
{% elif location.type == 'redirect' %}
redir {{ location.redirect_target }}{{ '{uri}' if location.redirect_preserve_path }} {{ location.redirect_type }}
{% elif location.type == 'respond' %}

View File

@@ -8,7 +8,7 @@
- redirect_target.split('://') | length < 2
- not redirect_target.startswith('/')
- name: Fail if redirect_tartget ends with / and redirect_preserve_path is true
- name: Fail if redirect_target ends with / and redirect_preserve_path is true
ansible.builtin.fail:
msg: redirect_target must not end with / if redirect_preserve_path is true
when:
@@ -25,6 +25,7 @@
'path': item.path,
'type': item.type | default(vhost_type),
'headers': item.headers | default(vhost_headers),
'delete_headers': item.delete_headers | default(vhost_delete_headers),
'basicauth': item.basicauth | default(vhost_basicauth),
'basicauth_users': item.basicauth_users | default(vhost_basicauth_users),
@@ -32,6 +33,7 @@
'proxy_target_port': item.proxy_target_port | default(proxy_target_port if vhost_type == 'reverse_proxy' else ''),
'proxy_target_host': item.proxy_target_host | default(proxy_target_host),
'proxy_target_protocol': item.proxy_target_protocol | default(proxy_target_protocol),
'proxy_delete_headers': item.proxy_delete_headers | default(proxy_delete_headers),
'redirect_target': item.redirect_target | default(redirect_target if vhost_type == 'redirect' else ''),
'redirect_preserve_path': item.redirect_preserve_path | default(redirect_preserve_path),