Self-Host Authentik with Docker: SSO, MFA, OIDC Apps, and Account Recovery
AuthentikSingle Sign-OnMFAOIDCDockerIdentity Management

Self-Host Authentik with Docker: SSO, MFA, OIDC Apps, and Account Recovery

SSelfhosting.cloud Editorial
2026-11-21
8 min read

Deploy Authentik with Docker for secure self-hosted SSO, MFA, OIDC, SAML, proxy authentication, least privilege, and tested recovery.

Running Authentik with Docker gives a self-hosted identity provider for single sign-on across dashboards, internal tools, and public applications. This guide covers a cautious deployment with PostgreSQL and Redis, persistent storage, HTTPS, MFA, OIDC, SAML, proxy authentication, least-privilege access, and recovery procedures you should test before depending on it.

Overview

Authentik is an identity and access management platform that can sit in front of self-hosted apps and centralize authentication. Instead of maintaining separate passwords and account policies in every application, users authenticate through Authentik and the target app receives a trusted identity through a protocol such as OpenID Connect (OIDC), SAML, or a reverse-proxy header.

The security benefit is not automatic. Authentik becomes a critical dependency: if it is unavailable, protected applications may be inaccessible; if it is misconfigured, users may receive too much access. Treat it like production infrastructure, even in a homelab. Keep it behind HTTPS, restrict administrative access, back up its database and media, monitor its health, and maintain a tested administrator recovery path.

Components and responsibilities

  • Authentik server: serves the web interface, authentication flows, provider endpoints, and API.
  • Authentik worker: handles background jobs and tasks. It should use the same image version and configuration as the server.
  • PostgreSQL: stores configuration, users, applications, flows, policies, and provider data.
  • Redis: provides the service’s cache and task-queue support. Treat it as a dependency rather than disposable application data.
  • Reverse proxy: terminates HTTPS and forwards the correct host and protocol information.

Before deploying, check the Authentik release documentation for the supported PostgreSQL and Redis versions, required environment variables, image names, migration notes, and any changed provider or outpost behavior. Avoid copying an old Compose file unchanged into a new installation.

Checklist by scenario

1. Base Docker deployment

Create a dedicated directory such as /opt/authentik and protect the environment file from other users. The following is a starting template, not a substitute for the release-specific example supplied by Authentik:

services:
  postgresql:
    image: postgres:YOUR_SUPPORTED_VERSION
    restart: unless-stopped
    environment:
      POSTGRES_PASSWORD: change-this-long-random-value
      POSTGRES_USER: authentik
      POSTGRES_DB: authentik
    volumes:
      - ./postgresql:/var/lib/postgresql/data

  redis:
    image: redis:YOUR_SUPPORTED_VERSION
    restart: unless-stopped
    volumes:
      - ./redis:/data

  server:
    image: ghcr.io/goauthentik/server:YOUR_AUTHENTIK_VERSION
    restart: unless-stopped
    command: server
    environment:
      AUTHENTIK_SECRET_KEY: change-this-long-random-value
      AUTHENTIK_REDIS__HOST: redis
      AUTHENTIK_POSTGRESQL__HOST: postgresql
      AUTHENTIK_POSTGRESQL__USER: authentik
      AUTHENTIK_POSTGRESQL__NAME: authentik
      AUTHENTIK_POSTGRESQL__PASSWORD: change-this-long-random-value
    ports:
      - "9000:9000"
      - "9443:9443"
    volumes:
      - ./media:/media
      - ./custom-templates:/templates

  worker:
    image: ghcr.io/goauthentik/server:YOUR_AUTHENTIK_VERSION
    restart: unless-stopped
    command: worker
    environment:
      AUTHENTIK_SECRET_KEY: change-this-long-random-value
      AUTHENTIK_REDIS__HOST: redis
      AUTHENTIK_POSTGRESQL__HOST: postgresql
      AUTHENTIK_POSTGRESQL__USER: authentik
      AUTHENTIK_POSTGRESQL__NAME: authentik
      AUTHENTIK_POSTGRESQL__PASSWORD: change-this-long-random-value
    volumes:
      - ./media:/media
      - ./certs:/certs
      - ./custom-templates:/templates

Use the exact service definition and variables from the Authentik documentation for the release you install. Pin a tested version rather than relying on an unreviewed floating tag. Keep PostgreSQL, Redis, server, and worker on a private Docker network unless a documented integration requires otherwise. Do not expose PostgreSQL or Redis directly to the internet.

Start the stack with docker compose up -d, then inspect docker compose logs -f server worker. Complete the initial administrator setup through the official bootstrap or setup path for your release. Use a unique administrator password and enroll a second recovery method before onboarding other users.

2. HTTPS and reverse proxy

Publish Authentik at a stable hostname such as auth.example.net. Terminate HTTPS at a maintained reverse proxy, forward the original host and scheme, and configure the proxy’s WebSocket and request-size behavior according to Authentik’s documentation. Traefik and Nginx Proxy Manager can both work, but the important controls are equivalent: valid certificates, correct forwarding headers, no accidental HTTP-only login path, and restricted access to the admin interface where practical.

For a comparison of operational trade-offs, see Traefik vs Nginx Proxy Manager for self-hosting. If you use a tunnel instead of inbound port forwarding, confirm that the tunnel preserves HTTPS and host information as Authentik expects.

3. Add an application with OIDC

OIDC is usually the simplest choice for a modern web application that supports it.

  1. Create a group such as app-project-readers and add only the intended users.
  2. Create an Authentik application with a clear name and slug.
  3. Create an OAuth2/OIDC provider and associate it with the application.
  4. Set the client type carefully. A confidential server-side application can keep a client secret; a public client cannot safely do so.
  5. Enter the exact redirect URI required by the application. Match scheme, hostname, path, port, and trailing slash.
  6. Use the provider’s issuer and discovery URL when the application supports OIDC discovery.
  7. Map claims such as username, email, groups, or name only when the target application needs them.
  8. Attach an authorization policy or group restriction before testing with a normal user.

4. Choose the right provider

ProviderUse it whenDouble-check
OIDCThe application supports modern OAuth 2.0 and OpenID Connect.Issuer URL, redirect URI, scopes, claims, client type, and secret rotation.
SAMLThe application is designed for enterprise SAML federation.Entity ID, ACS URL, certificate, name-ID format, and signed assertions.
Proxy providerThe application lacks native OIDC or SAML and can trust an upstream proxy.Outpost routing, forwarded identity headers, trusted proxy boundaries, and logout behavior.

5. MFA and access policies

Require MFA for administrators first, then apply it to users or sensitive applications through flows and policies. Prefer phishing-resistant methods when your environment and Authentik version support them; otherwise, use an appropriate second factor and require recovery enrollment. Keep a separate break-glass administrator account protected by a long, stored credential and a documented recovery process. Do not use the break-glass account for daily work.

Least privilege should be visible in the configuration. For example, allow the monitoring-users group to access a monitoring dashboard, allow admins to manage it, and deny everyone else. Avoid a single global policy that grants every authenticated user access to every provider.

6. SAML, proxy, and mixed environments

For SAML, copy values exactly from the consuming application and decide which side owns certificate rotation. For proxy providers, deploy and secure the required outpost, route only the intended hostnames, and verify that the upstream application cannot be reached directly to bypass authentication. Test logout, denied users, group changes, and direct-origin access from both an internal and external network.

What to double-check

  • Secrets: generate unique database credentials and an Authentik secret key; do not commit them to a public repository. Rotate client secrets through a planned overlap window where the application permits it.
  • Data protection: back up PostgreSQL, Authentik media, custom templates, certificates or key material, and the Compose configuration. A backup that excludes the database cannot restore identity configuration. Follow a tested Docker backup strategy and perform an actual restore.
  • Updates: read release notes, back up first, update server and worker together, watch migrations, and test one non-critical application before changing all providers. Renovate can help propose image updates, but review and rollback controls still matter.
  • Claims and groups: send only required claims. Group claims can expose organizational information and may behave differently across applications.
  • Time and DNS: incorrect system clocks can break token validation and certificates. Confirm DNS, certificate coverage, and consistent time on the host and dependent systems.
  • Recovery: test a lost MFA device, a forgotten administrator password, database restoration, and reverse-proxy failure. Record the procedure offline and restrict access to recovery material.

App-onboarding checklist

  1. Confirm the application supports OIDC, SAML, or proxy authentication.
  2. Document its expected issuer, redirect, logout, ACS, or header values.
  3. Create a dedicated provider and application rather than reusing credentials casually.
  4. Restrict access with a group or policy.
  5. Test allowed, denied, expired-session, logout, and group-removal cases.
  6. Record the owner, provider type, redirect URIs, scopes, and secret-rotation date.

Common mistakes

Redirect URI errors

“Invalid redirect URI” normally means the registered value does not exactly match the request. Check HTTP versus HTTPS, the public hostname rather than the container hostname, path spelling, port, and trailing slash. Do not solve the problem by adding a broad wildcard unless the application and threat model justify it.

Invalid tokens

Compare the token issuer with the application’s configured issuer, confirm the audience and signing algorithm, check system time, and verify that the application is using the intended tenant or provider. If a secret was rotated, update the application deliberately and invalidate old credentials when safe.

Proxy authentication failures

Check that the outpost is healthy, its route matches the public hostname, and the reverse proxy forwards the expected headers. Confirm the upstream application is not publicly reachable around the proxy. Review Authentik, outpost, reverse-proxy, and application logs together; a successful login at Authentik does not prove that the upstream accepted the identity headers.

Locked-out administrators

Stop repeated guesses. Use the documented recovery or bootstrap procedure for the installed release, preferably from a controlled local session. Restore the database only when necessary and only after preserving the current data. Once access is recovered, enroll a second administrator, review MFA devices and sessions, rotate exposed credentials, and document what failed.

When to revisit

Revisit this deployment before onboarding a high-value application, after changing a hostname or reverse proxy, when redirect URIs or group structures change, and whenever a client secret, signing certificate, MFA device, or administrator changes. Schedule periodic checks for backups, restore tests, inactive accounts, excessive group access, exposed services, and recovery documentation.

Also review the stack after Authentik, PostgreSQL, Redis, Docker, or reverse-proxy upgrades; after security advisories; and before a planned maintenance cycle. Read the current release notes instead of assuming that an older Compose file, environment variable, provider workflow, or outpost configuration remains valid.

A practical maintenance runbook is: back up the database and media, record the current image versions, read release notes, update in a test window, inspect migrations and logs, test administrator login and MFA, test one OIDC and one proxy-protected application, verify denied access, and confirm rollback or recovery steps. Authentik can provide a strong foundation for a self-hosted identity layer, but its reliability depends on disciplined backups, narrow policies, secure proxying, and recovery tests that work before an emergency occurs.

Related Topics

#Authentik#Single Sign-On#MFA#OIDC#Docker#Identity Management
S

Selfhosting.cloud Editorial

Senior SEO Editor

Senior editor and content strategist. Writing about technology, design, and the future of digital media. Follow along for deep dives into the industry's moving parts.