Hello! I’m fairly new to homelabbing, setting up a photo server to share with friends and family. The idea was to use Tailscale for friends and family to access the website via VPN, so if others visit the site, it doesn’t show up. Then, they’d hit an Authentik webpage where they’d log in, and then they’d be redirected to a Homepage.
I set up what I thought would be quite simple, but I feel like I’m only digging myself deeper and deeper in, trying to figure out what’s wrong. I have a single docker-compose.yml:
networks:
library_net:
proxy_net:
services:
#
# AUTHENTIK
#
authentik-outpost:
image: ghcr.io/goauthentik/proxy:latest
container_name: authentik-outpost
env_file:
- /app/environments/authentik.env
depends_on:
- authentik-server
labels:
- "traefik.enable=true"
- "traefik.port=9000"
- "traefik.http.routers.authentik.entrypoints=websecure"
- "traefik.http.routers.authentik.rule=Host(`name-of-domain.xyz`) && PathPrefix(`/outpost.goauthentik.io/`)"
- "traefik.http.routers.authentik.tls=true"
- "traefik.http.routers.authentik.tls.certresolver=le"
- "traefik.http.middlewares.authentik.forwardauth.address=http://authentik-outpost:9000/outpost.goauthentik.io/auth/traefik"
- "traefik.http.middlewares.authentik.forwardauth.trustForwardHeader=true"
- "traefik.http.middlewares.authentik.forwardauth.authResponseHeaders=X-authentik-username,X-authentik-groups,X-authentik-entitlements,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"
networks:
- library_net
- proxy_net
restart: unless-stopped
authentik-postgres:
image: postgres:16-alpine
container_name: authentik-postgres
env_file:
- /app/environments/authentik.env
healthcheck:
test:
- CMD-SHELL
- pg_isready -d $${POSTGRES_DB} -U $${POSTGRES_USER}
interval: 30s
retries: 5
start_period: 20s
timeout: 5s
networks:
- library_net
restart: unless-stopped
volumes:
- /app/services/authentik/postgres:/var/lib/postgresql/data
authentik-redis:
image: redis:7-alpine
container_name: authentik-redis
env_file:
- /app/environments/authentik.env
networks:
- library_net
restart: unless-stopped
volumes:
- /app/services/authentik/redis:/data
authentik-server:
image: ghcr.io/goauthentik/server:latest
container_name: authentik-server
command: server
depends_on:
- authentik-postgres
- authentik-redis
env_file:
- /app/environments/authentik.env
labels:
- "traefik.enable=true"
- "traefik.http.routers.auth.rule=Host(`auth.name-of-domain.xyz`)"
- "traefik.http.routers.auth.entrypoints=websecure"
- "traefik.http.routers.auth.tls=true"
- "traefik.http.routers.auth.tls.certresolver=le"
- "traefik.http.services.auth.loadbalancer.server.port=9000"
networks:
- library_net
- proxy_net
restart: unless-stopped
volumes:
- /app/services/authentik/media:/media
- /app/services/authentik/templates:/templates
authentik-worker:
image: ghcr.io/goauthentik/server:latest
container_name: authentik-worker
command: worker
depends_on:
- authentik-postgres
- authentik-redis
- authentik-server
env_file:
- /app/environments/authentik.env
networks:
- library_net
restart: unless-stopped
volumes:
- /app/services/authentik/media:/media
- /app/services/authentik/templates:/templates
#
# HOMEPAGE
#
homepage:
image: ghcr.io/gethomepage/homepage:latest
container_name: homepage
env_file:
- /app/environments/homepage.env
labels:
- "traefik.enable=true"
- "traefik.http.routers.home.entrypoints=websecure"
- "traefik.http.routers.home.middlewares=authentik-forward"
- "traefik.http.routers.home.rule=Host(`home.name-of-domain.xyz`)"
- "traefik.http.routers.home.tls=true"
- "traefik.http.routers.home.tls.certresolver=le"
- "traefik.http.services.home.loadbalancer.server.port=3000"
networks:
- library_net
- proxy_net
restart: unless-stopped
volumes:
- /app/services/homepage/config:/app/config
- /app/services/homepage/icons:/app/public/icons
#
# TAILSCALE
#
tailscale:
image: tailscale/tailscale:latest
container_name: tailscale
env_file:
- /app/environments/tailscale.env
network_mode: service:traefik
restart: unless-stopped
volumes:
- /app/services/tailscale:/var/run/tailscale
- /app/services/tailscale/state:/var/lib/tailscale
- /app/services/tailscale/run:/var/run/tailscale
- /dev/net/tun:/dev/net/tun
#
# TRAEFIK
#
traefik:
image: traefik:latest
container_name: traefik
ports:
- "80:80"
- "443:443"
command:
- "--accesslog=true"
- "--api.dashboard=true"
- "--certificatesresolvers.le.acme.dnschallenge=true"
- "--certificatesresolvers.le.acme.dnschallenge.delaybeforecheck=0"
- "--certificatesresolvers.le.acme.dnschallenge.provider=namecheap"
- "--certificatesresolvers.le.acme.email=email@gmail.com"
- "--certificatesresolvers.le.acme.storage=/letsencrypt/acme.json"
- "--entrypoints.web.address=:80"
- "--entrypoints.web.http.redirections.entrypoint.scheme=https"
- "--entrypoints.web.http.redirections.entrypoint.to=websecure"
- "--entrypoints.websecure.address=:443"
- "--entrypoints.websecure.asDefault=true"
- "--entrypoints.websecure.http.tls=true"
- "--entrypoints.websecure.http.tls.certresolver=le"
- "--log.level=DEBUG"
- "--providers.docker=true"
- "--providers.docker.exposedbydefault=false"
- "--providers.docker.network=proxy_net"
- "--serversTransport.forwardingTimeouts.dialTimeout=60s"
- "--serversTransport.forwardingTimeouts.idleConnTimeout=300s"
- "--serversTransport.forwardingTimeouts.responseHeaderTimeout=300s"
- "--serversTransport.insecureSkipVerify=true"
env_file:
- /app/environments/traefik.env
labels:
- "traefik.enable=true"
- "traefik.http.middlewares.authentik-forward.forwardauth.address=http://authentik-outpost:9000/outpost.goauthentik.io/auth/traefik"
- "traefik.http.middlewares.authentik-forward.forwardauth.trustForwardHeader=true"
- "traefik.http.middlewares.authentik-forward.forwardauth.authResponseHeaders=X-authentik-username,X-authentik-email,X-authentik-name,X-authentik-groups"
networks:
- proxy_net
restart: unless-stopped
volumes:
- /app/services/tailscale/run:/var/run/tailscale
- /app/services/traefik:/etc/traefik
- /app/services/traefik/letsencrypt:/letsencrypt
- /etc/localtime:/etc/localtime:ro
- /var/run/docker.sock:/var/run/docker.sock:ro
#
# REDIRECT
#
library-redirect:
image: traefik/whoami
container_name: library-redirect
labels:
- "traefik.enable=true"
- "traefik.http.middlewares.redirect-home.redirectregex.permanent=true"
- "traefik.http.middlewares.redirect-home.redirectregex.regex=^https?://name-of-domain.xyz/?$"
- "traefik.http.middlewares.redirect-home.redirectregex.replacement=https://home.name-of-domain.xyz"
- "traefik.http.routers.root.entrypoints=websecure"
- "traefik.http.routers.root.middlewares=redirect-home"
- "traefik.http.routers.root.rule=Host(`name-of-domain.xyz`) && Path(`/`)"
- "traefik.http.routers.root.tls=true"
- "traefik.http.routers.root.tls.certresolver=le"
- "traefik.http.routers.root.tls.domains[0].main=name-of-domain.xyz"
- "traefik.http.services.root.loadbalancer.server.port=80"
networks:
- proxy_net
restart: unless-stopped
So when I go to name-of-domain[.]xyz, it does successfully redirect to home.name-of-domain[.]xyz, but it gives a 500 error. If I go to auth.name-of-domain[.]xyz, it redirects to the right flow for Authentik, being auth.name-of-domain[.]xyz/if/flow/default-authentication-flow/?next=%2F, but it ends up in a gateway timeout. Weirdly, if I remove the redirect logic, the whoami and homepage containers seem to work totally fine, so I’m not exactly sure what’s happening. The logs look relatively clean for Traefik too, so I think it’s just a bad definition or something in my compose file… Regardless, any help would be much, much appreciated! Thanks so much!