Lesson 9 of 9 · 20m
Caddy vs nginx: Choosing the Edge on Purpose
Caddy often wins on automation and operational clarity, but nginx still wins in specific ecosystems; learn the real decision criteria and migration traps.
The wrong question is "is Caddy better than nginx?" Both are serious infrastructure. The right question is which failure modes, ecosystem assumptions, and operational skills fit the system you are building. I have replaced nginx with Caddy and watched teams become calmer. I have also kept nginx where the surrounding platform already spoke nginx fluently. Context decides.
Where Caddy usually wins
- Public HTTPS is a core requirement and you want issuance/renewal integrated rather than assembled from certbot hooks.
- Humans own the edge config and readability matters more than maximum micro-control.
- You need modern defaults quickly: HTTP/2 and HTTP/3 support, automatic TLS, structured config, graceful reloads.
- Small-to-medium infrastructure values fewer moving parts over squeezing every last niche behavior out of the edge.
A Caddyfile that a new hire can read in one sitting is not cosmetic value. During an outage, readability is an operational control.
Where nginx often still wins
- You are inside an ecosystem that ships mature nginx modules, ingress integrations, or vendor-tested configuration.
- You need extremely specific proxy behavior, legacy module support, or deep muscle memory your team already has.
- The deployment environment is constrained around distribution packages and operational playbooks built over years.
- You require edge behaviors that have been load-tested and documented in nginx under your exact traffic shape.
Do not migrate merely because Caddy is newer. Migration is a risk project, not a style upgrade.
The migration traps that matter
nginx configs often encode hidden behavior in details people forgot they depended on:
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;Caddy handles forwarding headers differently and preserves Host by default. Authentication systems, URL generators, audit logs, and IP allowlists can all change behavior even when HTTP status codes look fine. Compare actual response headers, redirect locations, and application logs — not just whether the homepage loads.
Another trap is trying to transliterate nginx line by line. nginx location blocks and Caddy routes have different composition rules. Rewrite the desired request policy in Caddy's model; then use caddy adapt to verify the compiled shape.
A practical decision table
| Situation | Lean |
|---|---|
| New public web app, small team, TLS everywhere | Caddy |
| Kubernetes ingress already standardized on nginx | nginx |
| SaaS tenant domains with controlled issuance | Caddy |
| Deep reliance on third-party nginx modules | nginx |
| Mixed static + reverse proxy with simple ownership | Caddy |
Field notes
- Benchmark under realistic TLS, keepalive, compression, and upstream conditions. Microbenchmarks of static hello-world responses rarely decide edge migrations.
- Run old and new edge in parallel behind controlled DNS or traffic splitting when the migration is high risk.
- Include renewal failure and certificate-state backup in the migration plan. TLS is behavior, not decoration.
- If neither team can explain the current edge config, simplify requirements before changing servers.
Was this lesson helpful?