Use it when you want a simple, secure-by-default web server or reverse proxy, especially for small sites, internal tools and containers where certificate management should just work.
Caddy
1. Does the config validate?
2. Did certificate issuance succeed (journal)?
3. Are 80/443 reachable from the internet (or is DNS challenge configured)?
4. Is the data directory persistent and writable?
Caddyfile → adapted to JSON → running config (admin API) → automatic HTTPS (ACME, storage) → site routes (reverse_proxy, php_fastcgi, file_server)
Context & applicabilityCommon mistakes · platform/version boundaries
Operational reference
Fast context before you go deeper.
systemctl status caddyVerification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
Capture the concrete output, symptom, packet, log or counter before changing anything.
Step 1 Read-only Verification Verify boundary
caddy validate --config /etc/caddy/Caddyfile
systemctl status caddy
journalctl -u caddy --since "1 hour ago" | grep -iE 'certificate|obtain|error'
# Running configuration (admin API on localhost)
curl -s localhost:2019/config/ | jq '.apps.http.servers | keys'
# From outside: redirect and certificate
curl -sSI http://example.com/ | head -3
echo | openssl s_client -connect example.com:443 -servername example.com 2>/dev/null | openssl x509 -noout -issuer -dates
The journal logs each certificate obtain/renew attempt with the challenge type and the CA's error if it fails.
Step 2 Common mistakes Narrow the fault
- Running Caddy in a container without persistent storage for certificates.
- Enabling on-demand TLS without an
askrestriction. - Exposing the admin API beyond localhost.
- Putting Caddy behind another TLS-terminating proxy and still expecting HTTP-01 to work.
Step 3 Troubleshooting Narrow the fault
Certificate cannot be obtained. Port 80/443 not reachable from the internet, DNS not pointing to this server, a CDN or proxy in front intercepting the challenge, or CA rate limits after repeated failures. Use the DNS challenge for servers that are not publicly reachable.
New certificates on every restart. The data directory is not persistent (container without a volume, wrong HOME for the service user).
Reverse proxy returns 502. Upstream unreachable or failing active health checks (health_uri); the journal shows the dial error.
Config change has no effect. It was edited but not reloaded, or the reload failed validation — check journalctl -u caddy.
caddy validate --config /etc/caddy/Caddyfile— config is valid.systemctl status caddyandjournalctl -u caddy— startup and certificate issuance messages.curl -s localhost:2019/config/ | jq— running configuration via the admin API.curl -sSI https://<host>/— certificate and redirect working.
ReferenceWhat it is2 sections · depth on demand
Direct Answer
Caddy is a web server and reverse proxy with automatic HTTPS. As soon as a site address contains a hostname, Caddy obtains a certificate from an ACME CA (Let's Encrypt, with ZeroSSL as fallback), renews it, and redirects HTTP to HTTPS. A short Caddyfile covers most sites, HTTP/2 and HTTP/3 are on by default, and the running configuration can be read and changed through a local admin API.
Scope and canonical references
- Certificates it obtains: ACME Certificate Automation.
- Other web servers: Nginx, Apache.
- Proxying and PHP: Reverse Proxy, HTTP Load Balancing, PHP-FPM.
ReferenceImportant terms & boundaries1 section · depth on demand
In depth
Caddyfile
{
email admin@example.com
}
example.com, www.example.com {
root * /var/www/example
encode zstd gzip
php_fastcgi unix//run/php/php8.2-fpm.sock
file_server
}
app.example.com {
reverse_proxy 10.0.0.21:8080 10.0.0.22:8080 {
lb_policy least_conn
health_uri /healthz
}
}
The global options block (first braces) sets account email and defaults. Each site block starts with its addresses. Directives such as reverse_proxy, php_fastcgi, file_server, encode, header, redir and handle/route are ordered by Caddy's built-in directive order unless grouped explicitly.
Automatic HTTPS
| Aspect | Behaviour |
|---|---|
| Trigger | A hostname or IP in the site address |
| Issuers | Let's Encrypt first, ZeroSSL as fallback |
| Redirects | HTTP on port 80 redirected to HTTPS automatically |
| Challenges | HTTP-01 needs port 80, TLS-ALPN-01 needs 443; DNS challenge needs a DNS provider module and credentials but no open ports |
| Local names | localhost and internal names get certificates from Caddy's own local CA |
| Storage | Data directory (needs a writable, persistent $HOME/XDG_DATA_HOME); instances sharing storage coordinate as a cluster |
| Renewal | Automatic in the background; failed attempts retry with backoff |
| On-demand TLS | Certificates obtained at the first handshake for unknown names — must be restricted with an ask endpoint |
In containers, mount the data directory on a volume; losing it forces new certificate orders on every restart and can hit CA rate limits.
Configuration model and admin API
The Caddyfile is adapted to Caddy's native JSON. The admin API on localhost:2019 exposes and changes the running configuration (/config/); caddy reload pushes a new config through it without downtime. Keep the admin endpoint bound to localhost.
Commands
| Command | Purpose |
|---|---|
caddy validate --config <file> | Check the configuration |
caddy fmt --overwrite <file> | Normalise Caddyfile formatting |
caddy adapt --config <file> | Show the resulting JSON |
caddy reload --config <file> | Apply without downtime |
caddy list-modules | Installed modules (e.g. DNS providers) |
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Terms & aliases
Hover a linked term for a quick definition; click it to open its glossary entry. Aliases are other names that find this Topic in search.