From 5ff25e7c0b5fc0f2ec4a27b1c89fd1b9daf2ec6f Mon Sep 17 00:00:00 2001 From: Pieter Viljoen Date: Sat, 24 Oct 2026 07:39:58 -0700 Subject: [PATCH 1/5] Send the Same Security Headers and Image Lifetime From Both Sites The blog block gains the HSTS, nosniff, and Referrer-Policy headers the family block already sends, with the same values. The family images take the blog's one-hour image class, replacing a week for SVGs and no-cache for the root PNG and ICO files. deploy/README.md states each remaining difference and its reason, the family-only CSP included. Co-Authored-By: Claude Opus 5.5 --- OPERATIONS.md | 2 +- deploy/Caddyfile | 12 +++++++++--- deploy/README.md | 16 +++++++++++++++- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/OPERATIONS.md b/OPERATIONS.md index 938eb05..e8d14d6 100644 --- a/OPERATIONS.md +++ b/OPERATIONS.md @@ -593,7 +593,7 @@ The maps are generated by [`capture/build-redirects.py`](./capture/build-redirec The bundle also carries `viljoen.family`, a single static page whose source is [`sites/viljoen.family/`](./sites/viljoen.family/). `make-release.sh` copies it to `family/` beside `site/`, leaving out its README, and precompresses it the same way. It shares the release, the containers, and the rollback with the blog, so a family change ships as a blog release. -A second site block in `deploy/Caddyfile` serves it on the same port, selected by the `Host` header the proxy forwards. Any other hostname falls through to the blog's `:8080` block, so the blog's redirects never answer on the family host. The family block carries its own security headers and CSP, and answers a missing path with the page itself at a `404` status. It also routes the page's two languages: `/` redirects to `/af/` for a browser whose first language is Afrikaans, while `/en/` and `/af/` never redirect. +A second site block in `deploy/Caddyfile` serves it on the same port, selected by the `Host` header the proxy forwards. Any other hostname falls through to the blog's `:8080` block, so the blog's redirects never answer on the family host. The family block adds a CSP to the security headers both blocks send, and answers a missing path with the page itself at a `404` status. It also routes the page's two languages: `/` redirects to `/af/` for a browser whose first language is Afrikaans, while `/en/` and `/af/` never redirect. Two container variables belong to it, both part of the [container contract](./deploy/README.md#container-contract). `FAMILY_SITE_ROBOTS` sets the family site's `X-Robots-Tag` apart from the blog's `SITE_ROBOTS`, for the reason given in [Identifying the environment](./deploy/README.md#identifying-the-environment). `FAMILY_SITE_ADDRESS` adds a local mirror's private name, per [Serving the family site on a local name](./deploy/README.md#serving-the-family-site-on-a-local-name). diff --git a/deploy/Caddyfile b/deploy/Caddyfile index 88cf259..9042a3a 100644 --- a/deploy/Caddyfile +++ b/deploy/Caddyfile @@ -33,6 +33,12 @@ # Without this a stale config passes the URL contract against rules never shipped. header X-Blog-Release "@@RELEASE@@" + header { + Strict-Transport-Security "max-age=31536000" + X-Content-Type-Options "nosniff" + Referrer-Policy "strict-origin-when-cross-origin" + } + # One map serves four classes because their key spaces are disjoint. # Merging them keeps those four classes to a single lookup. map {path} {mapped} { @@ -178,11 +184,11 @@ http://viljoen.family:8080, http://viljoen.vps.insanegenius.net:8080 {$FAMILY_SI Content-Security-Policy "default-src 'self'; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; font-src https://fonts.gstatic.com; connect-src 'self' https://fonts.googleapis.com https://fonts.gstatic.com; script-src 'self'; img-src 'self' data:" } - @svg path *.svg - header @svg Cache-Control "public, max-age=604800" + @image path *.svg *.png *.ico + header @image Cache-Control "public, max-age=3600" @code path *.css *.js header @code Cache-Control "no-cache" - @page not path *.svg *.css *.js + @page not path *.svg *.png *.ico *.css *.js header @page Cache-Control "no-cache" # The root follows the browser's first language, and /en/ and /af/ never redirect, so the language switch always holds. diff --git a/deploy/README.md b/deploy/README.md index d2305ea..7277e35 100644 --- a/deploy/README.md +++ b/deploy/README.md @@ -281,13 +281,27 @@ Every file the blog serves, and its error page, names its own lifetime. A browse | `/assets/`, the fingerprinted stylesheet and script | `public, max-age=31536000, immutable` | The name changes with the content, so a copy is never stale | | `/media/` and the root icons | `public, max-age=3600` | An image rarely changes, and an hour bounds how long a replaced one is still served from any copy | -A `404` answers with `no-cache` whatever its path, since a missing file in a cached class would otherwise keep that class's lifetime. The blog's redirects answer `no-cache` too, since the baseline header runs before them. A map entry a release changes is then followed at the next request. The family site keeps its own, shorter list in its block, and its error page answers `no-cache` the same way. Its language redirects answer `no-cache` as well, because the `@page` matcher reaches them. +A `404` answers with `no-cache` whatever its path, since a missing file in a cached class would otherwise keep that class's lifetime. The blog's redirects answer `no-cache` too, since the baseline header runs before them. A map entry a release changes is then followed at the next request. The family site follows the same table, and its images, the SVGs included, take the one-hour image class. Its stylesheet and script keep their names across releases, so they answer `no-cache` like its pages. A longer lifetime there would pair a new page with an old script. Its error page answers `no-cache` the same way, and so do its language redirects, because the `@page` matcher reaches them. **Two zone settings decide whether these lifetimes hold behind Cloudflare.** Both are the host side's to set. - **Browser Cache TTL must be "Respect Existing Headers".** A new zone's default is 4 hours. Cloudflare replaces an origin lifetime shorter than that setting with the setting. A browser would then keep a replaced image for 4 hours rather than one. - **Caching Level must not be "Ignore Query String".** `check-live-urls.sh` asks for each media file with a query no earlier run sent, so the edge's copy cannot answer for a file a release lost. The default level, Standard, keys the cache on the query string. Ignore Query String would answer from the copy again. +## Security headers + +Both sites send the same security headers on every response, redirects and the `404` included: + +| Header | Value | Why | +| --- | --- | --- | +| `Strict-Transport-Security` | `max-age=31536000` | After the first HTTPS visit a browser skips the cleartext redirect, which an on-path attacker could intercept | +| `X-Content-Type-Options` | `nosniff` | A browser trusts the served `Content-Type` rather than guessing one from the body | +| `Referrer-Policy` | `strict-origin-when-cross-origin` | Another site learns only the origin a reader came from, never the path | + +The HSTS value carries neither `includeSubDomains` nor `preload`, since each binds hostnames this bundle does not serve. HSTS at the edge stays off for the same reason, because Cloudflare applies it to every name in the zone. + +**Only the family site sends a `Content-Security-Policy`.** Its page loads nothing beyond its own files and Google Fonts, so its policy lists exactly those. Blog posts embed third-party content, so a blog policy waits on a survey of what the posts load. + ## Trusting the proxy A proxy fronts Caddy in every environment, so the peer address is always the proxy and the real From e71e36950f324a146ff0f8937b729ae3f0a96de4 Mon Sep 17 00:00:00 2001 From: Pieter Viljoen Date: Sat, 24 Oct 2026 07:41:36 -0700 Subject: [PATCH 2/5] Split the Family Block Sentence Under the Length Cap Co-Authored-By: Claude Opus 5.5 --- OPERATIONS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OPERATIONS.md b/OPERATIONS.md index e8d14d6..c8c4e4a 100644 --- a/OPERATIONS.md +++ b/OPERATIONS.md @@ -593,7 +593,7 @@ The maps are generated by [`capture/build-redirects.py`](./capture/build-redirec The bundle also carries `viljoen.family`, a single static page whose source is [`sites/viljoen.family/`](./sites/viljoen.family/). `make-release.sh` copies it to `family/` beside `site/`, leaving out its README, and precompresses it the same way. It shares the release, the containers, and the rollback with the blog, so a family change ships as a blog release. -A second site block in `deploy/Caddyfile` serves it on the same port, selected by the `Host` header the proxy forwards. Any other hostname falls through to the blog's `:8080` block, so the blog's redirects never answer on the family host. The family block adds a CSP to the security headers both blocks send, and answers a missing path with the page itself at a `404` status. It also routes the page's two languages: `/` redirects to `/af/` for a browser whose first language is Afrikaans, while `/en/` and `/af/` never redirect. +A second site block in `deploy/Caddyfile` serves it on the same port, selected by the `Host` header the proxy forwards. Any other hostname falls through to the blog's `:8080` block, so the blog's redirects never answer on the family host. The family block adds a CSP to the security headers both blocks send. It answers a missing path with the page itself at a `404` status. It also routes the page's two languages: `/` redirects to `/af/` for a browser whose first language is Afrikaans, while `/en/` and `/af/` never redirect. Two container variables belong to it, both part of the [container contract](./deploy/README.md#container-contract). `FAMILY_SITE_ROBOTS` sets the family site's `X-Robots-Tag` apart from the blog's `SITE_ROBOTS`, for the reason given in [Identifying the environment](./deploy/README.md#identifying-the-environment). `FAMILY_SITE_ADDRESS` adds a local mirror's private name, per [Serving the family site on a local name](./deploy/README.md#serving-the-family-site-on-a-local-name). From 4b1c72476ad29c70be0bd1e1db5e516fab9102ed Mon Sep 17 00:00:00 2001 From: Pieter Viljoen Date: Sat, 24 Oct 2026 07:46:54 -0700 Subject: [PATCH 3/5] Name the CSP Allowances and Drop the Counts From the Header Prose Co-Authored-By: Claude Opus 5.5 --- OPERATIONS.md | 2 +- deploy/README.md | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/OPERATIONS.md b/OPERATIONS.md index c8c4e4a..fa6d21f 100644 --- a/OPERATIONS.md +++ b/OPERATIONS.md @@ -593,7 +593,7 @@ The maps are generated by [`capture/build-redirects.py`](./capture/build-redirec The bundle also carries `viljoen.family`, a single static page whose source is [`sites/viljoen.family/`](./sites/viljoen.family/). `make-release.sh` copies it to `family/` beside `site/`, leaving out its README, and precompresses it the same way. It shares the release, the containers, and the rollback with the blog, so a family change ships as a blog release. -A second site block in `deploy/Caddyfile` serves it on the same port, selected by the `Host` header the proxy forwards. Any other hostname falls through to the blog's `:8080` block, so the blog's redirects never answer on the family host. The family block adds a CSP to the security headers both blocks send. It answers a missing path with the page itself at a `404` status. It also routes the page's two languages: `/` redirects to `/af/` for a browser whose first language is Afrikaans, while `/en/` and `/af/` never redirect. +A second site block in `deploy/Caddyfile` serves it on the same port, selected by the `Host` header the proxy forwards. Any other hostname falls through to the blog's `:8080` block, so the blog's redirects never answer on the family host. The family block adds a CSP to the security headers every block sends. It answers a missing path with the page itself at a `404` status. It also routes the page's two languages: `/` redirects to `/af/` for a browser whose first language is Afrikaans, while `/en/` and `/af/` never redirect. Two container variables belong to it, both part of the [container contract](./deploy/README.md#container-contract). `FAMILY_SITE_ROBOTS` sets the family site's `X-Robots-Tag` apart from the blog's `SITE_ROBOTS`, for the reason given in [Identifying the environment](./deploy/README.md#identifying-the-environment). `FAMILY_SITE_ADDRESS` adds a local mirror's private name, per [Serving the family site on a local name](./deploy/README.md#serving-the-family-site-on-a-local-name). diff --git a/deploy/README.md b/deploy/README.md index 7277e35..ea8bd18 100644 --- a/deploy/README.md +++ b/deploy/README.md @@ -281,7 +281,7 @@ Every file the blog serves, and its error page, names its own lifetime. A browse | `/assets/`, the fingerprinted stylesheet and script | `public, max-age=31536000, immutable` | The name changes with the content, so a copy is never stale | | `/media/` and the root icons | `public, max-age=3600` | An image rarely changes, and an hour bounds how long a replaced one is still served from any copy | -A `404` answers with `no-cache` whatever its path, since a missing file in a cached class would otherwise keep that class's lifetime. The blog's redirects answer `no-cache` too, since the baseline header runs before them. A map entry a release changes is then followed at the next request. The family site follows the same table, and its images, the SVGs included, take the one-hour image class. Its stylesheet and script keep their names across releases, so they answer `no-cache` like its pages. A longer lifetime there would pair a new page with an old script. Its error page answers `no-cache` the same way, and so do its language redirects, because the `@page` matcher reaches them. +A `404` answers with `no-cache` whatever its path, since a missing file in a cached class would otherwise keep that class's lifetime. The blog's redirects answer `no-cache` too, since the baseline header runs before them. A map entry a release changes is then followed at the next request. The family site follows the table's page and image rows, its SVGs included. Its stylesheet and script keep their names across releases, so they answer `no-cache` like its pages. A longer lifetime there would pair a new page with an old script. Its error page answers `no-cache` the same way, and so do its language redirects, because the `@page` matcher reaches them. **Two zone settings decide whether these lifetimes hold behind Cloudflare.** Both are the host side's to set. @@ -290,7 +290,7 @@ A `404` answers with `no-cache` whatever its path, since a missing file in a cac ## Security headers -Both sites send the same security headers on every response, redirects and the `404` included: +The sites send the same security headers on every response, redirects and the `404` included: | Header | Value | Why | | --- | --- | --- | @@ -300,7 +300,7 @@ Both sites send the same security headers on every response, redirects and the ` The HSTS value carries neither `includeSubDomains` nor `preload`, since each binds hostnames this bundle does not serve. HSTS at the edge stays off for the same reason, because Cloudflare applies it to every name in the zone. -**Only the family site sends a `Content-Security-Policy`.** Its page loads nothing beyond its own files and Google Fonts, so its policy lists exactly those. Blog posts embed third-party content, so a blog policy waits on a survey of what the posts load. +**Only the family site sends a `Content-Security-Policy`.** Its page loads few resources, so its policy names each kind: its own files, Google Fonts, inline styles, and `data:` images. Blog posts embed third-party content, so a blog policy waits on a survey of what the posts load. ## Trusting the proxy From 2bc5653e74360faca1832bd4f185efa89ad4f767 Mon Sep 17 00:00:00 2001 From: Pieter Viljoen Date: Sat, 24 Oct 2026 07:53:14 -0700 Subject: [PATCH 4/5] Give includeSubDomains and preload Their Own Reasons Co-Authored-By: Claude Opus 5.5 --- deploy/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deploy/README.md b/deploy/README.md index ea8bd18..fef134b 100644 --- a/deploy/README.md +++ b/deploy/README.md @@ -298,7 +298,7 @@ The sites send the same security headers on every response, redirects and the `4 | `X-Content-Type-Options` | `nosniff` | A browser trusts the served `Content-Type` rather than guessing one from the body | | `Referrer-Policy` | `strict-origin-when-cross-origin` | Another site learns only the origin a reader came from, never the path | -The HSTS value carries neither `includeSubDomains` nor `preload`, since each binds hostnames this bundle does not serve. HSTS at the edge stays off for the same reason, because Cloudflare applies it to every name in the zone. +The HSTS value carries neither `includeSubDomains` nor `preload`. `includeSubDomains` would bind every hostname under the site's own, which this bundle does not serve. `preload` asks for the whole domain to be built into browsers, where a removal takes months to reach readers. HSTS at the edge stays off too, because Cloudflare applies it to every name in the zone. **Only the family site sends a `Content-Security-Policy`.** Its page loads few resources, so its policy names each kind: its own files, Google Fonts, inline styles, and `data:` images. Blog posts embed third-party content, so a blog policy waits on a survey of what the posts load. From f1c096050d15df34cbf731624d24086ad0601dcc Mon Sep 17 00:00:00 2001 From: Pieter Viljoen Date: Sat, 24 Oct 2026 07:58:08 -0700 Subject: [PATCH 5/5] Name Edge HSTS as the Host Side's Setting Co-Authored-By: Claude Opus 5.5 --- deploy/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deploy/README.md b/deploy/README.md index fef134b..7ac96cf 100644 --- a/deploy/README.md +++ b/deploy/README.md @@ -298,7 +298,7 @@ The sites send the same security headers on every response, redirects and the `4 | `X-Content-Type-Options` | `nosniff` | A browser trusts the served `Content-Type` rather than guessing one from the body | | `Referrer-Policy` | `strict-origin-when-cross-origin` | Another site learns only the origin a reader came from, never the path | -The HSTS value carries neither `includeSubDomains` nor `preload`. `includeSubDomains` would bind every hostname under the site's own, which this bundle does not serve. `preload` asks for the whole domain to be built into browsers, where a removal takes months to reach readers. HSTS at the edge stays off too, because Cloudflare applies it to every name in the zone. +The HSTS value carries neither `includeSubDomains` nor `preload`. `includeSubDomains` would bind every hostname under the site's own, which this bundle does not serve. `preload` asks for the whole domain to be built into browsers, where a removal takes months to reach readers. HSTS at the edge is the host side's setting, and it stays off because Cloudflare applies it to every name in the zone. **Only the family site sends a `Content-Security-Policy`.** Its page loads few resources, so its policy names each kind: its own files, Google Fonts, inline styles, and `data:` images. Blog posts embed third-party content, so a blog policy waits on a survey of what the posts load.