vienalatina/infra/caddy/Caddyfile
Claude cba9939eb2
The last of WordPress
`/wp-cron.php` was reaching the Flask app. The matcher for old WordPress
paths listed four of them by name and missed that one, so it fell through
to the single-segment profile route — `/wp-cron.php` looks exactly like a
member's name — and was answered with a 400 by the CSRF hook. The old
install has been POSTing it every few minutes, which means the members
area was being woken up by the site it replaced. The matcher is now
`/wp-*`, after the uploads rule and never before it, so the migrated
pictures still map.

`/categoria/…` was redirecting to `/categories/…`, which stopped existing
when the taxonomies were removed: one dead address forwarding to another.
It goes home now.

vielac.at is the old site's own domain rather than a spare name, which is
worth saying in the file that redirects it: it is the address in every
link shared before the cutover and every search result not yet recrawled.
An old WordPress path arriving there lands on vienalatina.com and is
caught by the 301s further down — one set of rules rather than two.

Deleted with it: `scripts/wp-to-hugo.py`, whose own docstring called it
disposable and whose migration happened; its section in the README, which
now says what remains of that site instead; and the WordPress core
alignment CSS, which no content uses and nothing in the editor can
produce.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NizVpJ2dwzCbjCrTLCjeHn
2026-10-06 21:39:12 +00:00

140 lines
5.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
}
# The old site's own domain. vielac.at is where the WordPress install this
# project replaced used to live — it is the address in every link shared before
# the cutover, in every search result that has not been recrawled, and in the
# bookmarks of everybody who read it.
#
# Both spellings in one block, and 301 rather than 302: a permanent redirect is
# what makes a search engine fold the two names into one site instead of
# indexing them as duplicates of each other, and what makes a browser stop
# asking after the first visit. `{uri}` carries the path, so a link somebody
# shared to vielac.at/page/agenda/ lands on the agenda rather than on the home
# page — and an old WordPress path arrives at vienalatina.com and is caught by
# the 301s further down, which is one set of rules rather than two.
#
# Caddy asks Let's Encrypt for this certificate the first time the name
# resolves to this server, so the A records go in before this file is reloaded.
# Until they do, the block is harmless: nothing reaches it.
vielac.at, www.vielac.at {
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
# Public profiles at vienalatina.com/su-nombre.
#
# This shares a namespace with the entire static site, so the rule is that
# the static site always wins — decided by asking the disk, not by keeping
# a list of reserved paths that would be wrong the first time Hugo grows
# one. Three conditions, each load-bearing:
#
# path_regexp one segment only, so /page/acerca/ never comes here
# not path /comunidad is the members area, matched above
# not file if Hugo built anything at this path, Hugo serves it
#
# A member called "de" therefore shadows nothing: /de/ is a real directory,
# so it is served, and their profile is simply unreachable. The app refuses
# such names at sign-up for that reason, but the site is safe either way.
#
# handle_response turns the app's 404 for an unknown name into the site's
# own 404 page, so a visitor sees the public site's error, not the members
# area's, and the app never needs a public-facing error template.
@profile {
path_regexp ^/([A-Za-z0-9][A-Za-z0-9._-]{0,38})/?$
not path /comunidad /comunidad/*
not file {
try_files {path} {path}/index.html
}
}
reverse_proxy @profile 127.0.0.1:8080 {
@nobody status 404
handle_response @nobody {
rewrite * /404.html
file_server
}
}
# 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
# The old category base, which now has nowhere to land: the taxonomy was
# removed from this site, so /categories/… is a 404 and a 301 into it would
# be sending somebody from one dead address to another. Home instead.
@old_category path_regexp oldcat ^/categoria/(.*)$
redir @old_category / 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 beginning with /wp- is gone. Written as a wildcard rather
# than a list, because the list was missing the one that mattered:
# /wp-cron.php fell through to the single-segment profile matcher below —
# it looks exactly like a member's name — reached the Flask app, and was
# answered with a 400 by the CSRF hook. A WordPress install elsewhere was
# POSTing it every few minutes, so the members area was being woken up by
# the site it replaced.
#
# After the uploads rule above, never before it: these are `redir`
# directives and Caddy keeps them in the order they are written, so
# /wp-content/uploads/… still maps to the migrated pictures.
@wp_leftovers path /wp-* /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
}
}