Loading…
Loading documentation...
Terminate HTTPS automatically and pass X-Forwarded headers, trusted proxy ranges, large upload streams, and WebSocket upgrades with Caddy or Traefik.
Commands checked on 2026-11-23 with Caddy 2.9+, Traefik v3.2+, Docker Compose v2, Ubuntu 24.04.
A production-ready reverse proxy fronting Docker services with automated Let's Encrypt TLS, preserved client IP headers (X-Forwarded-For, X-Forwarded-Proto), working WebSocket upgrades, and clear separation between public and internal bridge networks.
A/AAAA records pointing app.YOUR_DOMAIN to the server's public IP; see Managed Docker first stack.80/tcp and 443/tcp open cleanly on host DOCKER-USER as shown in Fix Docker UFW bypasses with DOCKER-USER and nftables.Split reverse-proxied app ports from database networks so Postgres, Redis, and Ollama never sit on the proxy bridge:
docker network create proxy_net
In your stack's docker-compose.yml, attach public-facing web containers to both proxy_net and a stack-local internal: true network.
Caddy automatically forwards X-Forwarded-For, X-Forwarded-Proto, X-Forwarded-Host, and upgrades WebSockets out of the box. When placing Caddy behind Cloudflare or an upstream L7 proxy, configure trusted_proxies globally so real visitor IPs are preserved instead of rewritten:
{
email admin@YOUR_DOMAIN
servers {
trusted_proxies static private_ranges
client_ip_headers X-Forwarded-For CF-Connecting-IP
}
}
app.YOUR_DOMAIN {
encode zstd gzip
reverse_proxy app-service:3000 {
flush_interval -1
transport http {
dial_timeout 10s
response_header_timeout 120s
}
}
header {
Strict-Transport-Security "max-age=31536000; includeSubDomains"
X-Content-Type-Options "nosniff"
X-Frame-Options "SAMEORIGIN"
Referrer-Policy "strict-origin-when-cross-origin"
-Server
}
}
Use flush_interval -1 for AI streaming (SSE), Next.js streaming responses, n8n, or terminal consoles so chunks reach the browser immediately without proxy buffering.
services:
caddy:
image: caddy:2.9-alpine
container_name: edge-caddy
restart: unless-stopped
ports:
- "80:80"
- "443:443"
- "443:443/udp"
volumes:
- ./Caddyfile:/etc/caddy/Caddyfile:ro
- caddy_data:/data
- caddy_config:/config
networks:
- proxy_net
networks:
proxy_net:
external: true
volumes:
caddy_data:
caddy_config:
When using Traefik v3 via labels, pin docker.network=proxy_net explicitly so multi-homed containers never route to an isolated internal subnet IP:
services:
immich-server:
image: ghcr.io/immich-app/immich-server:release
networks:
- proxy_net
- internal_net
labels:
- "traefik.enable=true"
- "traefik.docker.network=proxy_net"
- "traefik.http.routers.immich.rule=Host(`photos.YOUR_DOMAIN`)"
- "traefik.http.routers.immich.entrypoints=websecure"
- "traefik.http.routers.immich.tls.certresolver=letsencrypt"
- "traefik.http.services.immich.loadbalancer.server.port=2283"
Extend Traefik --entrypoints.websecure.transport.respondingTimeouts.readTimeout=600s when serving multi-gigabyte media uploads (Immich, Nextcloud, Seafile).
Validate Caddy syntax, reload safely, and verify HTTP-to-HTTPS redirect and WebSocket/TLS headers from outside:
docker exec edge-caddy caddy validate --config /etc/caddy/Caddyfile
docker exec edge-caddy caddy reload --config /etc/caddy/Caddyfile
curl -sIL https://app.YOUR_DOMAIN
You should observe HTTP/2 200 (or expected app redirect) plus strict-transport-security and x-content-type-options: nosniff.
internal_net IP it cannot reach, or the app is bound to 127.0.0.1 inside its container instead of 0.0.0.0. Set traefik.docker.network=proxy_net and ensure upstream services listen on 0.0.0.0.172.x.0.1 instead of real client IPs or trigger redirect loops. The backend app doesn't trust the proxy subnet. Add 172.16.0.0/12 to the app's trusted_proxies / TRUSTED_PROXY_CIDRS.client_max_body_size 0; and proxy_request_buffering off;; on Cloudflare-proxied uploads keep chunks under 100 MB (Nextcloud/Immich clients auto-chunk)./data in Caddy (or acme.json 0600 in Traefik) so ACME certificates survive container recreation without hitting Let's Encrypt rate limits.Caddyfile readable only by root and mount :ro inside the proxy container.trusted_proxies configs before enabling external registrations.Every Servers Are Up virtual machine and container includes an integrated HTML5 browser-based SSH, RDP, and VNC console in your dashboard, default-off inbound firewall rules with per-IP allow-lists, and full programmatic control via REST API v1 and Model Context Protocol (MCP). Explore our Virtual Datacenter Plans or reach out to Servers Are Up Support.