diff --git a/roles/vhost/templates/Caddyfile_block.j2 b/roles/vhost/templates/Caddyfile_block.j2 index 9b228e8..8269591 100644 --- a/roles/vhost/templates/Caddyfile_block.j2 +++ b/roles/vhost/templates/Caddyfile_block.j2 @@ -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 %} } @@ -79,7 +79,7 @@ {% endif %} {% endif %} } - {% endfor %} + {% endfor %} } {% endfor %} } diff --git a/roles/vhost/vars/main.yaml b/roles/vhost/vars/main.yaml index e7f7816..e027590 100644 --- a/roles/vhost/vars/main.yaml +++ b/roles/vhost/vars/main.yaml @@ -1,7 +1,7 @@ --- _vhost_matcher_defaults: match_headers: {} - match_method: [] + match_methods: [] _vhost_matchers: >- {{ vhost_matchers