diff --git a/roles/vhost/meta/argument_specs.yaml b/roles/vhost/meta/argument_specs.yaml index 78795c8..9b0ca0c 100644 --- a/roles/vhost/meta/argument_specs.yaml +++ b/roles/vhost/meta/argument_specs.yaml @@ -247,6 +247,26 @@ argument_specs: type: dict required: false default: {} + match_query: + description: Query to match + type: list + elements: dict + required: false + default: [] + options: + key: + description: Query key to match + type: str + required: true + value: + description: Query value to match. Matches any if unset. + type: str + required: false + reverse: + description: If true, matches request without matching key/value + type: bool + required: false + default: false type: type: str @@ -655,6 +675,26 @@ argument_specs: type: dict required: false default: {} + match_query: + description: Query to match + type: list + elements: dict + required: false + default: [] + options: + key: + description: Query key to match + type: str + required: true + value: + description: Query value to match. Matches any if unset. + type: str + required: false + reverse: + description: If true, matches request without matching key/value + type: bool + required: false + default: false type: type: str diff --git a/roles/vhost/templates/Caddyfile_block.j2 b/roles/vhost/templates/Caddyfile_block.j2 index 3fec4b5..7d54928 100644 --- a/roles/vhost/templates/Caddyfile_block.j2 +++ b/roles/vhost/templates/Caddyfile_block.j2 @@ -10,6 +10,9 @@ {% for matcher in location.matchers %} {% if matcher.name != '' %} @{{ matcher.name }} { + {% for query in matcher.match_query | default([]) %} + {{ 'not ' if query.reverse else '' }}query {{ query.key }}={{ query.value | default('*') }} + {% endfor %} {% if matcher.match_methods | default([]) | length > 0 %} method {{ matcher.match_methods | join(' ') }} {% endif %} diff --git a/roles/vhost/vars/main.yaml b/roles/vhost/vars/main.yaml index a2d1c83..0f28153 100644 --- a/roles/vhost/vars/main.yaml +++ b/roles/vhost/vars/main.yaml @@ -2,6 +2,7 @@ _vhost_matcher_defaults: match_headers: {} match_methods: [] + match_query: [] _vhost_matchers: >- {{ vhost_matchers