21 lines
1 KiB
Django/Jinja
21 lines
1 KiB
Django/Jinja
mode http
|
|
{% for k in o["redirect"] %}
|
|
redirect prefix {{ o["redirect"][k] }} code 301 if { hdr(host) -i {{ k }} }
|
|
{% endfor %}
|
|
|
|
{%- for k in o["hosts"] %}
|
|
{% set host = k.replace(".", "_") + "_{0}".format(o["port"]) %}
|
|
{% set letsencrypt = o["hosts"][k]["letsencrypt"] %}
|
|
|
|
acl is_rule_{{ host }}_1 hdr(host) -i {{ k }}
|
|
acl is_rule_{{ host }}_2 hdr(host) -i {{ k }}:{{ o["port"] }}
|
|
{% if letsencrypt %}
|
|
acl is_letsencrypt_{{ host }} path_beg /.well-known/acme-challenge/
|
|
use_backend letsencrypt_backend if is_letsencrypt_{{ host }} is_rule_{{ host }}_1 OR is_letsencrypt_{{ host }} is_rule_{{ host }}_2
|
|
{% endif %}
|
|
{% if o["hosts"][k]["redirect_ssl"] %}
|
|
http-request redirect scheme https code 301 if {% if letsencrypt %}!is_letsencrypt_{{ host }} {% endif %}is_rule_{{ host }}_1 OR {% if letsencrypt %}!is_letsencrypt_{{ host }} {% endif %}is_rule_{{ host }}_2
|
|
{% else %}
|
|
use_backend srv_{{ host }} if is_rule_{{ host }}_1 OR is_rule_{{ host }}_2
|
|
{% endif %}
|
|
{% endfor %}
|