koopa-admin-log/scripts/dossiers-ngi/caddy-dossiers-ngi.snippet

68 lines
2.4 KiB
Text

# Stanza body for dossiers.ngi.hacktivism.ch only (hand-check / re-seed).
# Apply on koopa (host-local):
# bash ~/bin/apply-dossiers-ngi-edition-switch.sh
# sudo ~/bin/caddy-apply
#
# Sticky bar switches build via cookie tdpd_edition → editions/<name>/.
# Stock Caddy only (templates + map + handle). No replace-response plugin.
# Keep .2 / .3 blocks untouched.
#
# Site-block body (no outer braces):
header Alt-Svc "clear"
# Cookie selects editions/<slug>/; same paths (/static/css/style.css) must not
# share one browser/CDN cache entry across editions (main has no green CSS).
header Vary "Cookie"
header Cache-Control "private, no-cache"
@use path_regexp use ^/_cascade/use/([A-Za-z0-9_-]+)/?$
handle @use {
header Set-Cookie "tdpd_edition={re.use.1}; Path=/; Max-Age=31536000; SameSite=Lax"
header Cache-Control "private, no-store"
# Keep the caller's path (?next=). Never bounce to /. No next → bar page.
@next query_regexp next ^(/|/[^/].*)$
redir @next {query.next} 302
redir * /_cascade/ 302
}
handle /_cascade/* {
root * /var/www/monitoring-sites/dossiers.ngi.hacktivism.ch
header Cache-Control "private, no-cache"
file_server
}
# Path-root cascade stubs live under sites/…/cascade/
handle /cascade/* {
root * /var/www/monitoring-sites/dossiers.ngi.hacktivism.ch
header Cache-Control "private, no-cache"
file_server
try_files {path} {path}/ {path}/index.html
}
handle /branch-status.json {
root * /var/www/monitoring-sites/dossiers.ngi.hacktivism.ch
header Cache-Control "private, no-cache"
file_server
}
# Explicit edition_dir map (placeholder map output broke on Caddy v2.11.4 —
# non-flask cookies 404'd). Refresh this list when new origin tips appear
# (branch-status rebuild creates editions/<slug>/).
map {http.request.cookie.tdpd_edition} {edition_dir} {
default flask
flask flask
feat-sm-content feat-sm-content
feat-website-design feat-website-design
feat-website-features feat-website-features
feat-website-views feat-website-views
feature-nl-net-injestion-injestor-update feature-nl-net-injestion-injestor-update
main main
project_template project_template
}
root * /var/www/monitoring-sites/dossiers.ngi.hacktivism.ch/editions/{edition_dir}
templates {
mime text/html
between "{%" "%}"
root /var/www/monitoring-sites/dossiers.ngi.hacktivism.ch
}
file_server
try_files {path} {path}/ {path}/index.html