Traefik and Caddy get and renew certificates on their own. When renewal fails they keep serving the old certificate, and the logs are the only place that says so.
Traefik: where certificates live
Traefik stores certificates in the file set by certificatesResolvers.<name>.acme.storage, usually acme.json.
Two things break it:
- The file must have mode 600. Otherwise Traefik logs
permissions 644 for /acme.json are too open, please use 600and ignores it:chmod 600 acme.json. - The file must be on a volume that survives a restart. If it isn't, Traefik asks for new certificates on every start and soon hits Let's Encrypt's rate limits.
Traefik: read the ACME errors
docker logs traefik 2>&1 | grep -i acme | tail -n 20
Set log.level: DEBUG for more detail. The usual causes by challenge type:
- HTTP challenge: port 80 doesn't reach the entry point named in
httpChallenge.entryPoint. - TLS challenge: something in front of Traefik ends TLS, such as a CDN, so the challenge never arrives.
- DNS challenge: the provider's API token in the environment expired or lost access to the zone.
Traefik renews about 30 days before expiry. A certificate with less left means renewal is failing.
Traefik: force a renewal
Stop Traefik, back up acme.json, delete the entry for the domain from the Certificates list, and start it again.
Delete the whole file only as a last resort: every certificate is requested again at once.
If openssl s_client shows the subject TRAEFIK DEFAULT CERT, Traefik has no certificate for that router.
Check that the router has tls.certResolver set.
Caddy: where certificates live
Caddy keeps them in its data folder: ~/.local/share/caddy for a system install, /data/caddy in the
official Docker image. In Docker, mount /data as a volume, or every new container starts from zero.
Caddy: read the errors
journalctl -u caddy --since "-2 days" | grep -i -E 'renew|obtain|error'
# Docker
docker logs caddy 2>&1 | grep -i -E 'renew|obtain|error'
Caddy renews when about a third of the lifetime is left, so around 30 days for a 90-day certificate. Most failures are ports 80 and 443 not reaching Caddy, or DNS still pointing at the old server.
Caddy: force a renewal
Caddy has no renew command. Stop it, move the domain's folder out of certificates/ in the data folder, and start it.
Caddy requests a new certificate on start.
Then check what's served
echo | openssl s_client -connect example.com:443 -servername example.com 2>/dev/null \
| openssl x509 -noout -subject -issuer -enddate
For Kubernetes setups, see cert-manager certificate not renewing.