Lesson 7 of 9 · 22m
Operations: Logs, Metrics, Reloads, and Debugging Without Guessing
How to inspect what Caddy is doing, what to monitor before users complain, and the safe debugging sequence during an edge incident.
The worst edge-server incident is the one where the proxy is healthy enough to accept traffic but wrong enough to corrupt every request. Good Caddy operations are mostly about visibility: know which config is active, what certificates exist, what upstreams are failing, and whether logs tell the story of the request path.
Start with process truth, not config belief
systemctl status caddy
journalctl -u caddy --since '15 minutes ago'
curl http://localhost:2019/config/ | jq .apps.http.serversThe admin endpoint shows the running configuration. A file on disk is only an intention. After automation or a failed deployment, these can diverge. During incidents, establish the truth in order: process running, config active, listener reachable, route matched, upstream answered.
Access logs are structured — use them that way
app.sudosecurity.org {
log {
output file /var/log/caddy/app-access.log
format json
}
reverse_proxy 127.0.0.1:8080
}JSON logs are not meant to be read like artisanal nginx lines. Feed them to your log pipeline and query fields: status, host, URI, upstream latency, client address. The operational value is in aggregation — suddenly rising 502s by upstream tells a better story than scrolling raw lines.
Be deliberate about sensitive data. URLs often contain tokens; forwarded IPs are personal data in many jurisdictions. Log what you can defend retaining.
Metrics belong beside certificates and upstreams
Caddy can expose Prometheus metrics through the admin endpoint when server metrics are enabled in global options:
{
metrics
}At minimum, watch request counts, error rates, latency, certificate expiry, and process health. Certificate expiry should almost never page if automation is healthy — it should trend as a dashboard signal long before it becomes user-visible.
A disciplined debug sequence
caddy validate --config Caddyfile— can the candidate config parse and validate?caddy adapt --config Caddyfile --pretty— did it compile into the routes you think you wrote?curl -v https://host/from outside — does the request reach this edge and use the expected certificate?journalctl -u caddy— ACME, reload, or upstream errors usually appear quickly.- Query the app locally with explicit forwarded headers — isolate proxy from backend.
Do not jump directly to rewriting routes. Most edge incidents are DNS, reachability, trust, or upstream behavior wearing a proxy costume.
Field notes
caddy reloadreturning success proves config validity, not application correctness.- Keep admin and metrics endpoints on localhost or a protected management network. Observability data is still sensitive.
- Rotate file logs with your platform tooling; a disk full of logs can take down the edge just as surely as traffic.
- Capture one failing request end-to-end: edge log, upstream log, response headers. A single trace beats ten theories.
Was this lesson helpful?