1. Caddy version (caddy version
):
2.4.6
2. How I run Caddy:
Trough Docker Compose using image: caddy:2.4.6
a. System environment:
Ubuntu 20.04.3 LTS on Digital Ocean
docker-compose version 1.29.2
b. Command:
docker-compose up -d
c. Service/unit/compose file:
docker-compose.yml:
version: '3.7'
networks:
bonsy:
services:
caddy:
image: caddy:2.4.6
container_name: bonsy_caddy
restart: unless-stopped
ports:
- "80:80"
- "443:443"
volumes:
- ./docker/caddy/prod/Caddyfile:/etc/caddy/Caddyfile
- ./site:/var/www
- caddy_data:/data
- caddy_config:/config
depends_on:
- php
- mariadb
networks:
- bonsy
php:
build:
args:
user: ${PHP_USER}
uid: ${PHP_UID}
context: .
dockerfile: ./docker/php/Dockerfile
container_name: bonsy_php
restart: unless-stopped
volumes:
- ./site:/var/www
working_dir: /var/www
links:
- mariadb
networks:
- bonsy
mariadb:
image: mariadb:10.6.4
container_name: bonsy_mariadb
restart: unless-stopped
tty: true
ports:
- "3306:3306"
volumes:
- db_data:/var/lib/mysql
- ./docker/mariadb/initdb:/docker-entrypoint-initdb.d
- ./docker/mariadb/prod.cnf:/etc/mysql/conf.d/custom.cnf
environment:
MARIADB_ROOT_PASSWORD: ${DB_ROOT_PASSWORD}
MARIADB_DATABASE: ${DB_DATABASE}
networks:
- bonsy
volumes:
caddy_data:
caddy_config:
db_data:
driver: local
d. My complete Caddyfile or JSON config:
4.225.66.142:80,
bonsy.se,
app.bonsy.se {
root * /var/www/public
php_fastcgi /* php:9000
encode gzip
file_server
}
www.bonsy.se {
redir https://bonsy.se{uri}
}
3. The problem I’m having:
Everything runs as normal for a few days. Sometimes more than one week. Then suddenly I’m no longer able to access site. Both domain name and IP-address is down. Though all config above is for 1 server, I’m experiencing the exact same problem on another droplet on Digital Ocean. Only difference is that the other domain seems to last longer before it stops working.
When running docker ps
to check services, everything is running as normal.
I’m unsure if this issue is related to Caddy. If I run docker-compose stop caddy
and then docker-compose start caddy
everything gets back to normal.
4. Error messages and/or full log output:
The last logs before the server is not reachable
caddy_1 | {“level”:“info”,“ts”:1642340792.576553,“logger”:“tls.cache.maintenance”,“msg”:“advancing OCSP staple”,“identifiers”:[“bonsy.se”],“from”:1642640398,“to”:1642856398}
caddy_1 | {“level”:“info”,“ts”:1642340792.7062128,“logger”:“tls.cache.maintenance”,“msg”:“advancing OCSP staple”,“identifiers”:[“app.bonsy.se”],“from”:1642640398,“to”:1642856398}
caddy_1 | {“level”:“info”,“ts”:1642340792.8394566,“logger”:“tls.cache.maintenance”,“msg”:“advancing OCSP staple”,“identifiers”:[“www.bonsy.se”],“from”:1642640398,“to”:1642856398}
The logs after docker caddy service is restarted
ddy_1 | {“level”:“info”,“ts”:1642413590.9739013,“msg”:“shutting down apps, then terminating”,“signal”:“SIGTERM”}
caddy_1 | {“level”:“warn”,“ts”:1642413590.9739437,“msg”:“exiting; byeee!! ”,“signal”:“SIGTERM”}
caddy_1 | {“level”:“info”,“ts”:1642413590.9779565,“logger”:“tls.cache.maintenance”,“msg”:“stopped background certificate maintenance”,“cache”:“0xc000533d50”}
caddy_1 | {“level”:“info”,“ts”:1642413590.9792933,“logger”:“admin”,“msg”:“stopped previous server”,“address”:“tcp/localhost:2019”}
caddy_1 | {“level”:“info”,“ts”:1642413590.9793048,“msg”:“shutdown complete”,“signal”:“SIGTERM”,“exit_code”:0}
caddy_1 | {“level”:“info”,“ts”:1642413596.872622,“msg”:“using provided configuration”,“config_file”:"/etc/caddy/Caddyfile",“config_adapter”:“caddyfile”}
caddy_1 | {“level”:“info”,“ts”:1642413596.8796692,“logger”:“admin”,“msg”:“admin endpoint started”,“address”:“tcp/localhost:2019”,“enforce_origin”:false,“origins”:[“localhost:2019”,"[::1]:2019",“127.0.0.1:2019”]}
caddy_1 | {“level”:“info”,“ts”:1642413596.8798656,“logger”:“http”,“msg”:“server is listening only on the HTTPS port but has no TLS connection policies; adding one to enable TLS”,“server_name”:“srv0”,“https_port”:443}
caddy_1 | {“level”:“info”,“ts”:1642413596.8798788,“logger”:“http”,“msg”:“enabling automatic HTTP->HTTPS redirects”,“server_name”:“srv0”}
caddy_1 | {“level”:“info”,“ts”:1642413596.8798866,“logger”:“http”,“msg”:“server is listening only on the HTTP port, so no automatic HTTPS will be applied to this server”,“server_name”:“srv1”,“http_port”:80}
caddy_1 | {“level”:“info”,“ts”:1642413596.8829477,“logger”:“http”,“msg”:“enabling automatic TLS certificate management”,“domains”:[“bonsy.se”,“app.bonsy.se”,“www.bonsy.se”]}
caddy_1 | {“level”:“info”,“ts”:1642413596.888416,“logger”:“tls.cache.maintenance”,“msg”:“started background certificate maintenance”,“cache”:“0xc000539e30”}
caddy_1 | {“level”:“info”,“ts”:1642413596.888456,“logger”:“tls”,“msg”:“cleaning storage unit”,“description”:“FileStorage:/data/caddy”}
caddy_1 | {“level”:“info”,“ts”:1642413596.8890398,“logger”:“tls”,“msg”:“finished cleaning storage units”}
caddy_1 | {“level”:“info”,“ts”:1642413597.2713878,“msg”:“autosaved config (load with --resume flag)”,“file”:"/config/caddy/autosave.json"}
caddy_1 | {“level”:“info”,“ts”:1642413597.2715614,“msg”:“serving initial configuration”}
5. What I already tried:
Rechecked all settings. Tried caddy fmt --overwrite command. Tried to search google and forum for similar errors, but unable to find other cases where docker or caddy stops after a few days.
6. Links to relevant resources:
N/A