services: authentik_postgresql: environment: POSTGRES_DB: ${PG_DB:-authentik} POSTGRES_PASSWORD: ${PG_PASS:?database password required} POSTGRES_USER: ${PG_USER:-authentik} healthcheck: interval: 30s retries: 5 start_period: 20s test: - CMD-SHELL - pg_isready -d $${POSTGRES_DB} -U $${POSTGRES_USER} timeout: 5s image: docker.io/library/postgres:16-alpine restart: unless-stopped volumes: - database:/var/lib/postgresql/data authentik_server: command: server depends_on: authentik_postgresql: condition: service_healthy environment: AUTHENTIK_POSTGRESQL__HOST: authentik_postgresql AUTHENTIK_POSTGRESQL__NAME: ${PG_DB:-authentik} AUTHENTIK_POSTGRESQL__PASSWORD: ${PG_PASS} AUTHENTIK_POSTGRESQL__USER: ${PG_USER:-authentik} AUTHENTIK_SECRET_KEY: ${AUTHENTIK_SECRET_KEY:?secret key required} image: ${AUTHENTIK_IMAGE:-ghcr.io/goauthentik/server}:${AUTHENTIK_TAG:-2025.10.0} restart: unless-stopped volumes: - ./media:/media - ./custom-templates:/templates networks: coolify: aliases: - auth-core array: aliases: - auth-core labels: # 1. Define the Middleware (Forces HTTPS protocol header) - "traefik.http.middlewares.authentik-force-https.headers.customrequestheaders.X-Forwarded-Proto=https" # 2. Attach it to Coolify's generated Router # (Note: We usually append 'gzip' as Coolify adds it by default, ensuring we don't remove it) - "traefik.http.routers.https-0-j88cw4skoowsccs4oc44g0wg-authentik_server.middlewares=gzip,authentik-force-https" authentik_worker: command: worker depends_on: authentik_postgresql: condition: service_healthy environment: AUTHENTIK_POSTGRESQL__HOST: authentik_postgresql AUTHENTIK_POSTGRESQL__NAME: ${PG_DB:-authentik} AUTHENTIK_POSTGRESQL__PASSWORD: ${PG_PASS} AUTHENTIK_POSTGRESQL__USER: ${PG_USER:-authentik} AUTHENTIK_SECRET_KEY: ${AUTHENTIK_SECRET_KEY:?secret key required} image: ${AUTHENTIK_IMAGE:-ghcr.io/goauthentik/server}:${AUTHENTIK_TAG:-2025.10.0} restart: unless-stopped user: root volumes: - /var/run/docker.sock:/var/run/docker.sock - ./media:/media - ./certs:/certs - ./custom-templates:/templates volumes: database: driver: local networks: coolify: external: true array: external: true