Compare commits

...

2 Commits

Author SHA1 Message Date
uumas
601d5fcdc3 vhost: Support settting requst method for proxied requests 2025-11-22 06:43:25 +02:00
uumas
c151a2ee0c vhost: fix defaults for matchers 2025-11-22 05:55:56 +02:00
4 changed files with 45 additions and 5 deletions

View File

@@ -14,6 +14,7 @@ vhost_basicauth_users: {}
vhost_proxy_target_netproto: tcp
vhost_proxy_target_protocol: http
vhost_proxy_target_host: localhost
vhost_proxy_method: ""
vhost_proxy_headers: {}
vhost_proxy_delete_headers: []
vhost_proxy_pass_host_header: true

View File

@@ -103,6 +103,15 @@ argument_specs:
- Only applicable if vhost_type is reverse_proxy and vhost_proxy_target_netproto is unix.
type: str
required: false
vhost_proxy_method:
description: Method to set for proxied requests
type: str
required: false
default: ""
choices:
- ""
- GET
- POST
vhost_proxy_headers:
description: Dict of request headers and their values to set for proxied requests
type: dict
@@ -287,6 +296,15 @@ argument_specs:
type: str
required: false
default: "{{ vhost_proxy_target_socket if vhost_type == 'reverse_proxy' and vhost_proxy_target_netproto == 'unix' else '' }}"
proxy_method:
description: Method to set for proxied requests
type: str
required: false
default: "{{ vhost_proxy_method }}"
choices:
- ""
- GET
- POST
proxy_headers:
description: Dict of request headers and their values to set for proxied requests
type: dict
@@ -450,6 +468,15 @@ argument_specs:
type: str
required: false
default: "{{ vhost_proxy_target_socket if vhost_type == 'reverse_proxy' and vhost_proxy_target_netproto == 'unix' else '' }}"
proxy_method:
description: Method to set for proxied requests
type: str
required: false
default: "{{ vhost_proxy_method }}"
choices:
- ""
- GET
- POST
proxy_headers:
description: Dict of request headers and their values to set for proxied requests
type: dict
@@ -629,6 +656,14 @@ argument_specs:
- Only applicable if type is reverse_proxy and proxy_target_netproto is unix.
type: str
required: false
proxy_method:
description: Method to set for proxied requests
type: str
required: false
choices:
- ""
- GET
- POST
proxy_headers:
description: Dict of request headers and their values to set for proxied requests
type: dict

View File

@@ -7,13 +7,13 @@
{% else %}
handle {
{% endif %}
{% for matcher in location.matchers %}
{% for matcher in location.matchers %}
{% if matcher.name != '' %}
@{{ matcher.name }} {
{% if matcher.match_methods | length > 0 %}
{% if matcher.match_methods | default([]) | length > 0 %}
method {{ matcher.match_methods | join(' ') }}
{% endif %}
{% for header in matcher.match_headers | dict2items %}
{% for header in matcher.match_headers | default({}) | dict2items %}
header{{ '_regexp' if header.value.startswith('^') and header.value.endswith('$') else '' }} {{ header.key }} {{ header.value }}
{% endfor %}
}
@@ -59,6 +59,9 @@
{% endif %}
}
{% endif %}
{% if matcher.proxy_method | length > 0 %}
method {{ matcher.proxy_method }}
{% endif %}
{% for header in matcher.proxy_delete_headers %}
header_up -{{ header }}
{% endfor %}
@@ -79,7 +82,7 @@
{% endif %}
{% endif %}
}
{% endfor %}
{% endfor %}
}
{% endfor %}
}

View File

@@ -1,7 +1,7 @@
---
_vhost_matcher_defaults:
match_headers: {}
match_method: []
match_methods: []
_vhost_matchers: >-
{{
vhost_matchers
@@ -25,6 +25,7 @@ _vhost_location_defaults:
vhost_type == 'reverse_proxy' and vhost_proxy_target_netproto == 'tcp' else '' }}"
proxy_target_socket: "{{ vhost_proxy_target_socket if
vhost_type == 'reverse_proxy' and vhost_proxy_target_netproto == 'unix' else '' }}"
proxy_method: "{{ vhost_proxy_method }}"
proxy_headers: "{{ vhost_proxy_headers }}"
proxy_delete_headers: "{{ vhost_proxy_delete_headers }}"
proxy_pass_host_header: "{{ vhost_proxy_pass_host_header }}"