Skip to main content

authelia

Authelia

创建项目目录‌

mkdir -p authelia/{config,data/redis,data/sqlite}  # 配置文件与数据持久化目录‌

编写 docker-compose.yml

编写 docker-compose.yml‌
version: '3.8'

services:
authelia:
image: authelia/authelia:latest
container_name: authelia
volumes:
- ./authelia/config:/config # 挂载配置文件目录
- ./authelia/data/sqlite:/var/lib/sqlite # SQLite 数据持久化‌
environment:
- AUTHELIA_JWT_SECRET=your_jwt_secret_key # 随机生成密钥
- AUTHELIA_SESSION_SECRET=your_session_secret_key
networks:
- authelia_net
depends_on:
- redis

redis:
image: redis:alpine
container_name: authelia-redis
volumes:
- ./authelia/data/redis:/data # Redis 数据持久化
networks:
- authelia_net

networks:
authelia_net:
driver: bridge

生成配置文件 config.yml

生成配置文件 config.yml
# ./authelia/config/configuration.yml
host: 0.0.0.0
port: 9091
log_level: debug
jwt_secret: ${AUTHELIA_JWT_SECRET}
session:
secret: ${AUTHELIA_SESSION_SECRET}
redis:
host: redis
port: 6379
authentication_backend:
file:
path: /config/users_database.yml
access_control:
default_policy: deny
rules:
- domain: "*.example.com"
policy: two_factor # 启用两步验证
totp:
issuer: authelia.example.com
storage:
local:
path: /var/lib/sqlite

创建用户数据库文件‌

创建用户数据库文件‌
# ./authelia/config/users_database.yml
users:
admin:
password: "$argon2id$v=19$m=65536,t=1,p=2$your_hashed_password"
email: [email protected]
groups:
- admins