Nginx vs Traefik vs Caddy: Which Reverse Proxy Should You Pick for Microservices?
Published by InstaDevOps. Updated . Primary documentation and example limitations are noted below.
Free DevOps Audit Checklist
Get our comprehensive checklist to identify gaps in your infrastructure, security, and deployment processes
Introduction
Choosing a reverse proxy is one of those decisions that seems trivial until you're debugging TLS certificate renewals at 2 AM or trying to figure out why your service discovery isn't propagating. If you're running microservices, your reverse proxy is the front door to everything - and picking the wrong one can cost you weeks of configuration headaches.
Here, we'll do a hands-on comparison of the three most popular reverse proxies in the modern DevOps stack: Nginx, Traefik, and Caddy. We'll look at configuration complexity, automatic TLS, service discovery, performance characteristics, and when each one makes sense.
No fluff. Just real configs, real trade-offs, and a clear recommendation based on your use case.
The Contenders at a Glance
Before we dive in, here's a quick snapshot:
| Feature | Nginx | Traefik | Caddy |
|---|---|---|---|
| Language | C | Go | Go |
| Config Format | Custom DSL | YAML/TOML/Labels | Caddyfile/JSON |
| Auto TLS | Separate ACME client or module, depending on build | Built-in (Let's Encrypt) | Built-in (Let's Encrypt + ZeroSSL) |
| Service Discovery | Manual/scripted | Native (Docker, K8s, Consul) | Configured upstreams or dynamic upstream modules |
| Hot Reload | nginx -s reload |
Provider-driven | caddy reload or configuration API |
| Dashboard | Nginx Plus only | Built-in | Via API |
| Memory Footprint | Measure with your build and workload | Measure with your providers and workload | Measure with your modules and workload |
Nginx has been the default choice for over a decade. Traefik was built specifically for dynamic microservice environments. Caddy focuses on simplicity and security-by-default.
Example scope: Configuration sketches use NGINX with the HTTP/2 directive available since 1.25.1, Traefik v3 and Caddy v2 syntax. They are not a tested production bundle or a benchmark. Choose maintained patch versions, record them with your test results, and validate the complete configuration before deployment.
Configuration Complexity
This is where the differences hit you first. Let's set up a simple reverse proxy with TLS for two services: an API on port 3000 and a frontend on port 8080.
Nginx:
server {
listen 80;
server_name api.example.com;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl;
http2 on;
server_name api.example.com;
ssl_certificate /etc/letsencrypt/live/api.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/api.example.com/privkey.pem;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers HIGH:!aNULL:!MD5;
location / {
proxy_pass http://localhost:3000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
server {
listen 443 ssl;
http2 on;
server_name app.example.com;
ssl_certificate /etc/letsencrypt/live/app.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/app.example.com/privkey.pem;
location / {
proxy_pass http://localhost:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}
This NGINX example assumes certificates already exist at the configured paths. If using Certbot, configure renewal and a successful-renewal reload hook. Other ACME integrations depend on the modules included in your build. Validate with nginx -t before reloading.
Traefik (docker-compose labels):
services:
traefik:
image: traefik:${TRAEFIK_VERSION:?Set a reviewed Traefik v3 patch version}
command:
- "--providers.docker=true"
- "--providers.docker.exposedbydefault=false"
- "--entrypoints.web.address=:80"
- "--entrypoints.websecure.address=:443"
- "--certificatesresolvers.letsencrypt.acme.email=you@example.com"
- "--certificatesresolvers.letsencrypt.acme.storage=/acme/acme.json"
- "--certificatesresolvers.letsencrypt.acme.httpchallenge.entrypoint=web"
ports:
- "80:80"
- "443:443"
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- ./acme:/acme
api:
image: my-api:latest
labels:
- "traefik.http.routers.api.rule=Host(`api.example.com`)"
- "traefik.enable=true"
- "traefik.http.routers.api.entrypoints=websecure"
- "traefik.http.routers.api.tls.certresolver=letsencrypt"
- "traefik.http.services.api.loadbalancer.server.port=3000"
frontend:
image: my-frontend:latest
labels:
- "traefik.http.routers.frontend.rule=Host(`app.example.com`)"
- "traefik.enable=true"
- "traefik.http.routers.frontend.entrypoints=websecure"
- "traefik.http.routers.frontend.tls.certresolver=letsencrypt"
- "traefik.http.services.frontend.loadbalancer.server.port=8080"
Set TRAEFIK_VERSION to a patch version you have reviewed. The application images are placeholders. Persist and protect ACME storage, and restrict Docker API access: a read-only socket mount does not make the API read-only. See the Docker provider security guidance.
Caddy (Caddyfile):
api.example.com {
reverse_proxy localhost:3000
}
app.example.com {
reverse_proxy localhost:8080
}
That's it. Caddy automatically provisions TLS certificates, redirects HTTP to HTTPS, and enables HTTP/2. Two lines per service.
Automatic TLS and Certificate Management
Certificate lifecycle is an operational responsibility with every proxy. Compare how each obtains, stores and renews certificates, and how failures reach your alerts.
Caddy obtains certificates from Let's Encrypt and ZeroSSL automatically. It handles renewal, OCSP stapling, and even falls back to a secondary CA if the primary is down. Public DNS, reachable challenge endpoints and persistent writable storage must be configured. Caddy documents the requirements and staging-CA setup.
Traefik supports Let's Encrypt via ACME with HTTP-01 and DNS-01 challenges. DNS-01 is crucial if you're behind a load balancer or need wildcard certificates. Configuration looks like:
certificatesResolvers:
letsencrypt:
acme:
email: ops@example.com
storage: /acme/acme.json
dnsChallenge:
provider: cloudflare
resolvers:
- "1.1.1.1:53"
Nginx in this example loads certificate files managed separately. Match the renewal method to your installed modules, then test that a renewed certificate is actually served to clients.
Verdict: If automatic TLS matters to you (it should), Caddy wins on simplicity and Traefik wins on flexibility. Nginx is manageable but requires more operational overhead.
Service Discovery and Dynamic Configuration
This is where Traefik pulls ahead for container-heavy environments.
Traefik natively watches Docker labels, Kubernetes Ingress resources, Consul catalogs, etcd, and more. When a new container spins up with the right labels, Traefik picks it up immediately - no restart, no reload, no config file change. This is incredibly powerful for dynamic environments where services scale up and down frequently.
Caddy has an API for dynamic configuration but doesn't natively integrate with container orchestrators the way Traefik does. You can use caddy-docker-proxy (community plugin) to get Docker label support, but it's not first-party.
Nginx is static by default. You change a file, you reload. Tools like consul-template or nginx-proxy (jwilder) exist to generate configs dynamically, but they're external tools bolted on.
For Kubernetes, compare supported controller implementations separately from their underlying proxy engines. Community Ingress NGINX retirement does not mean the NGINX server itself is retired. Use our Ingress NGINX migration acceptance checklist to test route behavior before changing controllers.
Performance: build a comparison you can reproduce
There is no universal requests-per-second winner for your workload. We have removed the earlier numerical comparison because it did not include a reproducible harness, exact versions or hardware. Treat performance as a measured acceptance criterion.
- Use the same upstream, payloads, CPU and memory limits, TLS settings and network path for each proxy.
- Record image digests, configuration, load-generator version, warm-up and run duration. Test more than one concurrency level.
- Measure successful throughput, errors and p95/p99 latency together. Include CPU, memory, long-lived connections and a slow upstream.
- Repeat each run and keep raw results. An error-heavy run is not a throughput win.
Our k6 guide explains how to turn a workload into a repeatable test. Use a staging target you control and a defined load limit.
Middleware and Advanced Features
All three support common middleware patterns, but the implementation differs.
Rate limiting:
# Nginx
http {
limit_req_zone $binary_remote_addr zone=api:10m rate=10r/s;
server {
location /api/ {
limit_req zone=api burst=20 nodelay;
proxy_pass http://backend;
}
}
}
# Traefik (middleware via labels)
labels:
- "traefik.http.middlewares.ratelimit.ratelimit.average=10"
- "traefik.http.middlewares.ratelimit.ratelimit.burst=20"
- "traefik.http.routers.api.middlewares=ratelimit"
Caddy: Rate limiting is not a standard Caddyfile directive. Select and review a compatible module or enforce limits upstream. Do not paste a generic rate_limit block into a stock build; check the standard directive list and your installed modules.
Authentication, compression, headers, CORS - all three handle these well. Traefik has the concept of middleware chains that you can compose and reuse across routers, which is elegant for complex setups. Nginx has the most extensive third-party module ecosystem. Caddy has a growing plugin system but fewer options overall.
When to Use Each
Choose Nginx when:
- Your own workload measurements and required modules favor NGINX
- You have a static infrastructure that doesn't change often
- Your team already knows Nginx configuration well
- You need advanced features like TCP/UDP proxying, custom Lua scripting, or GeoIP
- You're running on resource-constrained hardware
Choose Traefik when:
- You're running Docker or Kubernetes with frequently changing services
- You want automatic service discovery without config file management
- You need the built-in dashboard for visibility into routing
- You're using multiple orchestration platforms (Docker + Consul, for example)
- Your microservices scale up and down dynamically
Choose Caddy when:
- You want the simplest possible setup with automatic HTTPS
- You're a small team that doesn't want to maintain proxy configuration
- You're running a handful of services that don't change often
- You want a single binary with no external dependencies
- You value security defaults (HTTPS everywhere, modern TLS settings out of the box)
Migration Tips
If you're switching from Nginx to Traefik or Caddy, here's what to watch for:
Upstream health checks - Nginx does passive health checks by default; Traefik and Caddy have active health check options that behave differently. Test failover behavior.
Websocket proxying - Nginx needs explicit
proxy_set_header UpgradeandConnectionheaders. Caddy and Traefik handle websockets transparently.Custom error pages - Each proxy handles error responses differently. Test your 502/503 pages after migration.
Logging format - If you're parsing access logs with Loki/ELK, your log format will change. Update your parsers before switching.
Certificate storage - Plan whether to import existing certificates or issue new ones. Caddy supports explicit certificate and key files. Test issuance against staging and check current CA rate limits before cutover.
Proxy migration acceptance checklist
For each critical route, record the expected upstream, status code, authentication result and forwarded headers. Verify HTTP redirects, TLS hostnames and renewal, WebSockets or gRPC where used, unknown paths and upstream failures. Name the person who can roll back and keep the previous configuration until the new path passes the checks.
Primary references and further reading
Keep reading
Want this handled for you?
Explore scoped projects and ongoing support for this kind of infrastructure work.
Never Miss an Update
Get the latest DevOps insights, tutorials, and best practices delivered straight to your inbox. Practical guidance for running and improving your infrastructure.