While Nginx has been the traditional workhorse for reverse proxies, Caddy has emerged as the developer favorite due to one killer feature: automatic HTTPS by default. Caddy provisions, renews, and staples OCSP certificates out of the box without Certbot or cron jobs.
Step 1: Point Your Subdomain to Server IP
In your Devs.Surf DNS Manager, add an A Record pointing to your server's public IP address:
- Type:
A - Name:
@ - Content:
YOUR_SERVER_PUBLIC_IP - TTL:
3600
Step 2: Docker Compose Setup
Here is a complete, production-ready docker-compose.yml file pairing Caddy with a backend container:
version: "3.8"
services:
caddy:
image: caddy:2-alpine
restart: unless-stopped
ports:
- "80:80"
- "443:443"
- "443:443/udp" # HTTP/3 QUIC
volumes:
- ./Caddyfile:/etc/caddy/Caddyfile:ro
- caddy_data:/data
- caddy_config:/config
app:
image: node:20-alpine
command: sh -c "npx serve -s /app -l 3000"
volumes:
- ./dist:/app:ro
expose:
- "3000"
volumes:
caddy_data:
caddy_config:
Step 3: The 3-Line Caddyfile
Create a file named Caddyfile in the same folder:
myproject.devs.surf {
reverse_proxy app:3000
}
Step 4: Launch and Observe
Run docker compose up -d. Caddy immediately requests a TLS certificate from Let's Encrypt for myproject.devs.surf. In under 15 seconds, your application is live over HTTPS with HTTP/3 support.