Every time Caddy comes up next to nginx, somebody mentions the shorter config and leaves it there, as if that settles the comparison. It never settles anything for me, because a shorter file doesn't say what happened to the parts that didn't fit in it. So I took an nginx config close to one I've actually run, with a proxy route, a rate limit, a static folder and a redirect, rewrote it as a Caddyfile directive by directive, and checked each one against a real request instead of trusting that it looked right.
I set this up locally with Docker: two matched pairs of containers, each a plain Python backend behind either nginx 1.29 or Caddy 2.11, on their own bridge network, nothing shared between them so neither measurement could leak into the other. The nginx side proxies /api/, serves a static JS file from /static/, rate-limits the API route, and redirects one old path. I wrote the Caddy side to do exactly the same four things, then tested both the same way.
The config did get shorter
Stripped of blank lines and lone braces, the nginx config is 18 lines. The Caddy version that reproduces logging, the redirect, gzip, and the static route is 11 lines — about 39% shorter. That's a real difference and it holds even after I'd gone back and fixed two things I'd missed the first time (below). But it comes with an asterisk: it doesn't include rate limiting, because the stock Caddy image can't do that at all. More on that in a minute.
| nginx.conf | Caddyfile | |
|---|---|---|
| meaningful lines | 18 | 11 |
| needs explicit access logging | no (logs by default) | yes, see below |
| handles the rate limit | yes | no, not without a custom build |
The redirect that silently stopped working
nginx's return 301 /api/ping; inside a location /old-path block is about as simple as a redirect gets. I translated it the way it reads: put the target path in a handle /old-path block and tell Caddy to redirect.
handle /old-path { redir /api/ping 301 } curl -D- http://localhost:18081/old-path came back 200 OK, empty body. No redirect, no error, nothing in the logs to say why.
The reason is that redir's first argument isn't the destination unless you've already consumed the path matcher some other way. Caddy's own caddy adapt showed what my config actually compiled to: a redirect that only fires if the request path is also /api/ping, which it never is once you're already inside a handle /old-path block. Nested like that, the directive just has nothing to match, and Caddy falls through to an empty 200.
The fix was to stop nesting it and let redir take the path itself as its own matcher:
redir /old-path /api/ping 301 That one came back 301 Moved Permanently with the right Location header. Functionally the same intention, structurally almost the opposite shape, and the broken version gives you no signal that anything is wrong beyond "that link doesn't redirect."
What a Caddyfile doesn't log unless you ask
I'd assumed access logging was a given, the way it is on nginx's official image, where every request shows up in docker logs without you writing a single line for it. To check properly rather than just believe it, I tagged each test request with a unique marker in the query string, then grepped for that exact marker in each container's logs.
nginx, marker probe-1796534729-nginx, request sent, then grep against docker logs:
172.18.0.1 - - [06/Dec/2026:05:25:29 +0000] "GET /static/app.js?marker=probe-1796534729-nginx HTTP/1.1" 200 296669 "-" "curl/8.5.0" There it is, immediately, no config written for it.
Caddy, same test, Caddyfile with no log directive, marker probe-1796534742-caddy-nolog. The request itself came back status=200, full 296,669 bytes, so it was genuinely served. The grep for that marker against the container's entire log history, from startup onward:
0 Nothing. Not a trimmed line, not a warning, zero matches anywhere in the log. The only lines Caddy had written were its own startup and certificate-maintenance housekeeping.
Adding one word fixed it:
:8080 { encode gzip log ... } With log present, I ran the same marker test a third time and the request showed up as a structured JSON line with status, duration, bytes and headers, marker included in the logged URI. Without it, the identical request left no trace I could find anywhere in the container. If you're moving a production nginx config across and you don't know to add this, you don't lose logging with an error, you lose it with silence. The config line counts above already include this fix, which is also why my first line-count pass, before I noticed the missing logs, said 10 lines instead of 11.
The rate limit nginx can enforce, and Caddy can't
My nginx config rate-limits /api/ to 5 requests a second with a burst of 10, nodelay. I fired 30 concurrent requests at it and counted responses:
fired 30 concurrent requests in 0.077s wall time 200: 11 503: 19 Eleven through, nineteen rejected. nginx's docs describe burst=10 as a queue of up to 10 requests it'll let through beyond the steady rate before it starts rejecting; add the one request that would've gone through at the steady rate anyway and you get 11, which is exactly what I measured.
I tried to set up the same thing on Caddy with a rate_limit block, because that's the directive name the third-party caddy-ratelimit module uses:
{"level":"error","ts":1796533865.40995,"msg":"parsing caddyfile tokens for 'handle': unrecognized directive: rate_limit - are you sure your Caddyfile structure (nesting and braces) is correct?, at /etc/caddy/Caddyfile:11"} The stock caddy:2.11-alpine image doesn't ship that module. Getting it requires building a custom binary with xcaddy and the caddy-ratelimit plugin added in. I didn't get to actually build and test that image this run, so I'm not going to claim it works or report a cost for it, only that the plain image, the one most people actually pull, has no rate limiting at all. If your nginx config leans on limit_req the way mine does, that's not a line-for-line migration, it's a decision to either build your own Caddy or do without.
Serving the same file, roughly the same speed
For the one thing both could do identically, serving a gzip-compressed static file, I ran the same client against both three times each: 1,500 requests, 30 concurrent, same machine, same file.
| trial 1 | trial 2 | trial 3 | |
|---|---|---|---|
| nginx req/s | 1125 | 1217 | 1177 |
| Caddy req/s | 1090 | 1079 | 1122 |
nginx came out ahead every time, by between 3% and 13% depending on the trial, averaging about 7% faster across the three. I want to be honest about what this number actually measures: my test client opens a fresh connection per request rather than reusing one, so some of this is connection overhead on my side, not pure server throughput. What it does tell me cleanly is that Caddy isn't faster at this, and the compressed output size was close either way: nginx sent 24,662 bytes for the gzipped file against Caddy's 23,973, out of a 296,669-byte original.
Memory told a clearer story, and this time I took three readings instead of trusting one. Idle, five seconds apart, all three identical:
nginx-test 4.504MiB caddy-test 10.13MiB That's about 2.25 times as much, at rest, serving nothing. After three separate load runs (1,500 requests each, fresh snapshot right after):
nginx caddy trial 1 5.234MiB 17.79MiB trial 2 4.984MiB 17.53MiB trial 3 5.129MiB 20.92MiB nginx barely moved. Caddy's gap grew to roughly 3.7 times nginx's average, and its process count rose from 9 to 12-13 while nginx's stayed at 5 the whole time, which points at connection-handling overhead that scales with load rather than a fixed cost. Some of Caddy's baseline is specific subsystems nginx doesn't run at all here — a certificate-maintenance goroutine and an admin API, both idling with nothing to do on a plain HTTP site on port 8080 — so I can't cleanly separate "Caddy's runtime is heavier" from "I'm paying for machinery this config never uses." Both are true to some extent; I just can't tell you the split. What I can say is the gap is real, it isn't fixed, and it gets worse, not better, once traffic shows up.
What I got wrong on the way
I wrote handle /old-path { redir /api/ping 301 }, looked at it, decided it was obviously right, and almost moved straight on to the next route without curling it. What stopped me was a rule I'd set for myself before I started: every route gets an actual request, config be damned. That same rule is the only reason I caught the missing logs too — if I'd gone by what the Caddyfile said rather than what the container actually did, both of these would have gone out quietly, and nothing in either config would have told me they were wrong.
Run it yourself
This is a minimal version of both proxies, each pointed at its own backend, plus the burst test against nginx's rate limit. The exact split between 200s and 503s will shift by a request or two between runs depending on timing, but you should see most of 30 concurrent requests rejected.
cd "$(mktemp -d)" cat > nginx.conf <<'EOF' events {} http { limit_req_zone $binary_remote_addr zone=api_limit:10m rate=5r/s; server { listen 8080; location /api/ { limit_req zone=api_limit burst=10 nodelay; proxy_pass http://backend-n:5000/api/; } } } EOF cat > Caddyfile <<'EOF' :8080 { log handle /api/* { reverse_proxy backend-c:5000 } } EOF BACKEND=' import http.server, socketserver class H(http.server.BaseHTTPRequestHandler): def do_GET(self): self.send_response(200); self.end_headers() def log_message(self, *a): pass socketserver.ThreadingTCPServer(("0.0.0.0", 5000), H).serve_forever() ' docker network create net-nginx; docker network create net-caddy docker run -d --name backend-n --network net-nginx python:3.13-slim python -c "$BACKEND" docker run -d --name backend-c --network net-caddy python:3.13-slim python -c "$BACKEND" docker run -d --name nginx-test --network net-nginx -p 18080:8080 -v "$PWD/nginx.conf:/etc/nginx/nginx.conf:ro" nginx:1.29-alpine docker run -d --name caddy-test --network net-caddy -p 18081:8080 -v "$PWD/Caddyfile:/etc/caddy/Caddyfile:ro" caddy:2.11-alpine sleep 2 echo "nginx /api/ping: $(curl -s -o /dev/null -w '%{http_code}' http://localhost:18080/api/ping)" echo "caddy /api/ping: $(curl -s -o /dev/null -w '%{http_code}' http://localhost:18081/api/ping)" python3 - <<'PY' import concurrent.futures, urllib.request from collections import Counter def one(i): try: return urllib.request.urlopen("http://localhost:18080/api/ping", timeout=5).status except Exception as e: return getattr(e, "code", "ERR") with concurrent.futures.ThreadPoolExecutor(30) as ex: print("nginx burst (30 concurrent):", Counter(ex.map(one, range(30)))) PY When I ran this exact script to check it before posting, both proxies answered their /api/ping with 200, and the burst test came back Counter({503: 20, 200: 10}) — one fewer through than the 11 I measured earlier in the main test, which is the kind of request-timing noise you should expect from burst at these speeds, not a different result.
What I'd actually do
This was one small config: a proxy route, a static folder, a redirect, a rate limit. I'm not calling that a verdict on nginx against Caddy in general, just on moving this. But if I were moving a real nginx config to Caddy today, I'd treat every directive as something to verify by request, not by reading, because the two failures I hit here both returned valid HTTP and no error. I'd keep nginx for anything that depends on limit_req, unless I was willing to maintain a custom Caddy build. And I'd put log at the top of every Caddyfile block before writing anything else, the same way I'd never ship an nginx config without checking where its access log goes. The shorter file was real. It just wasn't the whole story.
