vhost: Add support for specifying preserve query independently of

preserve path
This commit is contained in:
uumas
2024-11-05 15:47:21 +02:00
parent 6aabccbe75
commit 05714898eb
4 changed files with 16 additions and 4 deletions

View File

@@ -19,5 +19,6 @@ vhost_proxy_delete_headers: []
vhost_redirect_type: temporary vhost_redirect_type: temporary
vhost_redirect_preserve_path: false vhost_redirect_preserve_path: false
vhost_redirect_preserve_query: "{{ vhost_redirect_preserve_path }}"
vhost_respond_content_type: plain vhost_respond_content_type: plain

View File

@@ -117,8 +117,13 @@ argument_specs:
type: bool type: bool
required: false required: false
default: false default: false
redirect type: vhost_redirect_preserve_query:
description: Only applicable if vhost_type is reverse_proxy description: Whether to keep the original request query string
type: bool
required: false
default: "{{ vhost_redirect_preserve_path }}"
redirect_type:
description: Only applicable if vhost_type is redirect
type: str type: str
required: false required: false
default: temporary default: temporary
@@ -234,8 +239,13 @@ argument_specs:
type: bool type: bool
required: false required: false
default: "{{ vhost_redirect_preserve_path }}" default: "{{ vhost_redirect_preserve_path }}"
redirect_preserve_query:
description: Whether to keep the original request query string
type: bool
required: false
default: "{{ vhost_redirect_preserve_query }}"
redirect_type: redirect_type:
description: Only applicable if vhost_type is reverse_proxy description: Only applicable if vhost_type is redirect
type: str type: str
required: false required: false
default: "{{ vhost_redirect_type }}" default: "{{ vhost_redirect_type }}"

View File

@@ -41,7 +41,7 @@
request_header -{{ header }} request_header -{{ header }}
{% endfor %} {% endfor %}
{% elif location.type == 'redirect' %} {% elif location.type == 'redirect' %}
redir {{ location.redirect_target }}{{ '{uri}' if location.redirect_preserve_path }} {{ location.redirect_type }} redir * {{ location.redirect_target }}{{ '{path}' if location.redirect_preserve_path }}{{ '?{query}' if location.redirect_preserve_query }} {{ location.redirect_type }}
{% elif location.type == 'respond' %} {% elif location.type == 'respond' %}
{% if location.respond_content_type == 'json' %} {% if location.respond_content_type == 'json' %}
respond `{{ location.respond_content | to_json }}` respond `{{ location.respond_content | to_json }}`

View File

@@ -41,6 +41,7 @@
'redirect_target': item.redirect_target | default(vhost_redirect_target if vhost_type == 'redirect' else ''), 'redirect_target': item.redirect_target | default(vhost_redirect_target if vhost_type == 'redirect' else ''),
'redirect_preserve_path': item.redirect_preserve_path | default(vhost_redirect_preserve_path), 'redirect_preserve_path': item.redirect_preserve_path | default(vhost_redirect_preserve_path),
'redirect_preserve_query': item.redirect_preserve_query | default(vhost_redirect_preserve_query),
'redirect_type': item.redirect_type | default(vhost_redirect_type), 'redirect_type': item.redirect_type | default(vhost_redirect_type),
'respond_content': item.respond_content | default(vhost_respond_content if vhost_type == 'respond' else ''), 'respond_content': item.respond_content | default(vhost_respond_content if vhost_type == 'respond' else ''),