On this page
How does Authelia protect an app?
Authelia sits beside your reverse proxy and answers one question for every request: is this visitor allowed here? The proxy asks Authelia before forwarding; Authelia replies with "yes, and here is the user name" or "no, send them to the login portal". The protected application itself needs no changes.
That makes it a good fit for dashboards and admin tools that have weak or no login of their own, such as a metrics page, a file browser or a status page. It also supports OpenID Connect for apps that can use it, but this guide sticks to forward auth, the most common use.
You need Docker (see Docker Engine), a reverse proxy, and a domain where all protected apps share a parent, for example auth.example.net, grafana.example.net and files.example.net. The session cookie is set on example.net so one login covers every subdomain.
How do you prepare secrets and folders?
Create a config folder and three random secrets with the Authelia image itself, so the values have the right length and character set.
sudo mkdir -p /opt/authelia/config
cd /opt/authelia
for n in jwt session storage; do
sudo docker run --rm authelia/authelia:4.39 \
authelia crypto rand --length 64 --charset alphanumeric | \
awk '{print $NF}' | sudo tee config/secret_$n >/dev/null
done
sudo chmod 600 config/secret_*
sudo docker run --rm authelia/authelia:4.39 authelia --versionPinning the image to a minor version (4.39 here, check the project releases for the current one) keeps config changes predictable. Each secret lives in its own file, and Authelia reads them through environment variables ending in _FILE rather than from the main config.
How do you write the configuration file?
Save /opt/authelia/config/configuration.yml with these sections. The access rules decide which hostnames need one factor or two.
server:
address: 'tcp://:9091/'
log:
level: info
totp:
issuer: example.net
authentication_backend:
file:
path: /config/users.yml
password:
algorithm: argon2
access_control:
default_policy: deny
rules:
- domain: 'status.example.net'
policy: one_factor
- domain: '*.example.net'
policy: two_factor
session:
cookies:
- domain: 'example.net'
authelia_url: 'https://auth.example.net'
default_redirection_url: 'https://www.example.net'
storage:
local:
path: /config/db.sqlite3
notifier:
smtp:
address: 'submission://smtp.example.net:587'
username: 'auth@example.net'
sender: 'Login Portal <auth@example.net>'The submission:// scheme means port 587 with STARTTLS. That authenticated relay route is the reliable one; port 25 is not promised to be open, so ask support with a ticket before you plan direct mail. If you have no relay yet, replace the notifier block with filesystem: and filename: /config/notification.txt to read the emails from a file while testing.
How do you add users?
Users live in users.yml with Argon2 password hashes. Generate a hash, then add the entry.
sudo docker run --rm -it authelia/authelia:4.39 \
authelia crypto hash generate argon2
sudo nano /opt/authelia/config/users.ymlusers:
deploy:
disabled: false
displayname: 'Deploy User'
email: deploy@example.net
groups:
- admins
password: '$argon2id$v=19$m=65536,t=3,p=4$PASTE-THE-HASH'Authelia reloads this file on change. For larger teams, switch the backend to LDAP and keep users in one directory.
How do you start the Authelia container?
A small Compose file passes the secret files and the SMTP password, and binds the port to loopback.
services:
authelia:
image: authelia/authelia:4.39
container_name: authelia
restart: unless-stopped
volumes:
- ./config:/config
ports:
- '127.0.0.1:9091:9091'
environment:
TZ: UTC
AUTHELIA_IDENTITY_VALIDATION_RESET_PASSWORD_JWT_SECRET_FILE: /config/secret_jwt
AUTHELIA_SESSION_SECRET_FILE: /config/secret_session
AUTHELIA_STORAGE_ENCRYPTION_KEY_FILE: /config/secret_storage
AUTHELIA_NOTIFIER_SMTP_PASSWORD_FILE: /config/secret_smtpecho 'relay-password' | sudo tee /opt/authelia/config/secret_smtp >/dev/null
sudo chmod 600 /opt/authelia/config/secret_smtp
cd /opt/authelia && sudo docker compose up -d
sudo docker compose logs --tail 30 authelia
curl -s http://127.0.0.1:9091/api/health; echoThe logs list any config mistakes by key name, and the health call returns {"status":"OK"} when the service is ready. More Compose basics are in the Docker Compose guide.
How do you protect an app with Caddy forward auth?
Publish the portal itself, then add a forward_auth block to each protected site in the Caddyfile.
auth.example.net {
reverse_proxy 127.0.0.1:9091
}
grafana.example.net {
forward_auth 127.0.0.1:9091 {
uri /api/authz/forward-auth
copy_headers Remote-User Remote-Groups Remote-Email Remote-Name
}
reverse_proxy 127.0.0.1:3000
}sudo caddy validate --config /etc/caddy/Caddyfile
sudo systemctl reload caddyCaddy obtains certificates for both names automatically (see Caddy HTTPS). Open https://grafana.example.net in a private window: you should land on the portal, and after login with password plus TOTP you return to the app.
How do you do the same with Nginx?
Nginx uses the auth_request module and a dedicated Authelia endpoint. Inside the protected server block (already on HTTPS via Certbot):
location = /internal/authelia {
internal;
proxy_pass http://127.0.0.1:9091/api/authz/auth-request;
proxy_pass_request_body off;
proxy_set_header Content-Length "";
proxy_set_header X-Original-Method $request_method;
proxy_set_header X-Original-URL $scheme://$http_host$request_uri;
proxy_set_header X-Forwarded-For $remote_addr;
}
location / {
auth_request /internal/authelia;
auth_request_set $user $upstream_http_remote_user;
auth_request_set $redirection_url $upstream_http_location;
error_page 401 =302 $redirection_url;
proxy_set_header Remote-User $user;
proxy_pass http://127.0.0.1:3000;
}The portal host auth.example.net gets a normal proxy block to 127.0.0.1:9091. Test with sudo nginx -t, reload, and repeat the private-window check. The Nginx reverse proxy guide covers the base server block.
How do you keep Authelia healthy?
- Firewall: only 80 and 443 open (
sudo ufw allow 80,443/tcp); 9091 stays on loopback. - Upgrades: raise the image tag one minor version at a time, read the release notes for config changes, then
sudo docker compose pull && sudo docker compose up -d. - Backups: copy
/opt/authelia/config, which holds users, secrets and the SQLite database with TOTP registrations. - Redirect loops: usually the cookie domain does not match the app hostname, or the app is not under
example.net.
Plans that fit this guide
Base city prices. Every plan includes a dedicated IPv4 address, IPv6, full root and all 18 images.
Questions about Authelia SSO and forward auth
Does Authelia replace the login of my apps?
It adds a gate in front. Apps that can trust a Remote-User header can skip their own login; others keep it and simply sit behind the gate.
Can I use WebAuthn security keys?
Yes. Authelia supports WebAuthn and passkeys as a second factor alongside TOTP. Users register them from the portal settings.
Why does registering TOTP ask for an email code?
Authelia confirms identity before adding a device by sending a one-time code through the notifier. Configure SMTP on port 587, or use the filesystem notifier while testing.
How much memory does Authelia need?
Very little: the container usually stays well under 100 MB. It can share a small server with the apps it protects.
Can Authelia protect apps on another server?
Yes, as long as the proxy can reach both Authelia and the app and every hostname sits under the cookie domain.
More in Self-hosted apps
- Nextcloud on Nginx
- ownCloud Infinite Scale
- Seafile file sync
- Vaultwarden password vault
- Passbolt team password manager
- Gitea Git hosting
- Forgejo Git server
- GitLab Community Edition
- Gogs Git service
- Wiki.js
- BookStack documentation
- Outline knowledge base
- Paperless-ngx documents
- n8n workflow automation
- Activepieces automation
- Plausible Analytics (Community Edition)
- Umami analytics
- Mattermost team chat
- Matrix Synapse with Element
- Jitsi Meet video calls
- ONLYOFFICE Docs with Nextcloud
- HashiCorp Vault secrets server
- OpenBao secrets management
- Infisical secrets manager
- Zitadel identity platform
- VS Code in the browser (code-server)
- Joplin Server for notes sync
- Firefly III personal finance
- Snipe-IT asset tracking
- Odoo ERP on Ubuntu or Debian
- ERPNext with frappe_docker
- Dolibarr ERP and CRM with Nginx
- Penpot design tool with Docker
- Planka kanban boards
- Leantime project management
- Wekan boards with Docker
- Cal.com scheduling
- Chatwoot support inbox
- Mautic marketing automation
- DocuSeal document signing
- Metabase dashboards
- Appwrite backend server
- Self-hosted Supabase
- PocketBase backend
- RustDesk relay server
- Traccar GPS tracking
- Redmine project tracker
- The Lounge IRC client
- CyberChef data toolbox
- Typebot chat forms
- AFFiNE workspace
- Overleaf Community Edition
- Neko shared virtual browser
- imgproxy image resizing
- NetBox network inventory
- UVdesk help desk
- YetiForce CRM