Hello everyone, I recently discovered Traefik and I managed to spin it up and basically all of my services are proxied behind it. Then I wanted to implement authentik with it. I have been trying for the last two days to no avail. I keep getting 404 page not found or bad gateway error 502 when i try to go to my hostname (auth.mydomain.com) but I can connect via ip:port to the authentik page.
Since my other services work with traefik, I believe that my traefik and config yml files are working, so I am a bit confused
What I did was get the docker-compose.yml file from authentik, and created a docker-compose.override.yml for ease of updates.
Below are my yaml files:
#docker-compose.override.yml for authentik
services:
postgresql:
container_name: authentik-db
environment:
TZ: America/Toronto
networks:
- backend
volumes:
- ./postgres/database:/var/lib/postgresql/data
redis:
container_name: authentik-redis
environment:
TZ: America/Toronto
networks:
- backend
volumes:
- ./redis/redis:/data
server:
container_name: authentik-server
networks:
- backend
- frontend
environment:
TZ: America/Toronto
AUTHENTIK_DISABLE_STARTUP_ANALYTICS: true
AUTHENTIK_DISABLE_UPDATE_CHECK: false
AUTHENTIK_ERROR_REPORTING__ENABLED: true
# AUTHENTIK_ALLOWED_HOSTS: auth.mydomain.com
ports:
- 9000:9000
- 9447:9443
labels:
- "traefik.enable=true"
- "traefik.http.routers.authentik.entrypoints=web_internal"
- "traefik.http.routers.authentik.rule=Host(`auth.mydomain.com`)"
- "traefik.http.routers.authentik-secure.entrypoints=websecure_internal"
- "traefik.http.routers.authentik-secure.rule=Host(`auth.mydomain.com`)"
- "traefik.http.routers.authentik-secure.tls=true"
- "traefik.http.routers.authentik-secure.tls.certresolver=cloudflare"
- "traefik.http.routers.authentik-secure.rule=HostRegexp(`{subdomain:[a-z0-9-]+}.mydomain.com`) && PathPrefix(`/outpost.goauthentik.io/`)"
- "traefik.http.services.authentik.loadbalancer.server.port=9000"
- "traefik.docker.network=frontend"
worker:
container_name: authentik-worker
networks:
- backend
environment:
TZ: America/Toronto
networks:
frontend:
external: true
backend:
external: true
#my config.yml file for traefik
http:
middlewares:
crowdsec-bouncer:
forwardauth:
address: http://bouncer-traefik:8080/api/v1/forwardAuth
trustForwardHeader: true
ip-allowlist:
ipAllowList:
sourceRange:
# Cloudflare (https://www.cloudflare.com/ips-v4)
- "173.245.48.0/20"
- "103.21.244.0/22"
- "103.22.200.0/22"
- "103.31.4.0/22"
- "141.101.64.0/18"
- "108.162.192.0/18"
- "190.93.240.0/20"
- "188.114.96.0/20"
- "197.234.240.0/22"
- "198.41.128.0/17"
- "162.158.0.0/15"
- "104.16.0.0/13"
- "104.24.0.0/14"
- "172.64.0.0/13"
- "131.0.72.0/22"
# Local IPs
- "172.0.0.0/8"
- "10.0.0.0/24"
- "192.168.0.0/16"
https-redirectscheme:
redirectScheme:
scheme: https
permanent: true
security-headers:
headers:
customResponseHeaders:
X-Robots-Tag: "noindex,nofollow,none,noarchive,nosnippet,notranslate,noimageindex"
server: ""
X-Forwarded-Proto: "https"
sslProxyHeaders:
X-Forwarded-Proto: https
referrerPolicy: "strict-origin-when-cross-origin"
hostsProxyHeaders:
- "X-Forwarded-Host"
- "X-Forwarded-Server"
customRequestHeaders:
X-Forwarded-Proto: "https"
Connection: Upgrade
Upgrade: websocket
contentTypeNosniff: true
browserXssFilter: true
forceSTSHeader: true
stsIncludeSubdomains: true
stsSeconds: 63072000
stsPreload: true
frameDeny: true
auth:
forwardauth:
address: http://authentik-server:9000/outpost.goauthentik.io/auth/traefik
trustForwardHeader: true
authResponseHeaders:
- X-authentik-username
- X-authentik-groups
- X-authentik-email
- X-authentik-name
- X-authentik-uid
- X-authentik-jwt
- X-authentik-meta-jwks
- X-authentik-meta-outpost
- X-authentik-meta-provider
- X-authentik-meta-app
- X-authentik-meta-version
secured:
chain:
middlewares:
- crowdsec-bouncer
- ip-whitelist
- security-headers
- auth
and finally
#my traefik.yaml
global:
checkNewVersion: false
sendAnonymousUsage: false
# --> (Optional) Change log level and format here ...
# - level: [TRACE, DEBUG, INFO, WARN, ERROR, FATAL]
log:
level: INFO
filePath: "/var/log/traefik/traefik.log"
accessLog:
filePath: "var/log/traefik/access.log"
# --> (Optional) Enable API and Dashboard here, don't do in production
api:
dashboard: true
insecure: true
# -- Change EntryPoints here...
entryPoints:
web_internal:
address: ":80"
http:
middlewares:
- crowdsec-bouncer@file
- ip-allowlist@file
- security-headers@file
- https-redirectscheme@file
websecure_internal:
address: ":443"
http:
middlewares:
- crowdsec-bouncer@file
- ip-allowlist@file
- security-headers@file
# -- Configure your CertificateResolver here...
certificatesResolvers:
cloudflare:
acme:
email: myemail@email.com # <-- Change this to your email
storage: /var/traefik/certs/cloudflare-acme.json
caServer: "https://acme-v02.api.letsencrypt.org/directory"
dnsChallenge:
provider: cloudflare # <-- (Optional) Change this to your DNS provider
resolvers:
- "1.1.1.1:53"
- "8.8.8.8:53"
# --> (Optional) Disable TLS Cert verification check
serversTransport:
insecureSkipVerify: true
# <--
providers:
docker:
endpoint: "unix:///var/run/docker.sock"
exposedByDefault: false
file:
filename: /config.yml
Does anyone have any suggestions on how to get this working? I have the traefik dashboard enabled and I don't see any errors for authentik/authentik-secure routers.