1. The problem I’m having:
(Sorry for my english)
I’m trying to setup authelia with caddy, but my caddy container keeps crashing when importing authelia configuration to my Caddyfile.
- Caddy is working great (without Authelia)
- Authelia’s is working correctly (I can reach it and setup things).
2. Error messages and/or full log output:
date | stream | content |
---|---|---|
2023/12/21 11:41:25 | stderr | Error: adapting config using caddyfile: parsing caddyfile tokens for ‘forward_auth’: the ‘uri’ subdirective is required, at :0 |
(this is the only log I get before caddy crashes and restarts)
3. Caddy version:
Caddy V2.7.6
4. How I installed and ran Caddy:
a. System environment:
Docker-compose on a synology NAS 420+
c. Service/unit/compose file:
version: '3.9'
services:
caddy:
image: 'caddy:latest'
container_name: caddy
ports:
- "6007:80"
- "6006:443"
volumes:
- '/volume1/docker/caddy/caddy:/etc/caddy' #caddyfile
- '/volume1/docker/caddy/cert:/etc/ssl/custcerts' #my own certs
- '/var/run/docker.sock:/var/run/docker.sock'
- caddy_certs:/etc/ssl/certs #in order to not regenrate cert everytime caddy restart
restart: unless-stopped
network_mode: bridge
authelia:
image: authelia/authelia
container_name: authelia
volumes:
- '/volume1/docker/authelia:/config'
restart: unless-stopped
ports:
- 9091:9091
environment:
- TZ=Europe/Zurich
network_mode: bridge
volumes:
caddy_certs:
d. My complete Caddy config:
{
email myemail@gmail.com
}
(trusted_proxy_list) {
trusted_proxies 192.168.0.0/24
}
auth.sine-fatum.com {
reverse_proxy 192.168.0.200:9091 {
import trusted_proxy_list
}
}
# Protected Endpoint.
ytdl.sine-fatum.com {
forward_auth 192.168.0.200:9091 {
uri /api/verify?rd=https://auth.sine-fatum.com/
copy_headers Remote-User Remote-Groups Remote-Name Remote-Email
## This import needs to be included if you're relying on a trusted proxies configuration.
import trusted_proxy_list
}
reverse_proxy 192.168.0.200:6021 {
## This import needs to be included if you're relying on a trusted proxies configuration.
import trusted_proxy_list
}
}
#a host with custom certificats
host1.sine-fatum.com {
tls /etc/ssl/custcerts/mycustomcert.crt /etc/ssl/custcerts/mycustomkey.key
reverse_proxy 192.168.0.200:6009
}
#another host
host2.sine-fatum.com {
reverse_proxy 192.168.0.200:6008
}
deleting the block “ytdl.sine-fatum.com{}” will avoid making caddy crash and will make host1.sine-fatum.com and host2.sine-fatum.com work again.
5. Links to relevant resources:
I used this in order to help me :