Deployment
devopsdeploymentCore ConceptIntermediate
Reverse Proxies: Nginx, Caddy & Load Balancing
Complete guide to reverse proxies, SSL termination, static asset offloading, gzip/brotli compression, rate limiting, and backend load balancing.
Verified: 2026-09-30
Tested on:nginx 1.26.x, caddy 2.8.x
Platforms:
linux
#reverse-proxy#nginx#caddy#networking#devops
A Reverse Proxy sits in front of one or more backend web servers and intercepts all incoming client requests before routing them to the appropriate application process.
Architecture Diagram
Internet Clients
│ (HTTPS on Port 443)
▼
┌─────────────────────────────────────────────────────────────┐
│ Reverse Proxy (Nginx / Caddy / Traefik) │
│ - SSL / TLS Termination │
│ - Gzip & Brotli Compression │
│ - Rate Limiting & DDoS Shield │
│ - Serves /static files directly from disk │
└─────────────────────────────────────────────────────────────┘
│ (HTTP on localhost:3000, 3001, 3002)
▼
┌─────────────────────────────────────────────────────────────┐
│ Backend Application Servers (Node.js, Go, Python, Next.js) │
└─────────────────────────────────────────────────────────────┘Why Never Expose Node.js Directly to the Internet
- Slow Client Attacks: Node.js single-threaded event loop can be bogged down by slow network connections. Nginx buffers incoming requests and sends complete payloads to Node.js at internal network speeds.
- Privileged Port Binding: Binding to port 80/443 requires root privileges. Running Node.js as root is a major security risk; running Nginx on 80/443 allows Node.js to run as an unprivileged user on port 3000.
- High-Performance Static File Serving: Nginx uses the Linux kernel
sendfilesyscall to stream static images, CSS, and JS directly from disk with zero Node.js memory overhead.
Popular Reverse Proxy Options
| Reverse Proxy | Language | SSL Setup | Configuration Style |
|---|---|---|---|
| Nginx | C | Certbot required | Block-based imperative syntax (nginx.conf) |
| Caddy | Go | Automatic built-in HTTPS | Clean, human-readable Caddyfile |
| Traefik | Go | Automatic built-in HTTPS | Dynamic label-based config for Docker / K8s |
| HAProxy | C | Manual or Certbot | High-throughput Layer 4 / Layer 7 load balancer |
Related Guides
HTTPS, TLS Certificates & Let's Encrypt
Complete guide to securing web traffic with HTTPS, TLS 1.3 handshakes, Let's Encrypt ACME automated certificates, and HTTP Strict Transport Security (HSTS).
Process Managers: systemd vs. PM2
Complete guide to background process management in production, auto-restarts, startup on boot, cluster mode, and comparing systemd with PM2.