Repository navigation
Expand file tree
/
Copy pathCaddyfile
More file actions
99 lines (93 loc) · 3.42 KB
/
Copy pathCaddyfile
File metadata and controls
99 lines (93 loc) · 3.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# Caddyfile — Abstimmbar production reverse proxy with automatic HTTPS.
#
# This file needs NO local edits: it is configured through environment
# variables (set in .env, passed to the caddy service by docker-compose.prod.yml):
# PUBLIC_BASE_URL site address, bare origin, e.g.
# https://abstimmbar.example.org (no path)
# ACME_EMAIL Let's Encrypt contact (expiry notices)
# ABSTIMMBAR_FRAME_ANCESTORS optional, space-separated LMS origins allowed
# to embed the SPA in an iframe (LTI)
# Caddy obtains and renews a Let's Encrypt certificate automatically as long
# as ports 80 and 443 are reachable and the domain's DNS points here. The
# https:// scheme in PUBLIC_BASE_URL makes the site HTTPS-only (plain HTTP is
# redirected by Caddy's automatic redirect on port 80).
#
# Manual option, institutional certificates (e.g. HARICA): mount them into the
# container (see docker-compose.prod.yml) and add inside the site block
# `tls /etc/caddy/certs/<name>.crt /etc/caddy/certs/<name>.key`. This is a
# deliberate local edit; ACME_EMAIL is then unused but still required.
{
# Contact address for Let's Encrypt (expiry notices), from ACME_EMAIL.
email {$ACME_EMAIL}
}
{$PUBLIC_BASE_URL} {
encode zstd gzip
# API (including the SSE stream), Django admin, OIDC and LTI endpoints,
# and the server-rendered participant pages (/p/...) → Django (uvicorn).
# flush_interval -1 disables response buffering: SSE events must reach
# the devices immediately, not once a buffer fills up.
handle /api/* {
reverse_proxy app:8000 {
flush_interval -1
}
}
handle /admin/* {
reverse_proxy app:8000
}
handle /oidc/* {
reverse_proxy app:8000
}
handle /lti/* {
reverse_proxy app:8000
}
handle /p/* {
reverse_proxy app:8000
}
# Recording mode (#53): the per-question viewer page and its QR image
# live under /r/ and are server-rendered by Django — must be proxied, or
# the QR <img> and the scanned deep link fall through to the SPA.
handle /r/* {
reverse_proxy app:8000
}
# Self-check links (/c/<token>/ + QR) and the LTI learner redirect → Django.
handle /c/* {
reverse_proxy app:8000
}
# Personal committee meeting links (/g/<token>/) → Django, including
# the ballot page's SSE stream (unbuffered, see /api/*).
handle /g/* {
reverse_proxy app:8000 {
flush_interval -1
}
}
# Prometheus scrape endpoint — token-guarded by METRICS_TOKEN (404 while
# unset); see docs/monitoring.md.
handle /metrics {
reverse_proxy app:8000
}
handle /question-preview/* {
reverse_proxy app:8000
}
# Uploaded media and collected static files → served directly from volumes.
handle_path /media/* {
root * /srv/media
file_server
}
handle_path /static/* {
root * /srv/static
file_server
}
# Everything else → the built SPA, with client-side routing fallback.
handle {
# LTI iframe embedding (optional): set ABSTIMMBAR_FRAME_ANCESTORS in .env
# to the LMS origin(s), space-separated, to let the LMS embed the SPA in
# an iframe. Only needed for in-iframe launches; "new window" launches
# don't need it. Django already sets frame-ancestors for /p/ and /lti/
# from the registered platforms; this line covers the Caddy-served SPA.
# Empty (default) = 'self' only, no external framing.
header Content-Security-Policy "frame-ancestors 'self' {$ABSTIMMBAR_FRAME_ANCESTORS}"
root * /srv/www
try_files {path} /index.html
file_server
}
}