-# Gecode Website (Astro + GitHub Pages)
+# Gecode Website (Astro + Cloudflare Workers)
This repository hosts the Gecode website and is built with Astro and Tailwind
CSS 4. React is available for future interactive islands, but the current site
@@ -52,8 +52,8 @@ This command:
- checks content transformations, metadata, and canonical URLs
- validates the documentation and redirect Workers
-For the GitHub Pages artifact, including the mailing-list archive but excluding
-documentation now served from R2, run:
+For the deployed website, including the mailing-list archive but excluding
+documentation served from R2, run:
```bash
npm run build:pages
@@ -65,8 +65,14 @@ The legacy rollback/comparison build still copies both frozen archives:
npm run build:deploy
```
-That legacy artifact exceeds GitHub Pages' 1 GB published-site limit and must
-not be used by the production workflow.
+That legacy artifact must not be used by the production workflow.
+
+## Deployment
+
+Pushes to `main` build the site and deploy `_site` to the `gecode-website`
+Cloudflare Worker (static assets) on `www.gecode.dev`. See
+[Website hosting and TLS](docs/operations.md#website-hosting-and-tls) for the
+setup, rollback and monitoring.
## Notes on Scope
diff --git a/_headers b/_headers
new file mode 100644
index 000000000..54ee9cb88
--- /dev/null
+++ b/_headers
@@ -0,0 +1,4 @@
+# Workers Static Assets response headers.
+# Astro fingerprints these files, so their content never changes.
+/_astro/*
+ Cache-Control: public, max-age=31536000, immutable
diff --git a/docs/deployment-runbook.md b/docs/deployment-runbook.md
index af7a2a08e..bcb13292f 100644
--- a/docs/deployment-runbook.md
+++ b/docs/deployment-runbook.md
@@ -12,12 +12,15 @@ The tested R2 Worker now serves generated documentation in production. The
Astro artifact pairs a redirect Worker for classic active `.html` URLs with
small Pages fallback files.
-As checked on 5 September 2026, Cloudflare is authoritative for `gecode.dev`.
-Cloudflare proxies the apex GitHub Pages A records and the `www` CNAME to
-`gecode.github.io` with Full (strict) TLS and Always Use HTTPS. GitHub Pages
-serves the Astro active website and mail archive. All nine historical
+Cloudflare is authoritative for `gecode.dev`. Since 16 November 2026 the
+website is served by the `gecode-website` Worker (static assets only) on the
+`www.gecode.dev` Custom Domain, and a Cloudflare redirect rule sends the apex to
+`www`. GitHub Pages no longer serves any part of the site. All nine historical
documentation versions and both latest aliases use R2. Classic active-site
-URLs redirect to their canonical directory URLs through the redirect Worker.
+URLs redirect to their canonical directory URLs through the redirect Worker and
+the website's `_redirects` file. See [Website hosting and
+TLS](operations.md#website-hosting-and-tls) for the setup, deployment and
+rollback.
Cloudflare Email Routing is ready. Its managed MX, SPF, and DKIM records are
authoritative, both forwarding destinations are verified, and the catch-all
@@ -303,11 +306,9 @@ old URLs when that Worker is unavailable.
8. Watch Pages, Worker, and R2 errors and documentation 404s during the first
day.
-After the Astro deployment is stable, restore automatic Pages deployment for
-default-branch pushes in a separate reviewed change.
-
-GitHub Pages receives an artifact comfortably below its 1 GB published-site
-limit because generated documentation is no longer copied into it.
+Pushes to `main` now deploy the website automatically to the `gecode-website`
+Worker. The phase descriptions above refer to the GitHub Pages hosting used
+until November 2026.
## 7. Complete release automation
@@ -366,7 +367,7 @@ Monitor these signals during the first day and review them monthly afterward:
- documentation 404 and 503 responses;
- cache hit ratio and R2 Class A/Class B operations;
- R2 Standard storage, including the size of `staging/`;
-- GitHub Pages origin availability; and
+- website Worker deployments and edge certificate expiry; and
- Cloudflare Email Routing delivery failures.
Keep a release manifest and a recoverable source for every immutable version.
@@ -376,6 +377,10 @@ bucket-wide deletion.
## Rollback
+The website rolls back to an earlier Worker version; see [Website hosting and
+TLS](operations.md#website-hosting-and-tls). The paragraphs below describe the
+migration-era Pages rollback and are kept for history.
+
During the first canary, remove the canary route to return that version to the
existing GitHub Pages archive. Before the Astro cutover, remove the production
documentation routes for the same rollback. If Astro itself must be rolled
diff --git a/docs/operations.md b/docs/operations.md
index 6ef698947..e187fe615 100644
--- a/docs/operations.md
+++ b/docs/operations.md
@@ -15,7 +15,7 @@ and caps each response read at 1 MB. It never downloads the complete PDF.
Transient failures get two retries, twenty seconds apart. Persistent failures
fail the workflow and leave the failing path in its log. Check the failed path,
-the latest Pages and Worker deployments, and Cloudflare Workers logs. A version
+the latest website and Worker deployments, and Cloudflare Workers logs. A version
or revision mismatch can mean the checked-in promotion has not reached
production yet. Use the deployment runbook for rollback; this workflow never
changes traffic automatically.
@@ -59,6 +59,84 @@ every failure generated by the documentation Worker or R2. A Workers
Observability notification also needs an actual alert rule; the notification
destination alone does not monitor errors.
+## Website hosting and TLS
+
+Since November 2026 the website no longer uses GitHub Pages. Cloudflare serves
+everything under `gecode.dev`, and no origin certificate is involved:
+
+- `www.gecode.dev` is a Workers Custom Domain on `gecode-website`, a Worker
+ with static assets only (no script) built from `_site`. Its configuration is
+ `workers/website/wrangler.jsonc`.
+- More specific Worker routes on `www` take precedence over the Custom Domain:
+ `gecode-documentation` owns `/doc*` and `/robots.txt*`, and
+ `gecode-classic-url-redirects` owns the classic `.html` URLs and `/e/*`.
+ When they pass a request on with `fetch()`, it reaches the website Worker.
+- `_site/_redirects` (generated by `scripts/create-classic-redirects.mjs`)
+ sends `/page` and `/page.html` to `/page/` with a 308. `_headers` marks the
+ fingerprinted `/_astro/*` files as immutable.
+- The apex `gecode.dev` has a proxied placeholder record (`AAAA 100::`) and a
+ Single Redirect rule. The rule sends HTTP and HTTPS requests to
+ `https://www.gecode.dev/` with a 301 and keeps the query string.
+- Cloudflare Universal SSL issues and renews the edge certificates. The zone
+ should use **Full (strict)**; it has no external origin.
+
+Static asset requests are free and unlimited on Workers Free, so the website
+does not count against the daily Worker request limit unless a route Worker
+runs first. A version may hold at most 20,000 files; the build has about
+12,200, mostly the users archive.
+
+### Deployment
+
+A push to `main` runs `.github/workflows/pages.yml` ("Build and deploy
+website"). It builds and checks the site, uploads the `_site` artifact, then
+runs `wrangler deploy --env production` in the `website-production`
+environment and finishes with `scripts/check-availability.mjs`. The
+environment accepts only `main` and holds two secrets:
+
+- `CLOUDFLARE_ACCOUNT_ID`;
+- `CLOUDFLARE_API_TOKEN`: the account token `gecode-website-deploy`, created on
+ 16 November 2026 without expiry. It has Workers Scripts Write and Account
+ Settings Read on the Gecode account, and Zone Read and Workers Routes Write
+ on `gecode.dev`. It cannot change DNS, SSL or rules.
+
+The same build can be deployed by hand from the Workers workflow
+(`worker=website`) to `www-staging.gecode.dev` or, with the
+`cloudflare-production` approval, to production.
+
+### Rollback
+
+Every deploy creates a new Worker version. Roll back without rebuilding:
+
+```sh
+npx wrangler deployments list --name gecode-website
+npx wrangler rollback --name gecode-website
+```
+
+Alternatively, rerun an earlier successful "Build and deploy website" run, or
+in the dashboard choose Workers & Pages, `gecode-website`, Deployments.
+Wrangler needs a token for the Gecode account; local OAuth login may only
+cover a personal account.
+
+### Monitoring
+
+The availability check fetches `/news/` with a unique query string, so each
+run reaches the deployed assets. It checks the apex redirect, and fails when
+either edge certificate has fewer than 14 days left. Universal SSL normally
+renews 30 days before expiry, so a failure means renewal is stuck.
+
+### Incident, November 2026
+
+GitHub Pages issued the original origin certificate in August 2026, before
+Cloudflare proxied the domain. Pages cannot renew a certificate for a proxied
+domain, because its eligibility check requires the records to resolve to
+GitHub. The renewal stalled at `bad_authz`, and the certificate expired on
+7 November. Cloudflare in Full (strict) mode then returned HTTP 526 for every
+uncached page. Toggling the records to DNS only and re-adding the custom domain
+did not clear the order. On 12 November the SSL mode was lowered to Full as a
+stopgap. On 16 November the website moved to Workers Static Assets, the apex
+moved to a Cloudflare redirect rule, and the GitHub Pages A records were
+deleted.
+
## CDN cache policy
The Cloudflare zone's Browser Cache TTL is set to **Respect Existing Headers**.
@@ -71,6 +149,12 @@ Two active Cache Rules refine that default:
origin cache headers, and uses Cloudflare's status-code TTL when the origin
sends no cache header.
+Both rules were written for the GitHub Pages origin. Responses from the website
+Worker's static assets do not go through the zone cache, so the Cache Rules no
+longer affect them. Static assets
+have their own edge caching, and `_headers` sets the browser policy. The two
+rules can be removed once nothing depends on them.
+
Keep `/doc*` out of the website rule. The documentation Worker owns its cache
policy. The prepared Workers Cache change gives selected routes and aliases
thirty days of edge freshness plus seven days of stale-while-revalidate, while
@@ -97,7 +181,7 @@ separately from billable requests and zone cache hits.
An external CDN can avoid Cloudflare requests on cache hits. A concrete option
is Fastly Full Site Delivery at `www.gecode.dev`, with documentation misses sent
to a dedicated Cloudflare Worker origin hostname and website misses sent to
-GitHub Pages. This is a researched option, not a provisioned or tested service.
+the website Worker. This is a researched option, not a provisioned or tested service.
Use Fastly's [Surrogate-Control header](https://www.fastly.com/documentation/reference/http/http-headers/Surrogate-Control/)
for the long edge TTL and SWR policy; Cloudflare's edge-only header does not
diff --git a/package.json b/package.json
index 0ff2b00fa..88ca3c9fa 100644
--- a/package.json
+++ b/package.json
@@ -16,7 +16,8 @@
"check:docs-hosting": "npm run test:docs-tools && npm run test:docs-worker && npm run check:docs-worker",
"check:docs-worker": "wrangler deploy --dry-run --env canary --config workers/docs/wrangler.jsonc --outdir .wrangler/docs-canary-dry-run && wrangler deploy --dry-run --env production --config workers/docs/wrangler.jsonc --outdir .wrangler/docs-dry-run",
"check:email-worker": "wrangler deploy --dry-run --config workers/email/wrangler.jsonc --outdir .wrangler/email-dry-run",
- "check:redirect-worker": "wrangler deploy --dry-run --env production --config workers/redirects/wrangler.jsonc --outdir .wrangler/redirects-dry-run",
+ "check:website-worker": "wrangler deploy --dry-run --env production --config workers/website/wrangler.jsonc --outdir .wrangler/website-dry-run",
+ "check:redirect-worker": "wrangler deploy --dry-run --env production --config workers/redirects/wrangler.jsonc --outdir .wrangler/redirects-dry-run",
"check:mode": "./scripts/check-executable-bits.sh",
"check:quality": "npm run build && npm run check:mode && npm run check:html && npm run check:canonical-urls && npm run check:site-semantics && npm run test:content && npm run check:docs-hosting && npm run test:redirect-worker && npm run check:redirect-worker && npm run test:email-worker && npm run check:email-worker",
"dev": "node ./scripts/dev.mjs",
diff --git a/scripts/check-availability.mjs b/scripts/check-availability.mjs
index 3474394b6..2d6dfc108 100644
--- a/scripts/check-availability.mjs
+++ b/scripts/check-availability.mjs
@@ -1,7 +1,11 @@
import assert from "node:assert/strict";
import { readFile } from "node:fs/promises";
+import { connect } from "node:tls";
const origin = "https://www.gecode.dev";
+// Cloudflare Universal SSL renews edge certificates well before expiry.
+// Less than 14 days left means renewal has failed; see docs/operations.md.
+const minCertificateDays = 14;
const config = JSON.parse(await readFile("workers/docs/wrangler.jsonc", "utf8")).env.production.vars;
const version = config.LATEST_DOC_VERSION;
const revision = JSON.parse(config.DOC_REVISIONS ?? "{}")[version];
@@ -43,6 +47,21 @@ function docsHeaders(response, relative, indexable) {
? `<${origin}/doc/latest/${relative}>; rel="canonical"` : null, "Documentation canonical");
}
+// Check the public edge certificate directly so a failed renewal is reported
+// before browsers start rejecting it.
+function edgeCertificate(servername) {
+ return new Promise((resolvePromise, reject) => {
+ const socket = connect({ host: servername, port: 443, servername });
+ socket.setTimeout(10_000, () => socket.destroy(new Error("TLS timeout")));
+ socket.once("error", reject);
+ socket.once("secureConnect", () => {
+ const certificate = socket.getPeerCertificate();
+ socket.end();
+ resolvePromise(certificate);
+ });
+ });
+}
+
for (const path of ["/", "/download/"]) {
await check(path, 200, async (response) => {
assert.match(response.headers.get("content-type"), /text\/html/);
@@ -52,6 +71,10 @@ for (const path of ["/", "/download/"]) {
assert(!/\bnoindex\b/i.test(response.headers.get("x-robots-tag") ?? ""), "Website must remain indexable");
});
}
+await check(`/news/?availability=${Date.now()}`, 200, async (response) => {
+ assert.match(response.headers.get("content-type"), /text\/html/);
+ assert.match((await bytes(response)).toString(), / {
assert.equal(response.headers.get("location"), `${origin}/download/?availability=1`);
});
@@ -113,4 +136,19 @@ if (revision) {
assert((await bytes(response)).length > 0, "Modeling search runtime");
});
}
+const apex = await fetch("https://gecode.dev/news/?availability=1", {
+ redirect: "manual", signal: AbortSignal.timeout(10_000),
+});
+assert.equal(apex.status, 301, "Apex redirect status");
+assert.equal(apex.headers.get("location"), `${origin}/news/?availability=1`, "Apex redirect target");
+console.log("GET https://gecode.dev/news/?availability=1: 301");
+
+for (const servername of ["www.gecode.dev", "gecode.dev"]) {
+ const certificate = await edgeCertificate(servername);
+ const days = (Date.parse(certificate.valid_to) - Date.now()) / 86_400_000;
+ assert(days >= minCertificateDays,
+ `Edge certificate for ${servername} expires ${certificate.valid_to} (${days.toFixed(1)} days)`);
+ console.log(`TLS ${servername}: valid until ${certificate.valid_to} (${Math.floor(days)} days)`);
+}
+
console.log(`Production availability passed: documentation ${version}, revision ${revision ?? "legacy"}.`);
diff --git a/scripts/check-canonical-urls.mjs b/scripts/check-canonical-urls.mjs
index aea45d1d6..0d8d298ff 100644
--- a/scripts/check-canonical-urls.mjs
+++ b/scripts/check-canonical-urls.mjs
@@ -36,15 +36,12 @@ for (const route of routes) {
}
}
+const redirectRules = new Set((await readFile(path.join(siteRoot, "_redirects"), "utf8")).trim().split("\n"));
+if (!redirectRules.has("/index.html / 308")) failures.push("_redirects: expected /index.html / 308");
for (const route of routes.filter((route) => route.file !== "index.html")) {
- const classicFile = route.file.replace(/\/index\.html$/, ".html");
- const html = await readFile(path.join(siteRoot, classicFile), "utf8");
- const destination = `https://www.gecode.dev${route.canonical}`;
- if (!html.includes(``)) {
- failures.push(`${classicFile}: expected redirect canonical ${destination}`);
- }
- if (!html.includes(`http-equiv="refresh" content="0;url=${route.canonical}"`)) {
- failures.push(`${classicFile}: expected redirect to ${route.canonical}`);
+ const page = route.canonical.slice(0, -1);
+ for (const rule of [`${page}.html ${route.canonical} 308`, `${page} ${route.canonical} 308`]) {
+ if (!redirectRules.has(rule)) failures.push(`_redirects: expected ${rule}`);
}
}
diff --git a/scripts/create-classic-redirects.mjs b/scripts/create-classic-redirects.mjs
index 9a181daed..31f263c0f 100644
--- a/scripts/create-classic-redirects.mjs
+++ b/scripts/create-classic-redirects.mjs
@@ -1,38 +1,22 @@
#!/usr/bin/env node
-import { mkdir, writeFile } from "node:fs/promises";
+import { writeFile } from "node:fs/promises";
import path from "node:path";
-import { activePageSlugs, site } from "../src/data/site.ts";
+import { activePageSlugs } from "../src/data/site.ts";
import { getPublications } from "../src/lib/legacy-content.ts";
+// Workers Static Assets evaluates _redirects before matching files. The
+// classic URL redirect Worker answers these paths first; these rules keep the
+// redirects working when that Worker fails open, and give the canonical pages
+// a permanent redirect when requested without the trailing slash.
const siteRoot = path.resolve(process.argv[2] ?? "_site");
-const redirects = [
- ...activePageSlugs.map((slug) => ({ source: `${slug}.html`, destination: `/${slug}/` })),
- ...(await getPublications()).map((publication) => ({
- source: `publications/${publication.slug}.html`,
- destination: `/publications/${publication.slug}/`,
- })),
+const pages = [
+ ...activePageSlugs.map((slug) => `/${slug}`),
+ ...(await getPublications()).map((publication) => `/publications/${publication.slug}`),
+];
+const rules = [
+ "/index.html / 308",
+ ...pages.flatMap((page) => [`${page}.html ${page}/ 308`, `${page} ${page}/ 308`]),
];
-for (const redirect of redirects) {
- const filename = path.join(siteRoot, redirect.source);
- const canonical = new URL(redirect.destination, site.url).href;
- const html = `
-
-
-
-
-
-
- Redirecting…
-
-
-
-