IDP/Authentik

authentik is an open-source identity provider. It does single sign-on with OIDC, SAML, LDAP and proxy authentication, MFA with WebAuthn and TOTP, and it pulls users and groups from Active Directory. Once every application logs in through it, it’s the most important service you run. If it’s down, nobody can log in anywhere.

So this guide builds it to survive the loss of any single machine: three nodes, each running authentik in Docker, with HAProxy and keepalived on every node for a floating virtual IP. The database is your existing Patroni PostgreSQL cluster, and shared files live on your existing HA NFS server. On top of that come Active Directory integration (user and group sync, AD passwords, Kerberos single sign-on) and federation to your applications.

What you’ll end up with:

  • authentik 2026.8 on three Debian 13 nodes, server and worker on each, with no Redis. Since 2025.10, authentik keeps everything in PostgreSQL.
  • One virtual IP (auth.mydomain.local) that keepalived moves to a healthy node in seconds
  • HAProxy on every node, terminating TLS, balancing across all three authentik nodes with certificate verification, and routing database connections to the current Patroni leader
  • Secrets in files, never in the compose file; containers with no Docker socket, no capabilities and no new privileges
  • Shared media (icons, backgrounds, custom templates, blueprints) on the NFS server, mounted on every node
  • Active Directory: LDAPS user and group sync with nested groups, login with AD passwords, enforced MFA, and Kerberos SPNEGO for passwordless login from domain-joined machines
  • Federation: OIDC for Grafana as a worked example, and the pattern for SAML applications
  • Monitoring, failover tests, backups and a rolling procedure for upgrades

Tested on: Debian 13 “trixie”, Docker Engine from Docker’s repository, HAProxy 3.0 and keepalived 2.3 from Debian, authentik 2026.8. PostgreSQL 17 under Patroni as in my PostgreSQL HA with Patroni and etcd on Debian 13 guide. All commands run as root unless noted.


Table of contents

  1. Architecture
  2. Placeholders
  3. Prerequisites
  4. Prepare the database on Patroni
  5. Base setup on every node
  6. Shared storage on NFS
  7. Firewall
  8. HAProxy
  9. keepalived
  10. authentik: secrets, configuration and compose file
  11. First start and initial setup
  12. End-to-end TLS between HAProxy and authentik
  13. Active Directory: LDAP source
  14. Logging in with AD passwords and enforced MFA
  15. Kerberos single sign-on (SPNEGO)
  16. Federation: connecting applications
  17. Monitoring
  18. Testing failover
  19. Backup and recovery
  20. Upgrades
  21. Troubleshooting
  22. Checklist

1. Architecture

                         users, applications
                                  โ”‚  HTTPS
                                  โ–ผ
                     VIP 10.20.0.50  auth.mydomain.local
                     (keepalived: on one node at a time)
         โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
         โ–ผ                        โ–ผ                        โ–ผ
 โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”        โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”        โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
 โ”‚ auth-01       โ”‚        โ”‚ auth-02       โ”‚        โ”‚ auth-03       โ”‚
 โ”‚ keepalived    โ”‚โ—„โ”€VRRPโ”€โ–บโ”‚ keepalived    โ”‚โ—„โ”€VRRPโ”€โ–บโ”‚ keepalived    โ”‚
 โ”‚ HAProxy :443  โ”‚        โ”‚ HAProxy :443  โ”‚        โ”‚ HAProxy :443  โ”‚
 โ”‚   โ”‚ TLS, verified, to all three nodes :9443                    โ”‚
 โ”‚   โ–ผ           โ”‚        โ”‚               โ”‚        โ”‚               โ”‚
 โ”‚ authentik     โ”‚        โ”‚ authentik     โ”‚        โ”‚ authentik     โ”‚
 โ”‚ server+worker โ”‚        โ”‚ server+worker โ”‚        โ”‚ server+worker โ”‚
 โ”‚   โ”‚ 127.0.0.1:5432 (HAProxy โ†’ Patroni leader)   โ”‚               โ”‚
 โ””โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜        โ””โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜        โ””โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
     โ”‚ NFS                    โ”‚                        โ”‚
     โ–ผ                        โ–ผ                        โ–ผ
 nas.mydomain.local:/export/authentik  โ†’  /srv/authentik/shared on each node
 pg-01 / pg-02 / pg-03 (Patroni, TLS)  โ†  REST API :8008 decides the leader
 dc01 / dc02 (Active Directory)        โ†  LDAPS :636, Kerberos :88Code language: JavaScript (javascript)
ComponentRoleWhy it’s here
authentik serverWeb UI, API, flows, OIDC/SAML endpoints, embedded outpostStateless: any node can serve any request
authentik workerBackground tasks: LDAP sync, emails, certificate discovery, cleanupTasks run from a queue in PostgreSQL; several workers share it
PostgreSQL (Patroni)All state: configuration, users, sessions, task queue, cacheThe only stateful part; Patroni makes it HA
HAProxyTLS termination, load balancing, health checks, Patroni leader routingOn every node, so the node that holds the VIP can serve on its own
keepalivedMoves the VIP to a node whose HAProxy is healthyRemoves the single load balancer as a point of failure
NFS/data (media: icons, backgrounds), custom templates, blueprintsEvery node must see the same uploaded files

Why it all works: authentik’s server and worker are stateless. All session state and configuration is in the database. There’s no session stickiness to worry about, and losing a node only loses the requests that were in flight on it.


2. Placeholders

PlaceholderMeaning
auth.mydomain.local / 10.20.0.50The VIP and the name users and applications use
auth-01, auth-02, auth-03 / 10.20.0.51โ€“.53The three authentik nodes, interface ens192
pg-01, pg-02, pg-03 / 10.20.0.41โ€“.43The Patroni nodes (PostgreSQL 5432, REST API 8008)
nas.mydomain.local:/export/authentikThe NFS export for authentik’s shared files
dc01, dc02.mydomain.localDomain controllers; AD domain mydomain.local, Kerberos realm MYDOMAIN.LOCAL
DC=mydomain,DC=localAD base DN
10.20.90.0/24Admin network (SSH)
10.20.0.112Prometheus
mydomain-ca.pemYour internal CA (root plus intermediate)
pg-ca.crtThe CA that signed the Patroni node certificates

3. Prerequisites

These must exist before you start. Each is a guide of its own, and this one doesn’t build them.

PostgreSQL with Patroni. A three-node Patroni cluster, PostgreSQL 14 to 18 (authentik’s supported range), with TLS enabled. authentik requires TLS 1.3 or the Extended Master Secret extension for its database connections, which any current PostgreSQL on Debian 13 meets. The Patroni REST API on port 8008 must be reachable from the three authentik nodes, because HAProxy uses it to find the leader.

A highly available NFS server. nas.mydomain.local must fail over on its own (a NAS cluster, or Pacemaker with DRBD). authentik writes uploaded icons and backgrounds there and reads templates and blueprints from it. With the export from section 6.

Active Directory. Two or more domain controllers with LDAPS (port 636) and a certificate from your CA. Windows Server 2025 requires LDAP signing by default, which LDAPS takes care of.

DNS.

NameTypePoints to
auth.mydomain.localA10.20.0.50 (VIP)
auth-01, -02, -03.mydomain.localA + PTRNode addresses

A certificate for auth.mydomain.local from your CA, with the name in its SAN, plus the key. The same certificate is used on all three nodes. For how to issue one, see my Certificate management with OpenSSL on Debian 13 guide.

Three Debian 13 VMs, 2 vCPU and 4 GB RAM each as a minimum, hardened as in my Debian 13 VM hardening guide, but with the forwarding sysctls adjusted for Docker (section 5). Put them on three different hypervisor hosts, with a DRS anti-affinity rule, or the cluster dies with one host.

A note on .local: it’s reserved for multicast DNS. Linux clients with nss-mdns and macOS may try mDNS first and resolve slowly. Many AD domains use it anyway. If yours is new, choose a subdomain of a domain you own instead.


4. Prepare the database on Patroni

On the Patroni leader (patronictl list shows which), as the postgres user:

sudo -u postgres psql
CREATE ROLE authentik LOGIN PASSWORD 'use-a-long-random-password-here';
CREATE DATABASE authentik OWNER authentik ENCODING 'UTF8' TEMPLATE template0;
REVOKE ALL ON DATABASE authentik FROM PUBLIC;
\c authentik
REVOKE CREATE ON SCHEMA public FROM PUBLIC;
GRANT ALL ON SCHEMA public TO authentik;Code language: PHP (php)

Generate the password with openssl rand -base64 36. You’ll put it into a file on the authentik nodes in section 10.

Allow the three nodes, TLS only, in the Patroni configuration, which writes pg_hba.conf on every member:

patronictl -c /etc/patroni/config.yml edit-config
postgresql:
  pg_hba:
    # ... your existing entries ...
    - hostssl authentik authentik 10.20.0.51/32 scram-sha-256
    - hostssl authentik authentik 10.20.0.52/32 scram-sha-256
    - hostssl authentik authentik 10.20.0.53/32 scram-sha-256Code language: PHP (php)

Connections. Since authentik moved its cache, task queue and websockets into PostgreSQL, it uses roughly 50% more database connections than older versions. Budget per node for the server’s web workers, the worker’s processes and threads, and the embedded outpost, and check the real number under load:

SELECT client_addr, count(*) FROM pg_stat_activity WHERE datname = 'authentik' GROUP BY 1;Code language: JavaScript (javascript)

Set max_connections in the Patroni DCS configuration with plenty of room. For three nodes, start at 300 and adjust after a week of real numbers.

Also open the Patroni REST API (8008) and PostgreSQL (5432) for 10.20.0.51โ€“.53 in the database nodes’ firewall. In my Patroni guide, that means adding them to the clients_v4 set.


5. Base setup on every node

Run sections 5 to 10 on all three nodes. Only the parts marked “per node” differ.

Docker Engine from Docker’s own repository, as in my other Docker guides:

apt install ca-certificates curl
install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc
cat > /etc/apt/sources.list.d/docker.sources <<'EOF'
Types: deb
URIs: https://download.docker.com/linux/debian
Suites: trixie
Components: stable
Signed-By: /etc/apt/keyrings/docker.asc
EOF
apt update
apt install docker-ce docker-ce-cli containerd.io docker-compose-pluginCode language: JavaScript (javascript)

/etc/docker/daemon.json:

{
  "log-driver": "journald",
  "live-restore": true,
  "ip": "127.0.0.1"
}Code language: JSON / JSON with Comments (json)
  • journald: container logs end up in the journal, with rotation and forwarding you already have.
  • live-restore: a Docker daemon restart or upgrade doesn’t restart the containers.
  • "ip": "127.0.0.1": any port someone publishes later listens on localhost only. authentik itself uses host networking (section 10).

The other packages:

apt install haproxy keepalived nfs-common nftables curl jq
systemctl restart docker

Sysctls in /etc/sysctl.d/60-authentik-ha.conf:

# HAProxy may bind the VIP even while another node holds it
net.ipv4.ip_nonlocal_bind = 1Code language: PHP (php)
sysctl --system

If you applied my hardening guide, remove net.ipv4.ip_forward = 0 there. Docker needs forwarding, and the firewall’s forward chain is what stops the node from routing.


6. Shared storage on NFS

On the NAS (prerequisite). One export with three directories, owned by the user authentik runs as inside the container, UID and GID 1000:

/export/authentik/
โ”œโ”€โ”€ data/          # authentik /data: uploaded icons, backgrounds, reports
โ”œโ”€โ”€ templates/     # custom email and page templates
โ””โ”€โ”€ blueprints/    # your own blueprints (configuration as code)Code language: PHP (php)
# /etc/exports on the NAS, or the equivalent in its UI
/export/authentik 10.20.0.51(rw,sync,root_squash,no_subtree_check,sec=sys) 10.20.0.52(rw,sync,root_squash,no_subtree_check,sec=sys) 10.20.0.53(rw,sync,root_squash,no_subtree_check,sec=sys)Code language: PHP (php)
# on the NAS
install -d -o 1000 -g 1000 -m 0750 /export/authentik/data /export/authentik/templates /export/authentik/blueprintsCode language: PHP (php)

Check the UID of the authentik image before you rely on it:

docker run --rm --entrypoint id ghcr.io/goauthentik/server:2026.8.6

On every node, mount it:

install -d -m 0755 /srv/authentik/shared
cat >> /etc/fstab <<'EOF'
nas.mydomain.local:/export/authentik  /srv/authentik/shared  nfs4  vers=4.2,proto=tcp,hard,timeo=600,retrans=2,noatime,nosuid,nodev,noexec,_netdev  0  0
EOF
systemctl daemon-reload
mount /srv/authentik/shared
ls -ln /srv/authentik/sharedCode language: JavaScript (javascript)
  • hard: if the NAS fails over, file access waits and then continues. A soft mount would return errors, and authentik could save a broken file.
  • nosuid,nodev,noexec: nothing on the share is ever executed.
  • sec=sys trusts the client’s UID, so keep NFS on a network that only the nodes and the NAS can reach. With Kerberos on the NAS, sec=krb5p also encrypts the traffic.

Docker must not start before the share is mounted. Otherwise the containers start on an empty local directory, and uploads end up on one node only:

mkdir -p /etc/systemd/system/docker.service.d
cat > /etc/systemd/system/docker.service.d/authentik-nfs.conf <<'EOF'
[Unit]
RequiresMountsFor=/srv/authentik/shared
EOF
systemctl daemon-reloadCode language: JavaScript (javascript)

The consequence: if the NAS is unreachable at boot, Docker doesn’t start on that node, and the other two carry the load. That’s what you want: a node with missing files is worse than a node that’s missing.


7. Firewall

/etc/nftables.conf on each node, in the style of my nftables on Debian 13 guide. It replaces only its own table, so Docker’s rules stay. The only per-node line is SELF:

#!/usr/sbin/nft -f
# /etc/nftables.conf - authentik HA node

define SELF = 10.20.0.51            # per node: .51, .52, .53

destroy table inet filter

table inet filter {

    set auth_nodes {
        type ipv4_addr
        elements = { 10.20.0.51, 10.20.0.52, 10.20.0.53 }
    }
    set admin_v4 {
        type ipv4_addr
        flags interval
        elements = { 10.20.90.0/24 }
    }
    set monitor_v4 {
        type ipv4_addr
        elements = { 10.20.0.112 }
    }

    chain input {
        type filter hook input priority filter; policy drop;

        ct state vmap { established : accept, related : accept, invalid : drop }
        iifname "lo" accept

        # ICMP: errors and rate-limited ping; ICMPv6 essentials
        icmp type { destination-unreachable, time-exceeded, parameter-problem } accept
        icmp type echo-request limit rate 10/second accept
        icmpv6 type { destination-unreachable, packet-too-big, time-exceeded, parameter-problem } accept
        icmpv6 type { nd-router-advert, nd-neighbor-solicit, nd-neighbor-advert } ip6 hoplimit 255 accept

        # users and applications: HTTPS on the VIP (and the HTTP redirect)
        tcp dport { 80, 443 } accept

        # HAProxy on the other nodes -> authentik on this node
        tcp dport 9443 ip saddr @auth_nodes accept

        # keepalived: unicast VRRP from the other nodes to this node
        ip protocol 112 ip saddr @auth_nodes ip daddr $SELF accept

        # Prometheus: authentik server, worker, HAProxy exporter
        tcp dport { 9300, 9301, 8405 } ip saddr @monitor_v4 accept

        # SSH from the admin network
        tcp dport 22 ip saddr @admin_v4 ct state new accept

        limit rate 10/minute burst 20 packets log prefix "nft input drop: " level info
    }

    chain forward {
        type filter hook forward priority filter; policy drop;
    }

    chain output {
        type filter hook output priority filter; policy accept;
    }
}Code language: PHP (php)
nft -c -f /etc/nftables.conf && systemctl enable --now nftables && systemctl reload nftables

Port 9000 (authentik’s plain HTTP) isn’t open at all: authentik’s server listens on it only on 127.0.0.1 (section 10). The forward chain can stay a pure drop, because authentik runs with host networking and nothing is forwarded.


8. HAProxy

Install the certificate and the CAs on every node. HAProxy wants the certificate chain and the key in one PEM file:

install -d -m 0750 -o root -g haproxy /etc/haproxy/certs /etc/haproxy/ca
cat auth.mydomain.local.crt intermediate-ca.pem auth.mydomain.local.key > /etc/haproxy/certs/auth.mydomain.local.pem
chmod 0640 /etc/haproxy/certs/auth.mydomain.local.pem
chgrp haproxy /etc/haproxy/certs/auth.mydomain.local.pem
install -m 0644 mydomain-ca.pem /etc/haproxy/ca/mydomain-ca.pem
install -m 0644 pg-ca.crt       /etc/haproxy/ca/pg-ca.crtCode language: JavaScript (javascript)

/etc/haproxy/haproxy.cfg. The only per-node line is the bind of the metrics frontend:

global
    log /dev/log local0
    chroot /var/lib/haproxy
    stats socket /run/haproxy/admin.sock mode 660 level admin
    user haproxy
    group haproxy
    daemon

    # TLS towards clients: TLS 1.2+ with forward secrecy only, no session tickets
    ssl-default-bind-ciphersuites TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256
    ssl-default-bind-ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305
    ssl-default-bind-options ssl-min-ver TLSv1.2 no-tls-tickets
    # TLS towards the authentik nodes
    ssl-default-server-options ssl-min-ver TLSv1.2

defaults
    mode http
    log global
    option httplog
    option dontlognull
    timeout connect 5s
    timeout client 60s
    timeout server 60s
    timeout http-request 10s
    timeout http-keep-alive 10s
    timeout tunnel 1h              # authentik uses websockets

# ---------- users and applications ----------

frontend fe_http
    bind 10.20.0.50:80
    http-request redirect scheme https code 301

frontend fe_https
    bind 10.20.0.50:443 ssl crt /etc/haproxy/certs/auth.mydomain.local.pem alpn h2,http/1.1
    # never pass on what the client claims; authentik trusts this header from us
    http-request set-header X-Forwarded-For %[src]
    http-request set-header X-Forwarded-Proto https
    http-response set-header Strict-Transport-Security "max-age=63072000"
    default_backend be_authentik

backend be_authentik
    balance leastconn
    option httpchk
    http-check send meth GET uri /-/health/ready/ hdr Host auth.mydomain.local
    http-check expect status 200
    # Until section 12 is done, use "ssl verify none" here instead.
    default-server ssl verify required ca-file /etc/haproxy/ca/mydomain-ca.pem sni str(auth.mydomain.local) verifyhost auth.mydomain.local alpn http/1.1 check inter 3s fall 3 rise 2
    server auth-01 10.20.0.51:9443
    server auth-02 10.20.0.52:9443
    server auth-03 10.20.0.53:9443

# ---------- health for keepalived, metrics for Prometheus ----------

frontend fe_health
    bind 127.0.0.1:8404
    monitor-uri /healthz
    monitor fail if { nbsrv(be_authentik) lt 1 }

frontend fe_metrics
    bind 10.20.0.51:8405           # per node
    http-request use-service prometheus-exporter if { path /metrics }
    no log

# ---------- PostgreSQL: always the current Patroni leader ----------

listen pg_rw
    bind 127.0.0.1:5432
    mode tcp
    option tcplog
    timeout client 30m
    timeout server 30m
    option httpchk
    http-check send meth GET uri /primary
    http-check expect status 200
    default-server check port 8008 check-ssl verify required ca-file /etc/haproxy/ca/pg-ca.crt inter 3s fall 3 rise 2 on-marked-down shutdown-sessions
    server pg-01 10.20.0.41:5432
    server pg-02 10.20.0.42:5432
    server pg-03 10.20.0.43:5432

# Optional: read-only connections to a replica (see section 10)
listen pg_ro
    bind 127.0.0.1:5433
    mode tcp
    option tcplog
    timeout client 30m
    timeout server 30m
    balance leastconn
    option httpchk
    http-check send meth GET uri /replica
    http-check expect status 200
    default-server check port 8008 check-ssl verify required ca-file /etc/haproxy/ca/pg-ca.crt inter 3s fall 3 rise 2 on-marked-down shutdown-sessions
    server pg-01 10.20.0.41:5432
    server pg-02 10.20.0.42:5432
    server pg-03 10.20.0.43:5432Code language: PHP (php)
haproxy -c -f /etc/haproxy/haproxy.cfg && systemctl enable --now haproxy && systemctl reload haproxy

How the pieces work:

  • Every node binds the VIP. With ip_nonlocal_bind, HAProxy listens on 10.20.0.50 even while the VIP is on another node. When keepalived moves the VIP, the new node answers at once, without a HAProxy restart.
  • All three authentik nodes in the backend, not just the local one. If authentik dies on the node that holds the VIP, its HAProxy simply sends requests to the other two. The VIP only has to move if HAProxy itself, or the whole node, fails.
  • The health check asks authentik’s readiness endpoint, which only answers 200 once the instance is up and can reach its database.
  • X-Forwarded-For is overwritten, not appended. authentik uses it for logging, reputation and GeoIP, and it trusts it from the proxy addresses in section 10. A client-supplied header must never get through.
  • PostgreSQL is plain TCP (the TLS session runs end to end between authentik and PostgreSQL). Patroni’s REST API answers /primary with 200 only on the leader. on-marked-down shutdown-sessions cuts the connections to an old leader immediately after a switchover, so authentik reconnects to the new one instead of waiting for TCP timeouts.

9. keepalived

keepalived runs its check as an unprivileged user:

useradd --system --no-create-home --shell /usr/sbin/nologin keepalived_script

/etc/keepalived/keepalived.conf on auth-01:

global_defs {
    router_id auth-01
    enable_script_security
    script_user keepalived_script
    vrrp_garp_master_refresh 60
}

vrrp_script chk_haproxy {
    # healthy = HAProxy runs AND has at least one authentik node up
    script "/usr/bin/curl -fsS -o /dev/null --max-time 2 http://127.0.0.1:8404/healthz"
    interval 2
    timeout 3
    fall 2
    rise 3
}

vrrp_instance VI_AUTH {
    state BACKUP
    interface ens192
    virtual_router_id 61
    priority 150
    advert_int 1
    preempt_delay 60

    unicast_src_ip 10.20.0.51
    unicast_peer {
        10.20.0.52
        10.20.0.53
    }
    check_unicast_src

    authentication {
        auth_type PASS
        auth_pass 7hQx2vLm
    }

    virtual_ipaddress {
        10.20.0.50/24 dev ens192
    }

    track_script {
        chk_haproxy
    }
}Code language: PHP (php)

On auth-02 and auth-03, change router_id, priority (140, 130), unicast_src_ip and unicast_peer. Keep the virtual_router_id and auth_pass the same on all three, and choose a VRID that no other VRRP router on the segment uses.

keepalived -t -f /etc/keepalived/keepalived.conf && systemctl enable --now keepalived
ip -br addr show ens192        # the VIP shows up on auth-01Code language: PHP (php)
  • No weight on the track script. When the check fails, the instance goes into FAULT and releases the VIP straight away, whatever the priorities are.
  • preempt_delay 60: when auth-01 comes back, it waits 60 seconds before taking the VIP back. A node that’s still warming up doesn’t get traffic, and a flapping node doesn’t move the VIP back and forth.
  • Unicast with check_unicast_src: adverts only go to and come from the three nodes, and the firewall (section 7) only accepts VRRP from them. The PASS authentication only prevents accidental cross-talk with another VRRP setup. It isn’t security.

10. authentik: secrets, configuration and compose file

10.1 Secrets

Three secret values, identical on all three nodes:

install -d -m 0750 -o root -g 1000 /opt/authentik/secrets

# create once, on auth-01, and copy the same files to auth-02 and auth-03
openssl rand -base64 60 | tr -d '\n' > /opt/authentik/secrets/secret_key
printf '%s' 'use-a-long-random-password-here' > /opt/authentik/secrets/pg_password
install -m 0640 -o root -g 1000 pg-ca.crt /opt/authentik/secrets/pg-ca.crt

chown root:1000 /opt/authentik/secrets/*
chmod 0640 /opt/authentik/secrets/*Code language: PHP (php)
  • secret_key signs sessions and tokens. All nodes need the same one, or a session started on one node is invalid on the next. Changing it later logs everybody out. Back it up (section 19).
  • pg_password is the database password from section 4.
  • pg-ca.crt is the CA of the Patroni nodes, so authentik can verify the database server.

Group 1000 is the authentik user inside the container. That way it can read the files, and nobody else on the host except root can.

10.2 Configuration

/opt/authentik/authentik.env (mode 0640, owner root:root). It contains no secrets, only file:// references to them:

# ---------- database: via the local HAProxy to the Patroni leader ----------
AUTHENTIK_POSTGRESQL__HOST=127.0.0.1
AUTHENTIK_POSTGRESQL__PORT=5432
AUTHENTIK_POSTGRESQL__NAME=authentik
AUTHENTIK_POSTGRESQL__USER=authentik
AUTHENTIK_POSTGRESQL__PASSWORD=file:///run/authentik-secrets/pg_password
AUTHENTIK_POSTGRESQL__SSLMODE=verify-ca
AUTHENTIK_POSTGRESQL__SSLROOTCERT=/run/authentik-secrets/pg-ca.crt
# keep connections for 60 s, and check them before reuse (after a failover)
AUTHENTIK_POSTGRESQL__CONN_MAX_AGE=60
AUTHENTIK_POSTGRESQL__CONN_HEALTH_CHECKS=true

# ---------- optional: read-only queries to a replica ----------
#AUTHENTIK_POSTGRESQL__READ_REPLICAS__0__HOST=127.0.0.1
#AUTHENTIK_POSTGRESQL__READ_REPLICAS__0__PORT=5433
#AUTHENTIK_POSTGRESQL__READ_REPLICAS__0__NAME=authentik
#AUTHENTIK_POSTGRESQL__READ_REPLICAS__0__USER=authentik
#AUTHENTIK_POSTGRESQL__READ_REPLICAS__0__PASSWORD=file:///run/authentik-secrets/pg_password
#AUTHENTIK_POSTGRESQL__READ_REPLICAS__0__SSLMODE=verify-ca
#AUTHENTIK_POSTGRESQL__READ_REPLICAS__0__SSLROOTCERT=/run/authentik-secrets/pg-ca.crt

# ---------- identity of this deployment ----------
AUTHENTIK_SECRET_KEY=file:///run/authentik-secrets/secret_key

# only our HAProxies may set X-Forwarded-For
AUTHENTIK_LISTEN__TRUSTED_PROXY_CIDRS=127.0.0.1/32,10.20.0.51/32,10.20.0.52/32,10.20.0.53/32

# ---------- files: on the NFS share ----------
AUTHENTIK_STORAGE__BACKEND=file
AUTHENTIK_STORAGE__FILE__PATH=/data

# ---------- nothing leaves the network ----------
AUTHENTIK_ERROR_REPORTING__ENABLED=false
AUTHENTIK_DISABLE_UPDATE_CHECK=true

AUTHENTIK_LOG_LEVEL=infoCode language: PHP (php)

Why sslmode=verify-ca and not verify-full: authentik connects to 127.0.0.1, the local HAProxy, so the host name never matches the database certificate. verify-ca still proves that the server holds a certificate from your Patroni CA, which only signs the three database nodes.

Trusted proxies: authentik’s default list trusts all private ranges. Narrowed to the HAProxies, nobody else on the network can fake a client address.

Read replicas send read-only queries to a streaming replica through the pg_ro frontend. That takes load off the leader, but replicas lag slightly behind. Leave it off unless the leader is actually busy.

10.3 The compose file

/opt/authentik/compose.yml, the same on all nodes:

name: authentik

x-authentik: &authentik
  image: ghcr.io/goauthentik/server:2026.8.6
  restart: unless-stopped
  network_mode: host
  shm_size: 512mb
  env_file: /opt/authentik/authentik.env
  security_opt:
    - no-new-privileges:true
  cap_drop:
    - ALL
  logging:
    driver: journald
    options:
      tag: "{{.Name}}"

services:
  server:
    <<: *authentik
    command: server
    environment:
      # plain HTTP only for local use; HAProxy talks HTTPS on 9443
      AUTHENTIK_LISTEN__HTTP: "127.0.0.1:9000"
      AUTHENTIK_LISTEN__HTTPS: "[::]:9443"
      AUTHENTIK_LISTEN__METRICS: "[::]:9300"
    volumes:
      - /srv/authentik/shared/data:/data
      - /srv/authentik/shared/templates:/templates:ro
      - /opt/authentik/secrets:/run/authentik-secrets:ro

  worker:
    <<: *authentik
    command: worker
    environment:
      # host networking: the worker must not collide with the server's ports
      AUTHENTIK_LISTEN__HTTP: "127.0.0.1:9001"
      AUTHENTIK_LISTEN__METRICS: "[::]:9301"
    volumes:
      - /srv/authentik/shared/data:/data
      - /srv/authentik/shared/templates:/templates:ro
      - /srv/authentik/shared/blueprints:/blueprints/custom:ro
      - /opt/authentik/secrets:/run/authentik-secrets:roCode language: PHP (php)

The differences from authentik’s own compose file, and why:

Official fileHereWhy
Bundled postgresql serviceNone; Patroni through HAProxyThe database must survive a node
Bridge network, ports 9000, 9443 publishednetwork_mode: host, explicit listen addressesnftables controls every port (published ports bypass the input chain); no NAT between HAProxy and authentik
Worker as user: root with /var/run/docker.sockNeitherThe socket is root on the host. It’s only needed to let authentik deploy outposts automatically. Deploy outposts yourself instead.
./data, ./custom-templates localOn the NFS shareSame files on every node
Image tag from a variablePinned in the fileAll nodes run exactly the same version
No hardening optionsno-new-privileges, cap_drop: ALLauthentik listens on ports above 1024 and needs no capabilities

The worker also listens on the HTTP and metrics ports, which is why it gets its own in host mode. The server keeps 9000 on localhost and offers 9443 to the other nodes’ HAProxies.


11. First start and initial setup

Start one node first. The first start creates the database schema, and you don’t want three nodes racing to do it:

# auth-01
cd /opt/authentik
docker compose pull
docker compose up -d
docker compose logs -fCode language: PHP (php)

Wait until the logs calm down and the instance is ready:

curl -sk -o /dev/null -w '%{http_code}\n' https://127.0.0.1:9443/-/health/ready/   # 200Code language: JavaScript (javascript)

Then start auth-02 and auth-03 the same way. Check on the leader that all three nodes are connected:

SELECT client_addr, count(*) FROM pg_stat_activity WHERE datname = 'authentik' GROUP BY 1;Code language: JavaScript (javascript)

Initial setup. Open https://auth.mydomain.local/if/flow/initial-setup/ and set the e-mail and password of the built-in administrator akadmin. Do it right away, before anyone else on the network finds the page.

Then, as akadmin:

  1. Enrol a WebAuthn key (or at least TOTP) for akadmin: user settings โ†’ MFA Devices.
  2. Store the password in your vault. akadmin becomes the break-glass account: you’ll only use it when AD or Kerberos is broken (section 14.4).
  3. System โ†’ Settings: set the default token durations and the footer links to your policies. Check System โ†’ Brands โ†’ authentik-default for the domain and title.

12. End-to-end TLS between HAProxy and authentik

On 9443, authentik serves the web certificate of the brand. Until you set one, it’s a self-signed certificate, and HAProxy with verify required would mark every node as down. Do this once; it’s stored in the database, so it applies to all nodes:

  1. System โ†’ Certificates โ†’ Import: name auth.mydomain.local, the certificate (with the intermediate) and the key.
  2. System โ†’ Brands โ†’ authentik-default โ†’ Edit โ†’ Web certificate: select auth.mydomain.local.

Check it from another node:

openssl s_client -connect 10.20.0.52:9443 -servername auth.mydomain.local \
    -CAfile /etc/haproxy/ca/mydomain-ca.pem -verify_hostname auth.mydomain.local -verify_return_error -brief </dev/null
# Verification: OKCode language: PHP (php)

If you started HAProxy with ssl verify none, switch the default-server line in be_authentik to the verify required version from section 8 now, then reload:

haproxy -c -f /etc/haproxy/haproxy.cfg && systemctl reload haproxy
echo "show servers state be_authentik" | socat stdio /run/haproxy/admin.sockCode language: PHP (php)

All three servers must be up (srv_op_state 2). From now on, every hop is encrypted and verified: browser โ†’ HAProxy (your certificate), HAProxy โ†’ authentik (verified against your CA), authentik โ†’ PostgreSQL (verified against the Patroni CA), authentik โ†’ AD (LDAPS, section 13).


13. Active Directory: LDAP source

13.1 On the AD side

  • A service account for the sync, for example svc-authentik: a normal user with a long random password that never expires, Deny log on locally and Deny log on through Remote Desktop via GPO. For sync only, it needs no special rights: authenticated users can read the directory.
  • If you want authentik to write passwords back to AD (password reset through authentik), the account also needs the delegated Reset password right on the user OUs. Otherwise leave it out.
  • The AD CA certificate, so authentik can verify the LDAPS certificates of the DCs.

13.2 The source in authentik

Import the AD CA in System โ†’ Certificates (certificate only, no key). Then go to Directory โ†’ Federation and Social login โ†’ Create โ†’ LDAP Source:

FieldValue
Name / SlugActive Directory / ad
Server URIldaps://dc01.mydomain.local,ldaps://dc02.mydomain.local
TLS Verification CertificateThe AD CA you imported
Bind CNsvc-authentik@mydomain.local
Bind PasswordThe service account’s password
Base DNDC=mydomain,DC=local
Sync users / Sync groupsOn
User password writebackOff, unless you need it (13.1)
Addition User DN / Group DNYour OUs, for example OU=Users,OU=Corp / OU=Groups,OU=Corp
User object filter(&(objectClass=user)(!(objectClass=computer))(!(userAccountControl:1.2.840.113556.1.4.803:=2)))
Group object filter(objectClass=group)
Lookup using a user attributeOn
Group membership fieldmemberOf:1.2.840.113556.1.4.1941:
Object uniqueness fieldobjectSid
User property mappingsAll mappings that start with authentik default LDAP and authentik default Active Directory
Group property mappingsauthentik default LDAP Mapping: Name
  • Multiple DCs in a comma-separated list: if one is down, the sync and logins use the next.
  • The extra filter part !(userAccountControl:...:=2) skips disabled accounts. A user you disable in AD drops out of the next sync. AD refuses their password at login regardless.
  • memberOf:1.2.840.113556.1.4.1941: is AD’s “in chain” matching rule. It resolves nested groups, so a user in a group that’s a member of GG-Grafana-Admins counts as a member too.
  • objectSid never changes, even when a user is renamed or moved to another OU. authentik keeps matching the same person.

Save, then Run sync now on the source and check Sync status. The users and groups appear under Directory โ†’ Users and Groups. The worker repeats the sync on a schedule. Which worker runs it doesn’t matter; the task queue is in PostgreSQL.


14. Logging in with AD passwords and enforced MFA

14.1 AD passwords

The sync doesn’t copy passwords. They’re checked against AD at login. In Flows and Stages โ†’ Stages โ†’ default-authentication-password โ†’ Edit, enable the backend User database + LDAP password and select the ad source. Users now log in with their AD username or e-mail and their AD password.

14.2 MFA for everyone

Edit default-authentication-mfa-validation:

  • Device classes: WebAuthn and TOTP. Leave static codes only as a recovery option.
  • Not configured action: Force the user to configure an authenticator, with the WebAuthn and TOTP setup stages.

From the next login on, every user has to enrol a second factor. AD password plus WebAuthn (a security key or Windows Hello / Touch ID) is phishing-resistant in a way that password plus anything else isn’t.

14.3 Who may log in to what

Applications โ†’ Applications โ†’ app โ†’ Policy / Group / User Bindings: bind the AD groups that may use an application. Without a binding, every authenticated user can use the application, so always bind.

Give the AD group for authentik administrators admin rights: Directory โ†’ Groups โ†’ GG-authentik-Admins โ†’ Edit โ†’ Superuser privileges. Check after the next sync that the flag is still set.

14.4 Break glass

AD down, DCs unreachable, a broken Kerberos change: akadmin (local password + WebAuthn) still logs in, because it doesn’t depend on AD. If even that’s lost, create a recovery link on any node:

cd /opt/authentik
docker compose exec worker ak create_recovery_key 30 akadmin

The number is the validity in minutes. Open the printed URL, fix what’s broken, and change the password.


15. Kerberos single sign-on (SPNEGO)

With SPNEGO, a user who’s logged in to a domain-joined Windows machine opens an application and is logged in without typing anything. The browser hands authentik a Kerberos ticket. The Kerberos source in authentik is marked preview, so test it well before you rely on it.

15.1 Service principal and keytab, on a DC

A dedicated account for the service principal, for example svc-authentik-krb, then:

setspn -Q HTTP/auth.mydomain.local          # must not exist yet
ktpass -princ HTTP/auth.mydomain.local@MYDOMAIN.LOCAL -mapuser MYDOMAIN\svc-authentik-krb `
       -crypto AES256-SHA1 -ptype KRB5_NT_PRINCIPAL -pass * -out authentik-http.keytab
setspn -L svc-authentik-krb                  # shows HTTP/auth.mydomain.localCode language: PHP (php)

In the account’s properties, enable This account supports Kerberos AES 256 bit encryption, so no RC4 tickets are issued. authentik wants the keytab base64-encoded:

[Convert]::ToBase64String([IO.File]::ReadAllBytes('authentik-http.keytab')) | Set-ClipboardCode language: PHP (php)

Then delete the keytab file. It’s a password.

15.2 The source in authentik

Directory โ†’ Federation and Social login โ†’ Create โ†’ Kerberos Source:

FieldValue
Name / SlugKerberos / kerberos
RealmMYDOMAIN.LOCAL
Sync usersOff; the LDAP source does that
SPNEGO keytabThe base64 string from 15.1
SPNEGO server nameEmpty (authentik tries every principal in the keytab)
User matching modeLink to an existing user with the same username
Property mappingsThe defaults, including Ignore other realms and Ignore system principals

The users the LDAP source created must be found by the name the Kerberos principal produces (jdoe@MYDOMAIN.LOCAL โ†’ jdoe). Test with one user. If the names don’t match, adjust the username mapping so both sources produce the same form.

Add the Kerberos source to default-authentication-identification โ†’ Sources, so the login page offers it.

15.3 The browsers

Browsers only send Kerberos tickets to sites they’re told to trust. Via GPO:

BrowserSetting
Edge, ChromeAuthServerAllowlist = auth.mydomain.local
Internet Options (used by both)https://auth.mydomain.local in the Local intranet zone
Firefoxnetwork.negotiate-auth.trusted-uris = https://auth.mydomain.local

Kerberos needs the name, never the IP address, because the service principal is HTTP/auth.mydomain.local. For a failing login, klist on the client shows whether a ticket for HTTP/auth.mydomain.local was issued.


16. Federation: connecting applications

16.1 OIDC: Grafana as an example

In authentik: Applications โ†’ Applications โ†’ Create with provider:

  • Application: name Grafana, slug grafana
  • Provider: OAuth2/OpenID Connect
  • Client type: Confidential
  • Redirect URI: https://grafana.mydomain.local/login/generic_oauth (strict)
  • Signing key: a certificate from System โ†’ Certificates
  • Scopes: openid, profile, email
  • Bindings: the AD groups GG-Grafana-Users and GG-Grafana-Admins

In Grafana (my Grafana on Debian 13 guide), /etc/grafana/grafana.ini:

[auth.generic_oauth]
enabled = true
name = authentik
client_id = <client id from authentik>
client_secret = $__file{/etc/grafana/secrets/oauth_client_secret}
scopes = openid profile email
auth_url = https://auth.mydomain.local/application/o/authorize/
token_url = https://auth.mydomain.local/application/o/token/
api_url = https://auth.mydomain.local/application/o/userinfo/
signout_redirect_url = https://auth.mydomain.local/application/o/grafana/end-session/
use_pkce = true
tls_client_ca = /etc/grafana/mydomain-ca.pem
role_attribute_path = contains(groups, 'GG-Grafana-Admins') && 'Admin' || 'Viewer'
role_attribute_strict = true
allow_assign_grafana_admin = falseCode language: PHP (php)
  • The client secret lives in a root-only file, like the other Grafana secrets.
  • use_pkce protects the authorization code even if it leaks.
  • role_attribute_strict refuses users who match no role, instead of quietly making them viewers.

16.2 SAML

For applications that only speak SAML (many appliances and commercial tools):

  1. Create the application with a SAML provider. ACS URL and audience come from the application’s documentation.
  2. Choose a signing certificate, and enable signing of the assertion.
  3. Download the metadata (https://auth.mydomain.local/application/saml/<slug>/metadata/) and import it into the application.
  4. Map the attributes the application expects (e-mail, groups) with property mappings.

16.3 Other directions

  • Applications that can only do LDAP get an LDAP outpost. Deploy it by hand as its own container, on these nodes or elsewhere, since the Docker socket isn’t mounted.
  • Applications without any SSO go behind a proxy outpost (forward auth), for example in front of a reverse proxy.
  • Upstream federation: authentik can itself use Entra ID or ADFS as an OAuth/SAML source, for example for external staff. Then authentik stays the single place where your applications and policies are configured.

17. Monitoring

Prometheus scrape jobs (my Prometheus and Alertmanager in Docker guide):

  - job_name: authentik-server
    static_configs:
      - targets: [ 'auth-01.mydomain.local:9300', 'auth-02.mydomain.local:9300', 'auth-03.mydomain.local:9300' ]
  - job_name: authentik-worker
    static_configs:
      - targets: [ 'auth-01.mydomain.local:9301', 'auth-02.mydomain.local:9301', 'auth-03.mydomain.local:9301' ]
  - job_name: authentik-haproxy
    static_configs:
      - targets: [ 'auth-01.mydomain.local:8405', 'auth-02.mydomain.local:8405', 'auth-03.mydomain.local:8405' ]
  - job_name: authentik-login
    metrics_path: /probe
    params:
      module: [ http_2xx ]
    static_configs:
      - targets: [ 'https://auth.mydomain.local/-/health/live/' ]
    relabel_configs:
      - source_labels: [ __address__ ]
        target_label: __param_target
      - target_label: __address__
        replacement: blackbox-exporter:9115Code language: PHP (php)

Alert rules:

groups:
  - name: authentik
    rules:
      - alert: AuthentikInstanceDown
        expr: up{job=~"authentik-(server|worker)"} == 0
        for: 2m
        labels: { severity: warning }
        annotations:
          summary: "authentik {{ $labels.job }} on {{ $labels.instance }} is down"
      - alert: AuthentikBackendDegraded
        expr: max(haproxy_backend_active_servers{proxy="be_authentik"}) < 3
        for: 5m
        labels: { severity: warning }
        annotations:
          summary: "Only {{ $value }} of 3 authentik nodes are healthy"
      - alert: AuthentikNoDatabaseLeader
        expr: max(haproxy_backend_active_servers{proxy="pg_rw"}) < 1
        for: 1m
        labels: { severity: critical }
        annotations:
          summary: "HAProxy sees no Patroni leader: authentik cannot write"
      - alert: AuthentikVipUnreachable
        expr: probe_success{job="authentik-login"} == 0
        for: 2m
        labels: { severity: critical }
        annotations:
          summary: "https://auth.mydomain.local is not answering"Code language: JavaScript (javascript)

In authentik itself: System โ†’ System Tasks shows failed tasks, LDAP sync errors included. Events โ†’ Logs has logins, failures and admin changes. Forward events to your SIEM with a notification rule and a webhook transport, or collect the container logs from the journal (journalctl CONTAINER_NAME=authentik-server-1).

keepalived logs every state change. Find out who holds the VIP with:

journalctl -u keepalived -g 'Entering (MASTER|BACKUP|FAULT)' --since todayCode language: JavaScript (javascript)

18. Testing failover

Do every test while a browser session is open and a user logs in repeatedly. Write down what happened.

TestHowExpected
authentik dies on the VIP nodedocker compose stop on auth-01HAProxy on auth-01 marks it down within ~9 s; requests go to auth-02/03; the VIP stays
HAProxy dies on the VIP nodesystemctl stop haproxy on auth-01keepalived goes into FAULT, the VIP moves within ~4 s, sessions stay valid
Whole node gonePower off auth-01 in vCenterThe VIP moves to auth-02; auth-03’s HAProxy marks auth-01 down
Node comes backStart auth-01After 60 s (preempt_delay), auth-01 takes the VIP back
Database switchoverpatronictl switchover on the Patroni clusterpg_rw follows the new leader; authentik reconnects; at most a few seconds of errors
NAS failoverFail over the NASFile access pauses (hard mount) and continues; uploads in that moment may fail
AD DC downStop dc01’s services or block 636Logins and sync go to dc02
AD completely downBlock 636 to all DCsAD users can’t log in; akadmin can

Check after each test:

echo "show servers state" | socat stdio /run/haproxy/admin.sock | awk '{print $2, $4, $6}'
ip -br addr show ens192
docker compose -f /opt/authentik/compose.yml psCode language: PHP (php)

19. Backup and recovery

WhatWhereHow
DatabasePatroniYour PostgreSQL backups (pgBackRest or pg_dump). It holds everything: configuration, users, sessions, tasks.
Secret key/opt/authentik/secrets/secret_keyIn your vault. Without it, a restore logs everyone out, and tokens signed with it become invalid.
Shared filesNASSnapshots of /export/authentik
Node configuration/opt/authentik, /etc/haproxy, /etc/keepalived, /etc/nftables.confIn git (etckeeper, or an Ansible repository)
Certificates and keysHAProxy, authentik, the keytabIn your vault

A logical backup before every upgrade, on the leader:

sudo -u postgres pg_dump -Fc -d authentik -f /var/backups/authentik-$(date +%F).dumpCode language: JavaScript (javascript)

Restore onto an empty database: stop authentik on all nodes, pg_restore -d authentik as the owner, put the same secret_key and the same image version in place, and start one node first, as in section 11.

Configuration as code: for anything you build by hand in the UI, consider a blueprint in /srv/authentik/shared/blueprints. The worker applies blueprints automatically, and they’re versioned in git like everything else.


20. Upgrades

authentik’s rules:

  • Don’t skip major releases. Go through each release in turn (2026.2 โ†’ 2026.5 โ†’ 2026.8 …), always to the newest patch of each.
  • Downgrades aren’t supported. The backup is your way back.
  • Read the release notes of every version you go through. They list breaking changes, and the order is enforced: the tooling refuses unsupported jumps before migrations start. For example, the 2026.8 notes announce a new setting, AUTHENTIK_WEB__BASE_URL, that becomes required in a later release. Check what it means for your version when you get there.

Server and worker of all nodes should run the same version, and the database schema changes during the upgrade. So upgrade the whole cluster in one maintenance window, with one or two minutes of downtime:

# 1. backup (section 19), on the Patroni leader

# 2. on all three nodes: new tag in compose.yml, pull in advance
sed -i 's|server:2026.8.6|server:2026.8.7|' /opt/authentik/compose.yml
docker compose -f /opt/authentik/compose.yml pull

# 3. stop auth-02 and auth-03
docker compose -f /opt/authentik/compose.yml down

# 4. auth-01: start with the new version, which runs the migrations
docker compose -f /opt/authentik/compose.yml up -d
docker compose -f /opt/authentik/compose.yml logs -f server    # wait for it to be ready

# 5. auth-02 and auth-03
docker compose -f /opt/authentik/compose.yml up -dCode language: PHP (php)

Also update every outpost you deployed by hand to the same version. Outposts must match the server version.

Debian, HAProxy and keepalived updates are rolling, one node at a time: start with a node that doesn’t hold the VIP, and for the VIP node, stop keepalived first so the VIP moves away cleanly.


21. Troubleshooting

SymptomCheckLikely cause
All be_authentik servers DOWN after setupshow servers state be_authentikBrand web certificate not set yet, HAProxy verifies against a self-signed certificate (section 12)
Logins work, but you’re logged out after a few clickssecret_key on all nodesDifferent secret keys on the nodes
Every client shows the HAProxy address in the logsAUTHENTIK_LISTEN__TRUSTED_PROXY_CIDRSHAProxy’s address isn’t in the list, or the header isn’t set
authentik doesn’t start: database connection errorsdocker compose logs serverpg_hba entry missing, wrong CA in pg-ca.crt, or no leader in pg_rw
Errors for a few seconds after a Patroni switchoverExpectedConnections to the old leader are cut; authentik reconnects
Uploaded icon visible on one node, missing on anotherfindmnt /srv/authentik/shared on every nodeThe share wasn’t mounted when Docker started; check the systemd drop-in
Worker container restarts: “address already in use”ss -ltnpWorker and server on the same port in host mode (section 10.3)
VIP on two nodes at oncejournalctl -u keepalivedVRRP blocked between nodes (firewall), or different virtual_router_id/auth_pass
LDAP sync failsSystem โ†’ System Tasks, the source’s sync statusBind account password, LDAPS certificate not trusted, filter error
AD users can’t log in, sync worksPassword stage backendsUser database + LDAP password not enabled (section 14.1)
Kerberos prompts for a password or failsklist on the client, browser policiesSite not trusted for Negotiate, SPN missing or duplicate, keytab without AES
Upgrade stops with “migration inconsistency”Server logsA release was skipped: restore the backup and upgrade in sequence

22. Checklist

  • โ˜ Patroni database authentik with its own role, hostssl entries for the three nodes only, max_connections sized
  • โ˜ NFS export with data, templates, blueprints owned by UID 1000, mounted hard on every node, Docker waits for the mount
  • โ˜ nftables: 443/80 open, 9443 and VRRP only between the nodes, metrics only from Prometheus, SSH only from admins
  • โ˜ HAProxy on every node: VIP bound with ip_nonlocal_bind, TLS 1.2+, X-Forwarded-For overwritten, backends verified against your CA
  • โ˜ HAProxy pg_rw routes to the Patroni leader via /primary, with shutdown-sessions on failover
  • โ˜ keepalived: unicast, source check, FAULT on a failed check, preempt_delay
  • โ˜ Same secret_key, same image version and same configuration on all three nodes; secrets via file://
  • โ˜ No Docker socket, no-new-privileges, cap_drop: ALL, error reporting and update check off
  • โ˜ Trusted proxy CIDRs narrowed to the HAProxies
  • โ˜ Brand web certificate set; HAProxy โ†’ authentik verified
  • โ˜ AD LDAP source over LDAPS with both DCs, nested groups, objectSid, disabled accounts filtered
  • โ˜ Login with AD password, MFA enforced for everyone, applications bound to AD groups
  • โ˜ akadmin as break-glass with WebAuthn, password in the vault; recovery key procedure known
  • โ˜ Kerberos SPNEGO with an AES-only keytab; browsers trust the site via GPO
  • โ˜ Prometheus scrapes server, worker and HAProxy; alerts for nodes, backend, leader and the VIP
  • โ˜ Failover tests from section 18 done and written down
  • โ˜ Database backups, secret key in the vault, NAS snapshots, configuration in git
  • โ˜ Upgrade runbook: backup, every release in order, all nodes together, outposts too