Everything on this site so far has been a file built from git. This is the first component that runs code to answer a request and the first whose data git does not hold, so the trade is stated in the README and the backup script is not optional. Roles are owner, admin and user. The owner is seeded once from BOARD_OWNER and cannot be seeded again, because otherwise editing a compose file would be a quieter way to take the top role than asking for it; ownership moves only by transfer, inside the app. There is exactly one owner and a partial unique index enforces it, so the invariant holds even when a handler is wrong. The owner is beyond suspension and demotion by everyone, themselves included. Only the owner makes admins; admins make users. Sign-in goes through Gitea as a confidential OAuth client — the opposite of Decap, which has to be public because it runs in the browser. The rule the whole thing rests on is that a Gitea account is not a membership: entry needs an active row in `members`, or every account on the instance is a member, starting with the translations bot. Admins can delete any post; nobody can edit anyone else's, admins included. Taking a post down is visible to its author. Quietly rewriting it is not, and an admin who could do that could leave a sentence attributed to someone who never wrote it. The plan said admins could do both; this is the one place the implementation departs from it. Markdown renders with raw HTML disabled, which is the entire XSS defence and the reason there is no sanitiser: the renderer emits only its own tags and escapes the rest. The CSP carries no 'unsafe-inline', which makes an inline onsubmit silently inert rather than broken, so the confirmation dialogs live in a static file and a test fails any template that grows an inline handler. GDPR is in scope rather than deferred: erasure removes the member row and moves their authorship to a tombstone so the conversations around them still read, and any member can download their own writing. Verified: 63 checks pass, covering the membership gate, every role predicate, a direct insert of a second owner being refused by the index, atomic ownership transfer, CSRF, an offsite login redirect, script tags rendering as text, soft deletes leaving both listings and exports, and the member screens rendering for each role. Smoke-tested live: headers, both static assets, and the bare /comunidad redirect that the Caddy matcher has to cover. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NizVpJ2dwzCbjCrTLCjeHn
75 lines
2.5 KiB
Caddyfile
75 lines
2.5 KiB
Caddyfile
# /etc/caddy/Caddyfile — copy this file there, then: sudo systemctl reload caddy
|
|
#
|
|
# Caddy fetches and renews Let's Encrypt certificates automatically the first
|
|
# time a domain's DNS points at this server. Order matters on a cutover: move
|
|
# the A record here first, then reload Caddy — the ACME HTTP-01 challenge for
|
|
# vienalatina.com only succeeds once the domain already resolves to this box.
|
|
|
|
git.vienalatina.com {
|
|
reverse_proxy 127.0.0.1:3000
|
|
}
|
|
|
|
ci.vienalatina.com {
|
|
reverse_proxy 127.0.0.1:8000
|
|
}
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Live since cutover (A record for vienalatina.com points at this server).
|
|
# ---------------------------------------------------------------------------
|
|
|
|
www.vienalatina.com {
|
|
redir https://vienalatina.com{uri} 301
|
|
}
|
|
|
|
vienalatina.com {
|
|
root * /var/www/vienalatina.com
|
|
encode zstd gzip
|
|
file_server
|
|
|
|
# Members area — the only part of this site that runs code. Both paths are
|
|
# matched: Flask redirects /comunidad to /comunidad/, and a matcher of
|
|
# /comunidad/* alone would let the bare path fall through to file_server
|
|
# and 404 before the app ever sees it.
|
|
#
|
|
# No `handle` wrapper is needed. Caddy runs reverse_proxy ahead of
|
|
# file_server in its directive order, and reverse_proxy is terminal, so a
|
|
# matched request never reaches the static tree.
|
|
@board path /comunidad /comunidad/*
|
|
reverse_proxy @board 127.0.0.1:8080
|
|
|
|
# llms.txt is markdown (matches the old WP behaviour)
|
|
header /llms.txt Content-Type "text/markdown; charset=utf-8"
|
|
|
|
# --- 301s for old WordPress URL patterns -----------------------------
|
|
|
|
# /?p=123 style permalinks → home (add specific mappings as GSC reports them)
|
|
@wp_query_permalink {
|
|
path /
|
|
query p=*
|
|
}
|
|
redir @wp_query_permalink / 301
|
|
|
|
# WP category base was /categoria/… (Spanish slugs); Hugo uses /categories/…
|
|
@old_category path_regexp oldcat ^/categoria/(.*)$
|
|
redir @old_category /categories/{re.oldcat.1} 301
|
|
|
|
# WP author archives have no Hugo equivalent → home
|
|
@old_author path /autor/*
|
|
redir @old_author / 301
|
|
|
|
# Old WP media library URLs → migrated uploads folder
|
|
@old_uploads path_regexp oldup ^/wp-content/uploads/(?:\d{4}/\d{2}/)?(.*)$
|
|
redir @old_uploads /uploads/{re.oldup.1} 301
|
|
|
|
# Anything else that starts with /wp- doesn't exist anymore
|
|
@wp_leftovers path /wp-admin/* /wp-login.php /wp-json/* /xmlrpc.php
|
|
redir @wp_leftovers / 301
|
|
|
|
# Custom 404 falls back to Hugo's 404 page
|
|
handle_errors {
|
|
@404 expression {err.status_code} == 404
|
|
rewrite @404 /404.html
|
|
file_server
|
|
}
|
|
}
|