# Replace 'yourdomain.com' with your actual domain yourdomain.com { # Enable automatic HTTPS with Let's Encrypt tls { # Email for Let's Encrypt notifications email admin@yourdomain.com } # Reverse proxy to backend reverse_proxy backend:8000 { header_up X-Real-IP {remote} header_up X-Forwarded-For {remote} header_up X-Forwarded-Proto {scheme} } # Enable gzip compression encode gzip # Logging log { output file /var/log/caddy/access.log format json } # Security headers header { # Enable HSTS Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" # Prevent clickjacking X-Frame-Options "SAMEORIGIN" # XSS protection X-Content-Type-Options "nosniff" # Referrer policy Referrer-Policy "strict-origin-when-cross-origin" # Remove server header -Server } } # Optional: Redirect www to non-www www.yourdomain.com { redir https://yourdomain.com{uri} permanent }