#jinja2: lstrip_blocks: True {{ vhost_domains | join(' ') }} { {% for location in _vhost_locations_complete %} {% if location.path != '' %} @{{ location.path }} path{{ '_regexp' if location.path.startswith('^') and location.path.endswith('$') else '' }} {{ location.path }} handle @{{ location.path }} { {% else %} handle { {% endif %} {% for matcher in location.matchers %} {% if matcher.name != '' %} @{{ matcher.name }} { {% if matcher.match_methods | length > 0 %} method {{ matcher.match_methods | join(' ') }} {% endif %} {% for header in matcher.match_headers | dict2items %} header{{ '_regexp' if header.value.startswith('^') and header.value.endswith('$') else '' }} {{ header.key }} {{ header.value }} {% endfor %} } {% endif %} handle{{ ' @' ~ matcher.name if matcher.name != '' else '' }} { {% for header in matcher.delete_headers %} header -{{ header }} {% endfor %} {% for header in matcher.headers | dict2items %} header {{ header.key }} `{{ header.value }}` {% endfor %} {% if matcher.basicauth %} basicauth { {% for user in matcher.basicauth_users | dict2items %} {{ user.key }} {{ user.value }} {% endfor %} } {% endif %} {% if matcher.type == 'reverse_proxy' %} {% if matcher.proxy_auth_socket | length > 0 %} forward_auth { to unix//{{ matcher.proxy_auth_socket }} uri {{ matcher.proxy_auth_uri }} {% if matcher.proxy_auth_unauthorized_redir | length > 0 %} @unauthorized status 401 handle_response @unauthorized { redir * {{ matcher.proxy_auth_unauthorized_redir }} } {% endif %} } {% endif %} reverse_proxy { {% if matcher.proxy_target_netproto == 'tcp' %} to tcp/{{ matcher.proxy_target_host }}:{{ matcher.proxy_target_port }} {% else %} to unix/{{ matcher.proxy_target_socket }} {% endif %} {% if matcher.proxy_target_protocol == 'https' %} transport http { tls {% if matcher.proxy_target_host == 'localhost' %} tls_insecure_skip_verify {% endif %} } {% endif %} {% for header in matcher.proxy_delete_headers %} header_up -{{ header }} {% endfor %} {% for header in matcher.proxy_headers | dict2items %} header_up {{ header.key }} `{{ header.value }}` {% endfor %} {% if (not matcher.proxy_pass_host_header) and ('host' not in matcher.proxy_headers | map('lower')) %} header_up Host {upstream_hostport} {% endif %} } {% elif matcher.type == 'redirect' %} redir * {{ matcher.redirect_target }}{{ '{path}' if matcher.redirect_preserve_path }}{{ '?{query}' if matcher.redirect_preserve_query }} {{ matcher.redirect_type }} {% elif matcher.type == 'respond' %} {% if matcher.respond_content_type == 'json' %} respond `{{ matcher.respond_content | to_json }}` {% else %} respond `{{ matcher.respond_content }}` {{ matcher.respond_status }} {% endif %} {% endif %} } {% endfor %} } {% endfor %} }