diff --git a/docs/server-setup.md b/docs/server-setup.md index 2f1cbf4..896caf2 100644 --- a/docs/server-setup.md +++ b/docs/server-setup.md @@ -39,6 +39,51 @@ Check propagation (repeat until it prints the server IP): local$ dig +short git.vienalatina.com ``` +### 1.1 A second domain that leads here + +`vielac.at` is the second name, and it redirects: everything that arrives goes +to the same path on vienalatina.com. Two A records in that domain's **zone +editor**, both at the server: + +| Name | Type | Value | TTL | +|---|---|---|---| +| `@` | A | `` | 300 | +| `www` | A | `` | 300 | + +**Not the nameserver page.** On Hetzner's Konsole H those fields hand the whole +zone to another provider's DNS, which is a different thing entirely and turns +off the zone editor you want. *Standard Nameserver eintragen*, save, then edit +the zone. + +Then the block in `infra/caddy/Caddyfile`, which carries both spellings and +answers with a **301** — a permanent redirect is what folds the two names into +one site for a search engine rather than two copies of it, and `{uri}` keeps +the path so a shared link still lands where it was pointing. + +**Order matters, and it is the same order as the cutover above**: the A records +go in first, because Caddy asks Let's Encrypt for the certificate the first time +the name resolves to this server. A reload before DNS has propagated is not +harmful — nothing reaches the block — but it does not get a certificate either, +so reload again afterwards. + +```sh +sudo cp ~/vienalatina/infra/caddy/Caddyfile /etc/caddy/Caddyfile +sudo caddy validate --config /etc/caddy/Caddyfile +sudo systemctl reload caddy +``` + +`validate` before every `reload`, without exception: it is the one command +between a typo in that file and vienalatina.com going down with it. + +```sh +curl -sI https://vielac.at/ | head -3 # 301 → vienalatina.com +curl -sI https://www.vielac.at/page/agenda/ | grep -i location # the path survives +curl -sI https://vienalatina.com/ | head -1 # 200, unchanged +``` + +The third is the one that matters. A Caddyfile edit that breaks the site it was +meant to leave alone is the failure this ordering exists to prevent. + ## 2. First login + basic hardening ```sh diff --git a/infra/caddy/Caddyfile b/infra/caddy/Caddyfile index 5b87d62..62de8b9 100644 --- a/infra/caddy/Caddyfile +++ b/infra/caddy/Caddyfile @@ -21,6 +21,22 @@ www.vienalatina.com { redir https://vienalatina.com{uri} 301 } +# The second name, which leads here rather than somewhere else. +# +# 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. +# +# 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