89 lines
2.3 KiB
Django/Jinja

{
servers {
protocols h1 h2
}
dynamic_dns {
provider cloudflare {{ cloudflare_api_key }}
domains {
{% for domain in domains %}
{% set base_domain = domain.name.lstrip('*.') %}
{% if (domain.dynamic_dns | default(false)) %}
{{ base_domain }} *
{{ base_domain }} @
{% for site in domain.sites %}
{{ base_domain }} {{ site.name }}
{% endfor %}
{% endif %}
{% endfor %}
}
}
grace_period 10s
}
{% for domain in domains %}
{% set base_domain = domain.name.lstrip('*.') %}
{% set domain_var_name = domain.name.replace('.', '') %}
# Subdomain domain proxy for {{ base_domain }}
*.{{ base_domain }} {
tls {
issuer acme {
dns cloudflare {{ cloudflare_api_key }}
}
}
{% for site in domain.sites %}
@{{ site.name }} host {{ site.name }}.{{ base_domain }}
handle @{{ site.name }} {
{% if site.api_path is defined %}
handle_path /{{ site.api_path }}/* {
reverse_proxy {{ site.host }}:{{ site.api_port }} {
transport http {
{% for opt in (site.api_transport_opts | default([])) %}
{{ opt }}
{% endfor %}
}
}
}
{% endif %}
reverse_proxy {{ site.host }}:{{ site.port }} {
transport http {
{% for opt in (site.transport_opts | default([])) %}
{{ opt }}
{% endfor %}
}
}
}
{% endfor %}
}
# Base domain proxy for {{ base_domain }}
{% if domain.host is defined and domain.port is defined %}
{{base_domain}} {
tls {
issuer acme {
dns cloudflare {{ cloudflare_api_key }}
}
}
@{{ domain_var_name }} {
host {{ base_domain}}
}
handle @{{ domain_var_name }} {
handle {
reverse_proxy {{ domain.host }}:{{ domain.port }} {
transport http {
{% for opt in (domain.transport_opts | default([])) %}
{{ opt }}
{% endfor %}
}
}
}
}
}
{% endif %}
{% endfor %}