diff --git a/README.md b/README.md index b9aa163..03a8da6 100644 --- a/README.md +++ b/README.md @@ -162,18 +162,32 @@ On a new host: Rauthy's mail leaves through kasse's postfix like gdo's, and Rauthy stops if it cannot reach it. -## Preview +## Previews -`forhandsvisning.tomtervel.no` shows the content branch last pushed to -tomtervel/questions, before it is merged. The content repo's -`lint-and-reload` workflow runs it after the lint passes: a container -`tomtervel-preview` from this site's own image -(`localhost/tomtervel-portal:`), beside a throwaway NATS -(`tomtervel-preview-nats`), on 127.0.0.1:3065. It has no gdo, so nothing -mails anyone, and no sign-in, so desks stay shut and the public pages -show. A form sent on it lands in the throwaway NATS and nowhere else. -The commit gets a "forhåndsvisning" status with the link, which a PR -shows among its checks. Main is never previewed: it is the site. +Every content branch pushed to tomtervel/questions gets its own preview +before it is merged, on `https://.forhandsvisning.tomtervel.no`, +for five days after its last push; `forhandsvisning.tomtervel.no` lists +the ones there are. The content repo runs them +(`.gitea/preview/preview.sh`, from `lint-and-reload` once the lint +passes): a container `tomtervel-preview-` from this site's own +image (`localhost/tomtervel-portal:`), beside a throwaway +NATS (`tomtervel-preview-nats`) where each branch has a `SITE_NAME` of its +own, and a small Caddy, `tomtervel-preview-router` on 127.0.0.1:3066, that +picks the container by the name asked for. At most five run at once; the +one that expires first goes when a sixth arrives. The content repo's +`preview-cleanup` workflow removes them when they expire (hourly) and when +their branch is deleted. + +A preview has no gdo, so nothing mails anyone, and no sign-in, so desks +stay shut and the public pages show. A form sent on it lands in the +throwaway NATS and nowhere else. The commit gets a "forhåndsvisning" +status with the link, which a PR shows among its checks. Main is never +previewed: it is the site. + +On kasse this needs the DNS records in `dns/dnsconfig.js` (the bare name +and `*.forhandsvisning`), the two blocks in `host-caddy/tomtervel.no`, and +the `on_demand_tls` global option described there, in +`/etc/caddy/Caddyfile`. ## Backups diff --git a/dns/dnsconfig.js b/dns/dnsconfig.js index 90d7b4d..c0494f4 100644 --- a/dns/dnsconfig.js +++ b/dns/dnsconfig.js @@ -36,8 +36,12 @@ D("tomtervel.no", REG_NONE, DnsProvider(DSP_CLOUDFLARE), // id on to konto (the login) and chat on to samtaler. A("id", KASSE, CF_PROXY_OFF), A("chat", KASSE, CF_PROXY_OFF), - // The content repo's preview: a branch before it is merged. + // The content repo's previews: the list of them, and one name per + // branch before it is merged (.forhandsvisning). Caddy gets a + // certificate for a branch's name the first time it is asked for, and + // only for a branch that has a preview (host-caddy/tomtervel.no). A("forhandsvisning", KASSE, CF_PROXY_OFF), + A("*.forhandsvisning", KASSE, CF_PROXY_OFF), // The old website, kept for now so the move can be undone: what the // apex and web. pointed at before (Netlify, through Cloudflare). The diff --git a/host-caddy/tomtervel.no b/host-caddy/tomtervel.no index 676a761..1095eb6 100644 --- a/host-caddy/tomtervel.no +++ b/host-caddy/tomtervel.no @@ -33,13 +33,35 @@ konto.tomtervel.no { reverse_proxy 127.0.0.1:8090 } -# The content repo's preview: the branch last pushed, on a portal of its -# own with a throwaway NATS, no mail and no sign-in (tomtervel/questions, -# lint-and-reload.yml). Kept out of search engines. -# Port 3065: 3060 is gullberg.klingenbergbygg.no's, and podman's own -# published ports (3050, 3070, 8090) do not show in `ss`, so a port is -# chosen against this directory's upstreams as well. +# The content repo's previews (tomtervel/questions, .gitea/preview/): one +# portal per branch on .forhandsvisning.tomtervel.no, for five days +# after its last push, and the list of them on the bare name. Every name +# goes to the previews' own router on 3066, which picks the branch's +# container by name. Kept out of search engines. +# +# A branch's name has no certificate until someone opens it: Caddy gets one +# on demand, and first asks the router whether that name has a preview, so +# made-up names cannot use up Let's Encrypt's limits. That needs this in the +# global options of /etc/caddy/Caddyfile (kasse's, shared with the other +# sites there; nothing else on kasse uses on-demand TLS): +# +# on_demand_tls { +# ask http://127.0.0.1:3066/ask +# } +# +# Port 3066: 3060 is gullberg.klingenbergbygg.no's, 3065 was the single +# preview before, and podman's own published ports (3050, 3065, 3066, 3070, +# 8090) do not show in `ss`, so a port is chosen against this directory's +# upstreams as well. forhandsvisning.tomtervel.no { header X-Robots-Tag "noindex, nofollow" - reverse_proxy 127.0.0.1:3065 + reverse_proxy 127.0.0.1:3066 +} + +*.forhandsvisning.tomtervel.no { + tls { + on_demand + } + header X-Robots-Tag "noindex, nofollow" + reverse_proxy 127.0.0.1:3066 }