The Free Encyclopedia

Reverse Proxy with Caddy and Nginx

A reverse proxy sits in front of your services, routing requests by hostname/path and terminating TLS — so many apps share ports 80/443 behind clean URLs.

Caddy — automatic HTTPS

Caddy's killer feature: it gets and renews Let's Encrypt certs automatically.

# Caddyfile
app.example.com {
    reverse_proxy 127.0.0.1:8080
}
git.example.com {
    reverse_proxy 127.0.0.1:3000
}

Nginx — the workhorse

server {
    server_name app.example.com;
    location / {
        proxy_pass http://127.0.0.1:8080;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}

Which to use

Caddy Nginx
Auto-HTTPS, tiny config Manual certs, more verbose
Great for home labs Ubiquitous, max control/perf

Behind Cloudflare? You can skip origin TLS and let the edge handle it — see Hosting Many Sites Behind One Cloudflare Tunnel and Apache Name-Based Virtual Hosts on One Server.

Related: TLS Automation with Let's Encrypt · Docker Compose for Self-Hosting · Apache Name-Based Virtual Hosts on One Server