The live Caddy was returning a blank page (NOP, status 0) because its site block had no responder \u2014 no reverse_proxy to the blog. This adds a known-good HTTP-only Caddyfile matching the actual topology (Cloudflare terminates TLS -> Caddy :80 -> SWS blog:80): - reverse_proxy blog:80 (the missing responder that caused the blank page) - encode zstd gzip (fixes: origin was serving everything uncompressed) - security headers (fixes: HSTS/X-Frame-Options/etc were absent) - trusted_proxies + client_ip_headers for correct Cloudflare visitor IPs - http:// scheme so Caddy does not try to provision TLS (Cloudflare does) Validated + fmt-clean against the caddy-cf image; tested end-to-end locally (Caddy -> SWS) returning HTTP 200 with gzip and headers.
47 lines
1.6 KiB
Caddyfile
47 lines
1.6 KiB
Caddyfile
# Caddyfile for the blog behind Cloudflare.
|
|
#
|
|
# Topology: Cloudflare (terminates TLS) -> Caddy (HTTP :80) -> SWS (blog:80)
|
|
#
|
|
# Cloudflare handles the public HTTPS cert, so Caddy serves plain HTTP on :80
|
|
# and does NOT need the Cloudflare DNS-01 / automatic-HTTPS setup. Set the
|
|
# Cloudflare SSL/TLS mode to "Full" so CF->origin is encrypted at the network
|
|
# layer (e.g. over your tunnel/Netbird), even though this listener is HTTP.
|
|
#
|
|
# Copy this file to /etc/caddy/Caddyfile on the caddy_cf host and reload:
|
|
# docker exec caddy_cf caddy reload --config /etc/caddy/Caddyfile
|
|
# or restart the container.
|
|
{
|
|
# Trust Cloudflare so real visitor IPs (Cf-Connecting-Ip / X-Forwarded-For)
|
|
# are used for logging and remote_ip matchers instead of the CF edge IP.
|
|
servers {
|
|
trusted_proxies static private_ranges
|
|
client_ip_headers Cf-Connecting-Ip X-Forwarded-For
|
|
}
|
|
}
|
|
|
|
# Bind to the hostname on the HTTP port only. Because the address has an
|
|
# explicit ":80" scheme/port, Caddy will NOT try to provision a TLS cert.
|
|
http://blog.ahmza.com {
|
|
# THE responder: proxy every request to the blog (SWS) container.
|
|
# This is what was missing before (requests fell through to a NOP -> blank page).
|
|
reverse_proxy blog:80
|
|
|
|
# Compression happens here (SWS has it disabled on purpose).
|
|
encode zstd gzip
|
|
|
|
# Security headers (single source of truth; SWS has security-headers off).
|
|
header {
|
|
Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"
|
|
X-Content-Type-Options "nosniff"
|
|
X-Frame-Options "SAMEORIGIN"
|
|
Referrer-Policy "strict-origin-when-cross-origin"
|
|
# Drop Caddy's default Server header.
|
|
-Server
|
|
}
|
|
|
|
log {
|
|
output stdout
|
|
format console
|
|
}
|
|
}
|