digitalboard.core/roles/traefik/templates/docker-compose.yml.j2
Simon Bärlocher 99d8968a2e
feat(traefik): configurable extra_hosts for container DNS overrides
Add `traefik_extra_hosts` (list of `host:ip`) that maps straight into
the traefik container's compose `extra_hosts`. Needed when a downstream
middleware (e.g. ForwardAuth to authentik on a sibling LAN) has to
resolve a public FQDN to an internal IP because the DMZ doesn't hairpin
the public address back inside.

Empty by default; behaviour unchanged for existing inventories.
2026-05-27 23:12:23 +02:00

46 lines
No EOL
1.4 KiB
Django/Jinja

services:
traefik:
image: traefik:latest
container_name: traefik
restart: always
{% if traefik_cert_mode == 'acme' %}
environment:
RFC2136_NAMESERVER: "{{ traefik_acme_dns_nameserver }}"
RFC2136_TSIG_ALGORITHM: "{{ traefik_acme_tsig_algorithm }}"
RFC2136_TSIG_KEY: "{{ traefik_acme_tsig_key }}"
RFC2136_TSIG_SECRET: "{{ traefik_acme_tsig_secret }}"
RFC2136_PROPAGATION_TIMEOUT: "{{ traefik_acme_propagation_timeout }}"
RFC2136_POLLING_INTERVAL: "{{ traefik_acme_polling_interval }}"
RFC2136_TTL: "{{ traefik_acme_ttl }}"
{% if traefik_acme_tcp_only | default(false) %}
LEGO_EXPERIMENTAL_DNS_TCP_ONLY: "true"
{% endif %}
{% endif %}
ports:
- "80:80"
- "443:443"
{% if traefik_enable_dashboard and not traefik_dashboard_domain %}
- "8080:8080"
{% endif %}
volumes:
- {{ docker_volume_dir }}/traefik.yml:/traefik.yml:ro
- {{ docker_volume_dir }}/config:/config:ro
{% if traefik_cert_mode == 'acme' %}
- {{ docker_volume_dir }}/letsencrypt:/letsencrypt
{% endif %}
{% if traefik_mode == 'backend' %}
- /var/run/docker.sock:/var/run/docker.sock:ro
{% endif %}
networks:
- {{ traefik_network }}
{% if traefik_extra_hosts | default([]) | length > 0 %}
extra_hosts:
{% for h in traefik_extra_hosts %}
- "{{ h }}"
{% endfor %}
{% endif %}
networks:
{{ traefik_network }}:
name: {{ traefik_network }}
external: true