Production Caddyfile Reverse Proxy with Automatic HTTPS
# Global Caddy Configuration
{
email ops@example.com
admin off
}
# Production Domain Reverse Proxy
example.com {
# Automatic TLS and HTTP to HTTPS redirection is built-in
# Security & Protection Headers
header {
Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"
X-Content-Type-Options "nosniff"
X-Frame-Options "DENY"
Referrer-Policy "strict-origin-when-cross-origin"
Permissions-Policy "camera=(), microphone=(), geolocation=()"
-Server
}
# Compression (Zstandard & Gzip)
encode zstd gzip
# Static Assets Caching
@static {
file
path *.css *.js *.svg *.ico *.woff2
}
header @static Cache-Control "public, max-age=31536000, immutable"
# Reverse Proxy to Internal Node.js / Web Application
reverse_proxy 127.0.0.1:3000 {
header_up Host {host}
header_up X-Real-IP {remote_host}
header_up X-Forwarded-Proto {scheme}
# Health Check and Load Balancing
health_timeout 5s
max_fails 3
}
}