docs/content/integration/proxies/traefikv1.md
Traefik v1 is a reverse proxy formally supported by Authelia.
Important: When using these guides, it's important to recognize that we cannot provide a guide for every possible method of deploying a proxy. These guides show a suggested setup only, and you need to understand the proxy configuration and customize it to your needs. To-that-end, we include links to the official proxy documentation throughout this documentation and in the See Also section.
{{< callout context="caution" title="Important Note" icon="outline/alert-triangle" >}} Traefik formally has removed support for this version of Traefik. As such we no longer formally support it either. This guide will remain at least for a time as a form of legacy support. {{< /callout >}}
It's strongly recommended that users setting up Authelia for the first time take a look at our Get started guide. This takes you through various steps which are essential to bootstrapping Authelia.
{{< callout context="danger" title="Security Note" icon="outline/alert-octagon" >}} In addition to this section which is important to read, you should read the Validating Forwarded Authentication reference guide and perform the validation steps as part of your regular security validation routine when using this integration. {{< /callout >}}
Important: You should read the Forwarded Headers section and this section as part of any proxy configuration. Especially if you have never read it before.
Important: The included example is NOT meant for production use. It's used expressly as an example to showcase how you can configure multiple IP ranges. You should customize this example to fit your specific architecture and needs. You should only include the specific IP address ranges of the trusted proxies within your architecture and should not trust entire subnets unless that subnet only has trusted proxies and no other services.
Traefik by default doesn't trust any other proxies requiring explicit configuration of which proxies are trusted and removes potentially fabricated headers that are likely to lead to security issues, and it is difficult to configure this incorrectly. This is an important security feature that is common with proxies with good security practices.
In the example we have four commented lines which configure TrustedIPs which show an example on adding the following
networks to the trusted proxy list in Traefik:
This guide makes a few assumptions. These assumptions may require adaptation in more advanced and complex scenarios. We can not reasonably have examples for every advanced configuration option that exists. Some of these values can automatically be replaced with documentation variables.
{{< sitevar-preferences >}}
The following are the assumptions we make:
{{< sitevar name="host" nojs="authelia" >}} on port {{< sitevar name="port" nojs="9091" >}}{{< sitevar name="tls" nojs="http" >}}://{{< sitevar name="host" nojs="authelia" >}}:{{< sitevar name="port" nojs="9091" >}} and as such:
https:// if Authelia configuration has a TLS key and
certificate defined{{< sitevar name="host" nojs="authelia" >}} in the URL if:
{{< sitevar name="port" nojs="9091" >}} in the URL if:
{{< sitevar name="domain" nojs="example.com" >}} domain:
Traefik utilizes the ForwardAuth Authz implementation. The associated Metadata should be considered required.
The examples below assume you are using the default Authz Endpoints Configuration or one similar to the following minimal configuration:
server:
endpoints:
authz:
forward-auth:
implementation: 'ForwardAuth'
The examples below also assume you are using the modern
Session Configuration which includes the domain, authelia_url, and
default_redirection_url as a subkey of the session.cookies key as a list item. Below is an example of the modern
configuration as well as the legacy configuration for context.
{{< sessionTabs "Generate Random Password" >}} {{< sessionTab "Modern" >}}
session:
cookies:
- domain: '{{</* sitevar name="domain" nojs="example.com" */>}}'
authelia_url: 'https://{{</* sitevar name="subdomain-authelia" nojs="auth" */>}}.{{</* sitevar name="domain" nojs="example.com" */>}}'
default_redirection_url: 'https://www.{{</* sitevar name="domain" nojs="example.com" */>}}'
{{< /sessionTab >}} {{< sessionTab "Legacy" >}}
default_redirection_url: 'https://www.{{</* sitevar name="domain" nojs="example.com" */>}}'
session:
domain: '{{</* sitevar name="domain" nojs="example.com" */>}}'
{{< /sessionTab >}} {{< /sessionTabs >}}
Below you will find commented examples of the following docker deployment:
Authorization header for basic authentication (Heimdall)The below configuration looks to provide examples of running Traefik v1 with labels to protect your endpoint (Nextcloud in this case).
Please ensure that you also setup the respective ACME configuration for your Traefik setup as this is not covered in the example below.
Authelia provides the means to be able to authenticate your first factor via the Proxy-Authorization header.
Given that this is not compatible with Traefik 1.x you can call the Authelia /api/verify endpoint with the
auth=basic query parameter to force a switch to the Authentication header.
networks:
net:
driver: 'bridge'
services:
traefik:
image: 'traefik:v1.7.34-alpine'
container_name: 'traefik'
volumes:
- '/var/run/docker.sock:/var/run/docker.sock'
networks:
net: {}
labels:
traefik.frontend.rule: 'Host:traefik.{{< sitevar name="domain" nojs="example.com" >}}'
traefik.port: '8081'
ports:
- '80:80'
- '443:443'
- '8081:8081'
restart: 'unless-stopped'
command:
- '--api'
- '--api.entrypoint=api'
- '--docker'
- '--defaultEntryPoints=https'
- '--logLevel=DEBUG'
- '--traefikLog=true'
- '--traefikLog.filepath=/var/log/traefik.log'
- '--entryPoints=Name:http Address::80'
- '--entryPoints=Name:https Address::443 TLS'
## See the Forwarded Header Trust section. Comment the above two lines, then uncomment and customize the next two lines to configure the TrustedIPs.
# - '--entryPoints=Name:http Address::80 ForwardedHeaders.TrustedIPs:10.0.0.0/8,172.16.0.0/12,192.168.0.0/16,fc00::/7 ProxyProtocol.TrustedIPs:10.0.0.0/8,172.16.0.0/12,192.168.0.0/16,fc00::/7'
# - '--entryPoints=Name:https Address::443 TLS ForwardedHeaders.TrustedIPs:10.0.0.0/8,172.16.0.0/12,192.168.0.0/16,fc00::/7 ProxyProtocol.TrustedIPs:10.0.0.0/8,172.16.0.0/12,192.168.0.0/16,fc00::/7'
- '--entryPoints=Name:api Address::8081'
authelia:
image: 'authelia/authelia'
container_name: '{{< sitevar name="host" nojs="authelia" >}}'
volumes:
- '/path/to/authelia:/config'
networks:
net: {}
labels:
traefik.frontend.rule: 'Host:{{< sitevar name="subdomain-authelia" nojs="auth" >}}.{{< sitevar name="domain" nojs="example.com" >}}'
restart: 'unless-stopped'
environment:
TZ: 'Australia/Melbourne'
nextcloud:
image: 'linuxserver/nextcloud'
container_name: 'nextcloud'
volumes:
- '/path/to/nextcloud/config:/config'
- '/path/to/nextcloud/data:/data'
networks:
net: {}
labels:
traefik.frontend.rule: 'Host:nextcloud.{{< sitevar name="domain" nojs="example.com" >}}'
traefik.frontend.auth.forward.address: '{{< sitevar name="tls" nojs="http" >}}://{{< sitevar name="host" nojs="authelia" >}}:{{< sitevar name="port" nojs="9091" >}}/api/authz/forward-auth'
## The following commented line is for configuring the Authelia URL in the proxy. We strongly suggest this is
## configured in the Session Cookies section of the Authelia configuration.
# traefik.frontend.auth.forward.address: '{{< sitevar name="tls" nojs="http" >}}://{{< sitevar name="host" nojs="authelia" >}}:{{< sitevar name="port" nojs="9091" >}}/api/authz/forward-auth?authelia_url=https%3A%2F%2F{{< sitevar name="subdomain-authelia" nojs="auth" >}}.{{< sitevar name="domain" nojs="example.com" >}}%2F'
traefik.frontend.auth.forward.trustForwardHeader: 'true'
traefik.frontend.auth.forward.authResponseHeaders: 'Remote-User,Remote-Groups,Remote-Email,Remote-Name'
restart: 'unless-stopped'
environment:
PUID: '1000'
PGID: '1000'
TZ: 'Australia/Melbourne'
heimdall:
image: 'linuxserver/heimdall'
container_name: 'heimdall'
volumes:
- '/path/to/heimdall/config:/config'
networks:
net: {}
labels:
traefik.frontend.rule: 'Host:heimdall.{{< sitevar name="domain" nojs="example.com" >}}'
traefik.frontend.auth.forward.address: '{{< sitevar name="tls" nojs="http" >}}://{{< sitevar name="host" nojs="authelia" >}}:{{< sitevar name="port" nojs="9091" >}}/api/authz/forward-auth/basic'
traefik.frontend.auth.forward.trustForwardHeader: 'true'
traefik.frontend.auth.forward.authResponseHeaders: 'Remote-User,Remote-Groups,Remote-Email,Remote-Name'
restart: 'unless-stopped'
environment:
PUID: '1000'
PGID: '1000'
TZ: 'Australia/Melbourne'