vhost: Add support for custom matchers and specifying response status
This commit is contained in:
@@ -116,7 +116,7 @@ argument_specs:
|
||||
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
|
||||
type: bool
|
||||
required: false
|
||||
default: true
|
||||
|
||||
@@ -155,6 +155,178 @@ argument_specs:
|
||||
choices:
|
||||
- plain
|
||||
- json
|
||||
vhost_respond_status:
|
||||
description: Status code of response
|
||||
type: int
|
||||
required: false
|
||||
default: 200
|
||||
|
||||
vhost_matchers:
|
||||
description: >
|
||||
List of matchers to handle differently from the default for vhost.
|
||||
A matcher matches if all of its conditions match
|
||||
type: list
|
||||
elements: dict
|
||||
required: false
|
||||
default: []
|
||||
options:
|
||||
name:
|
||||
description: Name of the matcher used to reference it
|
||||
type: str
|
||||
required: true
|
||||
|
||||
match_methods:
|
||||
description: HTTP methods to match against. Matching one method is enough.
|
||||
type: list
|
||||
elements: str
|
||||
choices:
|
||||
- GET
|
||||
- HEAD
|
||||
- OPTIONS
|
||||
- TRACE
|
||||
- PUT
|
||||
- DELETE
|
||||
- POST
|
||||
- PATCH
|
||||
- CONNECT
|
||||
required: false
|
||||
default: []
|
||||
match_headers:
|
||||
description: >-
|
||||
Headers to match against.
|
||||
If the value begins with ^ and end with $, the value is matched as regex.
|
||||
type: dict
|
||||
required: false
|
||||
default: {}
|
||||
|
||||
type:
|
||||
type: str
|
||||
required: false
|
||||
default: "{{ vhost_type }}"
|
||||
choices:
|
||||
- reverse_proxy
|
||||
- redirect
|
||||
- respond
|
||||
headers:
|
||||
description: Dict of response headers and their values
|
||||
type: dict
|
||||
required: false
|
||||
default: "{{ vhost_headers }}"
|
||||
delete_headers:
|
||||
description: List of response headers to delete
|
||||
type: list
|
||||
elements: str
|
||||
required: false
|
||||
default: "{{ vhost_delete_headers }}"
|
||||
|
||||
basicauth:
|
||||
description: Whether to require basic auth for the location
|
||||
type: bool
|
||||
required: false
|
||||
default: "{{ vhost_basicauth }}"
|
||||
basicauth_users:
|
||||
description: A dict of basic auth users and their password hashes. Required if basicauth is true
|
||||
type: dict
|
||||
default: "{{ vhost_basicauth_users }}"
|
||||
|
||||
proxy_target_netproto:
|
||||
description:
|
||||
- Network protocol to use for proxy requests.
|
||||
- Only applicable if type is reverse_proxy.
|
||||
type: str
|
||||
required: false
|
||||
default: "{{ vhost_proxy_target_netproto }}"
|
||||
choices:
|
||||
- tcp
|
||||
- unix
|
||||
proxy_target_protocol:
|
||||
description:
|
||||
- Transport protocol (scheme) to use for proxy requests.
|
||||
- Only applicable if type is reverse_proxy.
|
||||
type: str
|
||||
required: false
|
||||
default: "{{ vhost_proxy_target_protocol }}"
|
||||
choices:
|
||||
- http
|
||||
- https
|
||||
proxy_target_host:
|
||||
description: Host where to proxy requests to. Only applicable if type is reverse_proxy
|
||||
type: str
|
||||
required: false
|
||||
default: "{{ vhost_proxy_target_host }}"
|
||||
proxy_target_port:
|
||||
description: Port where to proxy requests to. Only applicable if type is reverse_proxy.
|
||||
type: int
|
||||
required: false
|
||||
default: "{{ vhost_proxy_target_port if vhost_type == 'reverse_proxy' and vhost_proxy_target_netproto == 'tcp' else 0 }}"
|
||||
proxy_target_socket:
|
||||
description:
|
||||
- Unix socket path to proxy requests to.
|
||||
- Only applicable if type is reverse_proxy and proxy_target_netproto is unix.
|
||||
type: str
|
||||
required: false
|
||||
default: "{{ vhost_proxy_target_socket if vhost_type == 'reverse_proxy' and vhost_proxy_target_netproto == 'unix' else '' }}"
|
||||
proxy_headers:
|
||||
description: Dict of request headers and their values to set for proxied requests
|
||||
type: dict
|
||||
required: false
|
||||
default: "{{ vhost_proxy_headers }}"
|
||||
proxy_delete_headers:
|
||||
description: List of request headers to delete from proxied requests
|
||||
type: list
|
||||
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)
|
||||
type: 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"
|
||||
type: str
|
||||
required: false
|
||||
default: "{{ vhost_redirect_target if vhost_type == 'redirect' else '' }}"
|
||||
redirect_preserve_path:
|
||||
description: Whether to keep the original request path
|
||||
type: bool
|
||||
required: false
|
||||
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:
|
||||
description: Only applicable if vhost_type is redirect
|
||||
type: str
|
||||
required: false
|
||||
default: "{{ vhost_redirect_type }}"
|
||||
choices:
|
||||
- temporary
|
||||
- permanent
|
||||
|
||||
respond_content:
|
||||
description: >-
|
||||
Content to respond with.
|
||||
Json content can be set as yaml as long as respond_content_type is set to json.
|
||||
type: str
|
||||
required: false
|
||||
default: "{{ vhost_respond_content if vhost_type == 'respond' else '' }}"
|
||||
respond_content_type:
|
||||
description: Type of the respond content
|
||||
type: str
|
||||
required: false
|
||||
default: "{{ vhost_respond_content_type }}"
|
||||
choices:
|
||||
- plain
|
||||
- json
|
||||
respond_status:
|
||||
description: Status code of response
|
||||
type: int
|
||||
required: false
|
||||
default: "{{ vhost_respond_status }}"
|
||||
|
||||
vhost_locations:
|
||||
description: List of locations to handle differently from the default for vhost
|
||||
@@ -247,7 +419,7 @@ argument_specs:
|
||||
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
|
||||
type: bool
|
||||
required: false
|
||||
default: "{{ vhost_proxy_pass_host_header }}"
|
||||
|
||||
@@ -276,7 +448,9 @@ argument_specs:
|
||||
- permanent
|
||||
|
||||
respond_content:
|
||||
description: Content to respond with. Json content can be set as yaml as long as respond_content_type is set to json
|
||||
description: >-
|
||||
Content to respond with.
|
||||
Json content can be set as yaml as long as respond_content_type is set to json.
|
||||
type: str
|
||||
required: false
|
||||
default: "{{ vhost_respond_content if vhost_type == 'respond' else '' }}"
|
||||
@@ -288,3 +462,157 @@ argument_specs:
|
||||
choices:
|
||||
- plain
|
||||
- json
|
||||
respond_status:
|
||||
description: Status code of response
|
||||
type: int
|
||||
required: false
|
||||
default: "{{ vhost_respond_status }}"
|
||||
|
||||
matchers:
|
||||
description: >
|
||||
List of matchers to handle differently from the default for vhost.
|
||||
A matcher matches if all of its conditions match.
|
||||
Options without a specified default will default to location's corresponding option.
|
||||
type: list
|
||||
elements: dict
|
||||
required: false
|
||||
default: "{{ vhost_matchers }}"
|
||||
options:
|
||||
name:
|
||||
description: Name of the matcher used to reference it
|
||||
type: str
|
||||
required: true
|
||||
|
||||
match_methods:
|
||||
description: HTTP methods to match against. Matching one method is enough.
|
||||
type: list
|
||||
elements: str
|
||||
choices:
|
||||
- GET
|
||||
- HEAD
|
||||
- OPTIONS
|
||||
- TRACE
|
||||
- PUT
|
||||
- DELETE
|
||||
- POST
|
||||
- PATCH
|
||||
- CONNECT
|
||||
required: false
|
||||
default: []
|
||||
match_headers:
|
||||
description: >-
|
||||
Headers to match against.
|
||||
The value is matched as regex.
|
||||
^ and $ are implied, so don't add them yourself.
|
||||
type: dict
|
||||
required: false
|
||||
default: {}
|
||||
|
||||
type:
|
||||
type: str
|
||||
required: false
|
||||
choices:
|
||||
- reverse_proxy
|
||||
- redirect
|
||||
- respond
|
||||
headers:
|
||||
description: Dict of response headers and their values
|
||||
type: dict
|
||||
required: false
|
||||
delete_headers:
|
||||
description: List of response headers to delete
|
||||
type: list
|
||||
elements: str
|
||||
required: false
|
||||
|
||||
basicauth:
|
||||
description: Whether to require basic auth for the location
|
||||
type: bool
|
||||
required: false
|
||||
basicauth_users:
|
||||
description: A dict of basic auth users and their password hashes. Required if basicauth is true
|
||||
type: dict
|
||||
|
||||
proxy_target_netproto:
|
||||
description:
|
||||
- Network protocol to use for proxy requests.
|
||||
- Only applicable if type is reverse_proxy.
|
||||
type: str
|
||||
required: false
|
||||
choices:
|
||||
- tcp
|
||||
- unix
|
||||
proxy_target_protocol:
|
||||
description:
|
||||
- Transport protocol (scheme) to use for proxy requests.
|
||||
- Only applicable if type is reverse_proxy.
|
||||
type: str
|
||||
required: false
|
||||
choices:
|
||||
- http
|
||||
- https
|
||||
proxy_target_host:
|
||||
description: Host where to proxy requests to. Only applicable if type is reverse_proxy
|
||||
type: str
|
||||
required: false
|
||||
proxy_target_port:
|
||||
description: Port where to proxy requests to. Only applicable if type is reverse_proxy.
|
||||
type: int
|
||||
required: false
|
||||
proxy_target_socket:
|
||||
description:
|
||||
- Unix socket path to proxy requests to.
|
||||
- Only applicable if type is reverse_proxy and proxy_target_netproto is unix.
|
||||
type: str
|
||||
required: false
|
||||
proxy_headers:
|
||||
description: Dict of request headers and their values to set for proxied requests
|
||||
type: dict
|
||||
required: false
|
||||
proxy_delete_headers:
|
||||
description: List of request headers to delete from proxied requests
|
||||
type: list
|
||||
elements: str
|
||||
required: false
|
||||
proxy_pass_host_header:
|
||||
description: Whether to pass the host header unchanged (true) or change it to the proxy target host (false)
|
||||
type: bool
|
||||
required: false
|
||||
|
||||
redirect_target:
|
||||
description: "Only applicable if vhost_type is redirect. Example: https://www.domain.tld/location"
|
||||
type: str
|
||||
required: false
|
||||
redirect_preserve_path:
|
||||
description: Whether to keep the original request path
|
||||
type: bool
|
||||
required: false
|
||||
redirect_preserve_query:
|
||||
description: Whether to keep the original request query string
|
||||
type: bool
|
||||
required: false
|
||||
redirect_type:
|
||||
description: Only applicable if vhost_type is redirect
|
||||
type: str
|
||||
required: false
|
||||
choices:
|
||||
- temporary
|
||||
- permanent
|
||||
|
||||
respond_content:
|
||||
description: >-
|
||||
Content to respond with.
|
||||
Json content can be set as yaml as long as respond_content_type is set to json.
|
||||
type: str
|
||||
required: false
|
||||
respond_content_type:
|
||||
description: Type of the respond content
|
||||
type: str
|
||||
required: false
|
||||
choices:
|
||||
- plain
|
||||
- json
|
||||
respond_status:
|
||||
description: Status code of response
|
||||
type: int
|
||||
required: false
|
||||
|
||||
Reference in New Issue
Block a user