Choosing a reverse proxy is one of the first infrastructure decisions for any web application. Nginx, Caddy, and Traefik each take a different approach.
Quick Comparison
| Feature | Nginx | Caddy | Traefik |
|---|---|---|---|
| Auto HTTPS | No (needs certbot) | Yes (built-in) | Yes (built-in) |
| Config format | Custom syntax | Caddyfile / JSON | YAML / TOML / labels |
| Docker integration | Manual config | Manual config | Automatic (labels) |
| Performance | Excellent | Very good | Good |
| Memory usage | Low | Low | Medium |
| Learning curve | Medium | Low | Medium |
| Kubernetes ingress | nginx-ingress | Not common | Traefik ingress |
Nginx
The industry standard. Powers ~34% of all websites.
# /etc/nginx/sites-available/app
server {
listen 80;
server_name app.example.com;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl http2;
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: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;
}
location /api {
proxy_pass http://localhost:8080;
}
# Static files with caching
location /static {
alias /var/www/static;
expires 1y;
add_header Cache-Control "public, immutable";
}
}Pros: Battle-tested, highest performance, most documentation, excellent for static files Cons: No auto-HTTPS, config reload required for changes, verbose configuration
Master this topic with hands-on labs
Go beyond reading — build real projects in sandboxed environments with expert video guidance.
Browse Courses →Caddy
Automatic HTTPS with zero configuration:
# Caddyfile
app.example.com {
reverse_proxy localhost:3000
}
api.example.com {
reverse_proxy localhost:8080
}
static.example.com {
root * /var/www/static
file_server
header Cache-Control "public, max-age=31536000, immutable"
}That is the entire configuration. Caddy automatically: - Obtains Let's Encrypt certificates - Redirects HTTP → HTTPS - Renews certificates before expiry - Enables HTTP/2 and HTTP/3
Pros: Simplest config, auto-HTTPS, HTTP/3, single binary, great for small-medium deployments Cons: Smaller ecosystem, less documentation than Nginx, not as fast under extreme load
Traefik
Built for containers and microservices:
# docker-compose.yml
services:
traefik:
image: traefik:v3
command:
- --providers.docker=true
- --entrypoints.web.address=:80
- --entrypoints.websecure.address=:443
- --certificatesresolvers.le.acme.email=admin@example.com
- --certificatesresolvers.le.acme.storage=/acme.json
- --certificatesresolvers.le.acme.tlschallenge=true
ports:
- "80:80"
- "443:443"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ./acme.json:/acme.json
web:
image: my-web-app
labels:
- "traefik.http.routers.web.rule=Host(`app.example.com`)"
- "traefik.http.routers.web.tls.certresolver=le"
api:
image: my-api
labels:
- "traefik.http.routers.api.rule=Host(`api.example.com`)"
- "traefik.http.routers.api.tls.certresolver=le"Add a new service → Traefik discovers it automatically via Docker labels. No config reload, no restart.
Pros: Auto-discovery from Docker/Kubernetes, auto-HTTPS, dashboard, middleware ecosystem Cons: Docker socket access is a security concern, more complex config for non-container use, higher memory usage
Get weekly IT automation tips
Docker, Ansible, Terraform, MLOps — curated insights delivered to your inbox. No spam.
Subscribe Free →When to Use Each
| Scenario | Best Choice | Why |
|---|---|---|
| High-traffic static site | Nginx | Best static file performance |
| Simple reverse proxy | Caddy | Easiest config, auto-HTTPS |
| Docker Compose stack | Traefik | Auto-discovery, no config per service |
| Kubernetes ingress | Traefik or Nginx | Both have mature ingress controllers |
| Legacy/enterprise | Nginx | Most teams already know it |
| Personal projects | Caddy | Zero-config HTTPS, single binary |
| Microservices platform | Traefik | Dynamic service discovery |
Load Balancing
Nginx
upstream backend {
server 10.0.1.10:3000 weight=3;
server 10.0.1.11:3000;
server 10.0.1.12:3000 backup;
}
server {
location / {
proxy_pass http://backend;
}
}Caddy
app.example.com {
reverse_proxy 10.0.1.10:3000 10.0.1.11:3000 {
lb_policy round_robin
health_uri /health
health_interval 10s
}
}Traefik
# Automatic — scales with Docker replicas
services:
web:
image: my-app
deploy:
replicas: 3
labels:
- "traefik.http.services.web.loadbalancer.server.port=3000"
- "traefik.http.services.web.loadbalancer.healthcheck.path=/health"What's Next?
Our Docker Fundamentals course covers reverse proxy patterns with containerized applications. Our Terraform for Beginners course teaches infrastructure provisioning including load balancer setup. First lessons are free. -e ---
Ready to go deeper? Explore our hands-on DevOps courses — practical labs covering Docker, Ansible, Terraform, and more.
Ready to learn by doing?
Stop reading tutorials — start building. Expert video courses with hands-on labs in real sandboxed environments.
Related Articles
Nginx Reverse Proxy Configuration
Configure Nginx as a production reverse proxy. Upstream pools, load balancing, SSL termination, caching, and rate limiting.
SELinux for Apache and PHP-FPM
Configure Apache with PHP-FPM over TCP on RHEL with SELinux enforcing. Diagnose and fix name_connect denials using the correct SELinux boolean and audit tools.
Fix SELinux Apache Custom Webroot
Step-by-step guide to fix SELinux 403 Forbidden errors when using a custom Apache DocumentRoot like /srv/webroot on RHEL.
Nix Package Manager for DevOps
Nix creates reproducible development environments that work the same on every machine. Learn how to use Nix for DevOps: dev shells, Docker images, CI.
NixOS: Reproducible Linux Builds
NixOS uses declarative configuration and the Nix package manager to create fully reproducible systems. Learn what makes it unique and who it's for.
Observability vs Monitoring Explained
The three pillars of observability. Metrics, logs, and distributed traces with OpenTelemetry, Prometheus, Grafana, and Jaeger.
Explore topics
Browse more articles on the topics covered here.