Traefik Security Hardening
How the containers are protected
Section titled “How the containers are protected”By default, Traefik is configured with an allowlist that only permits private IPs (RFC1918) to access containers.
Exception: If you route a container through Cloudflare Tunnel, the traffic goes directly to the container and bypasses Traefik entirely. Traefik allowlists and middlewares do not apply to Tunnel traffic.
This is controlled on a per-container basis in the inventory/group_vars/all/container_map.yml file as the expose_to_public variable for each container. If you set this to true, it will allow all IPs (0.0.0.0/0) to access them.
To configure SSO (Single Sign-On) for certain containers, see the Authentik docs
Security Hardening
Section titled “Security Hardening”There is a traefik_security_hardening variable in inventory/group_vars/all/traefik.yml that will do the following if enabled:
- Enforce HTTPS only requests
- Enforce Traefik dashboard over secure connection
- Disable port
8080access to Traefik- This will also disable Homepage integration with Traefik
- Only allows requests to services/Hosts with Traefik enabled
- Disable TLS1.0 and TLS1.1 and use TLS1.2 as the new minimum
- Add security headers for the following:
X-Frame-Options: DENY: [Mozilla Docs] Denies iFrame embeddingX-Content-Type-Options: nosniff: [Mozilla Docs] Blocks a request if the request destination is of type style and the MIME type is not text/css, or of type script and the MIME type is not a JavaScript MIME type
Middlewares
Section titled “Middlewares”The following middlewares are available:
internal-secured: A chain, applies theinternal-ipallowlist,https-only,secure-headersexternal-secured: A chain, applies theexternal-ipallowlist,https-only,secure-headersinternal-ipallowlist: Allows only RFC1918 private address space and any other IPs/ranges defined in thetraefik_subnet_allow_listvariableexternal-ipallowlist: Allows all traffic from0.0.0.0/0https-only: Configures permanent redirection to HTTPSsecure-headers: Applies headers to prevent iFrame embedding, blocks requests if MIME types do not match certain criteria, and only allows Host headers for applications that are enabled within this project