Files
plm-lottery/Caddyfile
T
davideandClaude Sonnet 5.5 fc23a75c9b A1: Django skeleton with web and worker processes (ADR-54, ADR-55, WEB-01, WEB-07, ARC-70..74)
Django 5.2 project (config/, apps/accounts with a custom User and
case-insensitive usernames, apps/lottery with the run_worker command,
apps/web with a placeholder home and /health/live, apps/ops), SQLite in WAL
with IMMEDIATE transactions, secrets and hosts from the environment. The
compose stack is now web + worker + caddy and serves https://localhost; the
old FastAPI service is out of the stack until roadmap D1. The three old
infrastructure tests follow the new Dockerfile and compose.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-16 12:00:57 +01:00

34 lines
1.9 KiB
Caddyfile

# 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} {
encode gzip
# 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.
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'"
}
# 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
# reads the last hop rather than the first, so the two defences hold independently.
reverse_proxy web:8000 {
header_up X-Forwarded-For {remote_host}
}
}