69 lines
2.9 KiB
Django/Jinja
69 lines
2.9 KiB
Django/Jinja
#jinja2: lstrip_blocks: True
|
|
{{ vhost_domains | join(' ') }} {
|
|
{% for location in _vhost_locations_complete %}
|
|
handle {{ location.path }} {
|
|
{% 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' %}
|
|
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 %}
|
|
}
|