Repository navigation
Expand file tree
/
Copy pathCaddyfile
More file actions
68 lines (62 loc) · 2.12 KB
/
Copy pathCaddyfile
File metadata and controls
68 lines (62 loc) · 2.12 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
# Caddyfile — ansehBAR 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://ansehbar.example.org (no path, no trailing /)
# ACME_EMAIL Let's Encrypt contact (expiry notices)
# 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>.pem /etc/caddy/certs/<name>.key`. This is a
# deliberate local edit; ACME_EMAIL is then unused but still required.
# Step-by-step guide: docs/deployment.md.
{
# Contact address for Let's Encrypt (expiry notices), from ACME_EMAIL.
email {$ACME_EMAIL}
}
{$PUBLIC_BASE_URL} {
encode zstd gzip
# The tool is never embedded anywhere: no framing, no MIME sniffing, no
# referrer beyond the origin.
header {
Content-Security-Policy "frame-ancestors 'none'"
X-Frame-Options DENY
X-Content-Type-Options nosniff
Referrer-Policy strict-origin-when-cross-origin
}
# API, Django admin and OIDC endpoints → Django (uvicorn).
handle /api/* {
reverse_proxy app:8000
}
handle /admin/* {
reverse_proxy app:8000
}
# Prometheus scrape endpoint — token-guarded by METRICS_TOKEN (404 while
# unset); see docs/monitoring.md.
handle /metrics {
reverse_proxy app:8000
}
handle /oidc/* {
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 {
root * /srv/www
try_files {path} /index.html
file_server
}
}