2026-07-21 11:15:04 +02:00
|
|
|
# SITE_ADDRESS is the domain to serve (e.g. lottery.example.com) — Caddy
|
|
|
|
|
# automatically requests a Let's Encrypt certificate for it.
|
|
|
|
|
#
|
|
|
|
|
# Left at the default "localhost" (dev mode, no domain), Caddy detects it's
|
|
|
|
|
# not a public hostname and issues a locally-trusted self-signed certificate
|
|
|
|
|
# instead, via its internal CA. Browsers will still warn on first visit
|
|
|
|
|
# unless that CA is explicitly trusted — expected for local/dev use.
|
|
|
|
|
{$SITE_ADDRESS:localhost} {
|
2026-11-16 12:00:57 +01:00
|
|
|
encode gzip
|
2026-07-27 15:44:47 +02:00
|
|
|
|
2026-11-16 12:00:57 +01:00
|
|
|
# B-43: Caddy adds none of these on its own. The session cookie is HttpOnly, but a CSP is
|
|
|
|
|
# still the main mitigation against injected script. 'unsafe-inline' stays for now because
|
|
|
|
|
# Django Admin uses inline scripts and styles; the pages of the new site (roadmap A5-A8)
|
|
|
|
|
# are written without them so the policy can be tightened for them later.
|
2026-07-27 15:44:47 +02:00
|
|
|
header {
|
|
|
|
|
Strict-Transport-Security "max-age=31536000; includeSubDomains"
|
|
|
|
|
X-Content-Type-Options "nosniff"
|
|
|
|
|
X-Frame-Options "DENY"
|
|
|
|
|
Referrer-Policy "strict-origin-when-cross-origin"
|
|
|
|
|
Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; font-src 'self' https://fonts.gstatic.com; img-src 'self'; connect-src 'self'; base-uri 'self'; form-action 'self'; frame-ancestors 'none'; object-src 'none'"
|
|
|
|
|
}
|
|
|
|
|
|
2026-08-03 22:14:03 +02:00
|
|
|
# B-54: Caddy *appends* the real peer address to whatever X-Forwarded-For the
|
|
|
|
|
# client sent, so without this the header arrives as "<whatever the client
|
|
|
|
|
# claimed>, <real ip>" and every IP-keyed control in the app (the login and
|
|
|
|
|
# registration throttles of B-33, the SSE per-IP subscriber cap of B-38) is
|
|
|
|
|
# defeated by simply rotating a fake value per request. Overwriting the header
|
|
|
|
|
# with the actual peer makes the app's assumption true at the source; it also
|
2026-11-16 12:00:57 +01:00
|
|
|
# reads the last hop rather than the first, so the two defences hold independently.
|
|
|
|
|
reverse_proxy web:8000 {
|
2026-08-03 22:14:03 +02:00
|
|
|
header_up X-Forwarded-For {remote_host}
|
|
|
|
|
}
|
2026-07-21 11:15:04 +02:00
|
|
|
}
|