Generates the nginx rules for prerendered pages
Pages now map to their html file, other forms get one redirect, unknown URLs get a real 404 and responses are compressed. A browser-free test suite runs the rules against a real nginx, in CI only so far. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
- **Feature Slug**: prerendering
|
||||
- **Project Type**: Brownfield
|
||||
- **Start Date**: 2026-10-31T14:15:01Z
|
||||
- **Current Stage**: CONSTRUCTION - Code Generation (unit 3: hosting-and-targets): plan approved; B0 running
|
||||
- **Current Stage**: CONSTRUCTION - Code Generation (unit 3: hosting-and-targets): steps 1 to 5 done; CP1 waits for a CI run; runner mode being checked before dispatch
|
||||
- **Branch**: feature/prerendering (from master c4c2f83); commits and pushes allowed for this feature (owner, 2026-10-31); workflow dispatch without deploy allowed; deploy to test after all units (owner, 2026-11-01), after the nginx config is placed
|
||||
- **Worktree**: K:\Development\SlpSoftware\Projects\AndreaSlopFotografie-prerendering
|
||||
|
||||
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
# Baseline checks: hosting and targets (Step 1, CP0)
|
||||
|
||||
- Commit: `4f32042410a8163b19c2296f99bd85c9ced79538` (branch `feature/prerendering`)
|
||||
- Date: 2026-11-01
|
||||
- Node: v24.16.0; pnpm: 12.11.2
|
||||
- `git status --short`: empty (clean tree; no untracked files reported)
|
||||
|
||||
## Command results
|
||||
|
||||
| Command | Result | Counts and details |
|
||||
|---|---|---|
|
||||
| `pnpm lint` | pass (exit 0) | ESLint: no issues found |
|
||||
| `pnpm format:check` | pass (exit 0) | All matched files use Prettier code style |
|
||||
| `pnpm test` | pass (exit 0) | 130 test files passed (130); 1277 tests passed (1277). Coverage thresholds met: statements 96.12%, branches 94.62%, functions 97.27%, lines 96.59%. fast-check seed: `1618276745` |
|
||||
| `pnpm build && pnpm e2e` | pass (exit 0) | e2e: 9 test files passed (9); 214 tests passed (214); duration 207.73 s. Build completed before the e2e run started (`&&`) |
|
||||
|
||||
Logs: `C:\Users\Bryan\AppData\Local\Temp\claude\k--Development-SlpSoftware-Projects-AndreaSlopFotografie\bb0a550e-5427-462f-b99b-f9db012a172a\scratchpad\b0-test.log` (test run), `C:\Users\Bryan\AppData\Local\Temp\claude\k--Development-SlpSoftware-Projects-AndreaSlopFotografie\bb0a550e-5427-462f-b99b-f9db012a172a\tasks\bbl6g4opx.output` (build and e2e).
|
||||
|
||||
## Tool availability
|
||||
|
||||
- nginx available locally: **no**. `Get-Command nginx` and `where.exe nginx` found nothing; `C:\nginx\nginx.exe` absent; `C:\Users\Bryan\scoop\apps\nginx\current\nginx.exe` absent; `NGINX_BIN` is empty.
|
||||
- scoop: present; `scoop list` shows only `php 8.5.9`.
|
||||
- lftp: **no** (`Get-Command lftp` found nothing).
|
||||
- bash: **yes** (GNU bash 5.2.37, msys; `C:\Users\Bryan\AppData\Local\Microsoft\WindowsApps\bash.exe`).
|
||||
- curl: **yes** (curl 8.12.1 from Git Bash; `C:\WINDOWS\system32\curl.exe` 8.21.0 also present).
|
||||
- podman: machine `podman-machine-default` (wsl) listed, not started (`podman machine list` only, read-only).
|
||||
|
||||
## Checksums (SHA-256)
|
||||
|
||||
- `web/lighthouserc.cjs`: `717c80a2aee64ba534b01bbffcd90b6dceba6fd666dd24fb13d8d4db182bee43`
|
||||
- `web/lighthouserc.desktop.cjs`: `f13d993389babd384177a0a1c601547b356d894ae97ac12177b09229a5318e04`
|
||||
|
||||
## State at the end of Step 1
|
||||
|
||||
- No server or browser left running; port 4173 is free.
|
||||
- Files written by this step: `aidlc-docs/features/prerendering/construction/hosting-and-targets/code/verification-log.md` (V1 to V14 rows, V6 WITHDRAWN) and this file.
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
# Verification log: hosting and targets (unit 3)
|
||||
|
||||
Source of the points: `construction/hosting-and-targets/infrastructure-design/infrastructure-design.md` § 12. Settled-in step: § 3.2 of the code generation plan.
|
||||
|
||||
Status values: OK, BLOCKED, DEVIATION, WITHDRAWN, OPEN.
|
||||
|
||||
| V# | Point | Step | Outcome | Evidence | Status |
|
||||
|---|---|---|---|---|---|
|
||||
| V1 | The generated nginx file loads in a real nginx (`nginx -t`) as an `http`-level include without any other directive from the Pi; `map` before `server` works in `conf.d`. Every directive is checked against the nginx 1.30 documentation (the Pi runs 1.30.6; CI has 1.24) | 3 (documentation), 6 (real nginx) | Documentation part OK; real-nginx part OPEN (no nginx locally; waits for the CI run) | Checked against nginx.org docs on 2026-11-01: map (context http only; exact string beats regex, first regex in file order wins; ~* case-insensitive; no default gives empty), if/return/rewrite (server, location; rewrite permanent = 301, original args appended unless replacement ends in ?), try_files (server, location), error_page (http, server, location; without = keeps the status), internal (location), absolute_redirect (http, server, location; since 1.11.8, default on), autoindex (http, server, location; default off), gzip/gzip_vary/gzip_proxied/gzip_http_version/gzip_comp_level/gzip_min_length/gzip_types (http, server, location; text/html always compressed). The generated file puts map at http level (conf.d include) and all others in server or location. NOT documented by nginx.org: escaping of the rewrite replacement (BR-HST-06 relies on it; settled only by the real nginx test on //evil.example/ and /evil.example/); the safety of if with only return comes from the nginx wiki, not the page. | OPEN |
|
||||
| V2 | Server-level `if ... return 301` and `rewrite ... permanent` responses carry all five headers and `Cache-Control` with real nginx; `absolute_redirect off` gives a relative `Location`; `/` works without an `index` directive | 6, 16 | | | open |
|
||||
| V3 | `/soorten-fotoshoots` (file) and `/soorten-fotoshoots/` (directory) behave as in section 3.1 on nginx and preview; `/assets` and `/assets/` as well | 6, 8, 16 | | | open |
|
||||
| V4 | `/404` and `/404.html` give 404 with the page and the five headers on nginx; `error_page` keeps the status; HEAD works | 6, 16 | | | open |
|
||||
| V5 | A HTTP/1.0 request with `Accept-Encoding: gzip` to the generated block gets `Content-Encoding: gzip` for `.html`, `.js`, `.css`, `.svg`, `.json`, `.xml` (all sizes above 256 bytes) and not for `.woff2`/images | 6, 16 | | | open |
|
||||
| V6 | Withdrawn for this unit (IIS needs a host). The checks move to the "Before go-live" list, U1 to U6 | WITHDRAWN (no host) | | | WITHDRAWN |
|
||||
| V7 | `previewServer.ts`: the new `resolveRequest` contract (redirect result, query handling, `--audit-route`); unit 1 tests for BR-SRV-07 are updated (the "interim" rules become final); `pageFiles.ts` stays the single path to file mapping | 7, 8 | | | open |
|
||||
| V8 | The 301 is followed by Chrome with the query string intact for `?pakket=` and `?shoot=` links, and the hydrated page has 1 title (extend the existing "URL die de server niet kent en de router wel" e2e) | 17 | | | open |
|
||||
| V9 | One Lighthouse run of the 404 page on the preview audit route, and (as comparison) `/404.html` with `ignoreStatusCode`; record best-practices for both, then keep the simpler passing option (O2) | 23 (measurement-final.md) | | | open |
|
||||
| V10 | lftp: dry run against a `file:` target proves that pass 1 skips all nested `*.html` and `web.config`, pass 2 uploads them, pass 3 deletes only stale files | 14 | | | open |
|
||||
| V11 | `verify-deployment.sh` fails against a copy of the old nginx config (home page for `/over-mij`) and passes against the new one | 13 | | | open |
|
||||
| V12 | CI: the `lighthouse` job (or a new `server-rules` job) installs nginx, `pnpm e2e` includes `serverRules.e2e.ts`, and the job fails if nginx is missing | 5, 16 | CI step added (lighthouse job): apt-get install nginx lftp, service nginx stop, nginx -v; Browsertests step has CI=true; serverRules.e2e.ts fails with "nginx ontbreekt in CI (BR-HST-24)" when nginx is missing. Gate proven locally with CI=true and no nginx (1 failed, as intended) and without CI (skip line, exit 0). The real CI run is still to come. | e2e/serverRules.e2e.ts; .gitea/workflows/continuous_integration.yaml; CI run pending | OPEN |
|
||||
| V13 | `lighthouserc.cjs`: the exception table is empty on delivery unless an owner decision exists; P-HST-11 passes; `pnpm lighthouse` still starts the preview with `--audit-route` and `Local` appears for `startServerReadyPattern` | 11, 12 | | | open |
|
||||
| V14 | The generated header comment fits the Pi: install path `/etc/nginx/conf.d/andreaslop-test.conf` (included from `nginx.conf:38`), no `sites-enabled`, no global `nginx.conf` change; the file works for a first install and for an update of an existing file | 3 | Header comment rewritten: install path /etc/nginx/conf.d/andreaslop-test.conf, included in http {} from nginx.conf, no sites-enabled, no global nginx.conf change, own gzip block because the Pi has none, works behind an HTTP/1.0 proxy, 444 from 00-default.conf for an unknown host (old WordPress remark removed), server_name and root adaptable, no default_server. The same file serves a first install and an update (it replaces the existing file in place). | Generated deploy/nginx/andreaslop-test.conf (lines 1-12); equals nginxTestConf() (serverConfig.test.ts sync test green) | OK |
|
||||
+2
@@ -78,6 +78,8 @@ The proxy Pi handles TLS through certbot and forwards `test.andreaslop.nl` to `1
|
||||
| `proxy_cache` | An old SPA `index.html` could stay cached for `/over-mij` |
|
||||
| `proxy_redirect` | Could change the relative 301s |
|
||||
|
||||
**Checked by the owner on 2026-11-01, reported through the Pi-Main session: no change needed on the proxy Pi.** The server block has `proxy_pass http://192.168.1.103` with Host, X-Forwarded-Proto, X-Forwarded-For and X-Real-IP, and no `proxy_http_version` (so HTTP/1.0 upstream), no change to `Accept-Encoding`, no `proxy_intercept_errors` and no `add_header`. At http level there is no gzip, `proxy_cache`, `add_header` or `proxy_buffering`. So `gzip_http_version 1.0` must stay in the new block, all headers and the 404 page come from the hosting Pi, and no cache holds old pages. `http2 on;` in the 443 block is an optional, separate improvement, out of scope for this feature.
|
||||
|
||||
The proxy passes an already compressed response through unchanged. If the owner wants gzip for all sites, WordPress included, the proxy Pi is the place for that, and this block can keep its own.
|
||||
|
||||
## Points for the generated config
|
||||
|
||||
+9
-5
@@ -155,7 +155,7 @@ PBT-06 (stateful): none; the redirect function is stateless. PBT-07 (generators)
|
||||
|
||||
## Part A: Setup and baseline (batch B0, Haiku, exclusive)
|
||||
|
||||
### Step 1: Confirm a green baseline and create the log [ ]
|
||||
### Step 1: Confirm a green baseline and create the log [x]
|
||||
|
||||
- Executor: Haiku.
|
||||
- Implements: NFR-PR-Q-01 (baseline), setup.
|
||||
@@ -174,7 +174,7 @@ PBT-06 (stateful): none; the redirect function is stateless. PBT-07 (generators)
|
||||
|
||||
The riskiest mechanism is the nginx block (a `map`, a server-level `if` and `rewrite`, `error_page` with an internal location, `try_files` without `$uri/`, a custom gzip setup behind a proxy). It is built in its real form and proven with a real nginx process before the rest. Reading the config is not a proof.
|
||||
|
||||
### Step 2: Shared URL and type modules (BR-HST-04, 06, 11) [ ]
|
||||
### Step 2: Shared URL and type modules (BR-HST-04, 06, 11) [x]
|
||||
|
||||
- Executor: Sonnet.
|
||||
- Implements: BR-HST-03, 04, 06, 11; P-HST-02, 03, 04 (function level).
|
||||
@@ -186,8 +186,9 @@ The riskiest mechanism is the nginx block (a `map`, a server-level `if` and `rew
|
||||
4. `canonicalUrls.test.ts`: example-based table (the redirect rows of infrastructure-design.md § 3.1) and properties: P-HST-02 (every `pageVariant` returns the canonical page, `(invariant)`), P-HST-03 (the result is a fixpoint: `canonicalRedirect(result)` is `undefined`, and `stripTrailingSlashes(result)` is `undefined`, `(idempotent)`; the combined function used by the resolver needs at most 2 hops for any `pageVariant` or `unknownPath` plus slashes), P-HST-04 (a target starts with `/`, never `//` or `/\`, has no control characters, and is one of `pagePaths`, `(invariant)`; run it also over `hostilePath`: a non-`undefined` result is still one of `pagePaths`).
|
||||
- Done when: `pnpm exec vitest run config/canonicalUrls.test.ts` green; `pnpm exec tsc --noEmit`, `pnpm lint` clean; `pnpm exec prettier --check` on the new files clean.
|
||||
- Record: one line with the exported names.
|
||||
- Done. `canonicalUrls.ts`: pagePaths, redirectNames, escapeRegex, variantPattern, canonicalRedirect, stripTrailingSlashes. `compressibleTypes.ts`: FileType, compressibleTypes, plainTypes, compressibleExtensions, gzipMimeTypes. `src/test/urlArbitraries.ts`: knownPage, caseVariant, pageVariant, unknownPath, hostilePath, queryString. stripTrailingSlashes returns undefined when the stripped target would start with // or / or hold control characters (BR-HST-06), so the resolver treats such a path as unknown.
|
||||
|
||||
### Step 3: The nginx block (BR-HST-01 to 09, 11 to 13; V14) [ ]
|
||||
### Step 3: The nginx block (BR-HST-01 to 09, 11 to 13; V14) [x]
|
||||
|
||||
- Executor: Sonnet.
|
||||
- Implements: BR-HST-01 to 09, 11 to 13; FR-PR-14, 16, 23; V1 (documentation part), V14.
|
||||
@@ -200,8 +201,9 @@ The riskiest mechanism is the nginx block (a `map`, a server-level `if` and `rew
|
||||
5. Run `pnpm server-config`. Update the three `serverConfig.test.ts` tests that § 6 lists for nginx (they assert the old SPA fallback and the location count) with stricter replacements; the rest of the test file is unchanged and must pass.
|
||||
- Done when: `pnpm exec vitest run config/serverConfig.test.ts` green (the IIS SPA-fallback test is still the old one and still passes because Step 9 has not run); the committed `deploy/nginx/andreaslop-test.conf` equals `nginxTestConf()`; `pnpm exec tsc --noEmit`, `pnpm lint` clean.
|
||||
- Record: verification log V1 (documentation), V14.
|
||||
- Done. V1 documentation part and V14 recorded. The three serverConfig tests of section 6 (noindex/try_files, location count) changed and are stricter. The nginx.org rewrite page does not document escaping of the replacement; BR-HST-06 relies on it and the real nginx test must show it.
|
||||
|
||||
### Step 4: Fixture site, nginx harness and the first contract test (BR-HST-24) [ ]
|
||||
### Step 4: Fixture site, nginx harness and the first contract test (BR-HST-24) [x]
|
||||
|
||||
- Executor: Sonnet.
|
||||
- Implements: BR-HST-24; V1 to V5 (tests); P-HST-09 (first version).
|
||||
@@ -212,8 +214,9 @@ The riskiest mechanism is the nginx block (a `map`, a server-level `if` and `rew
|
||||
3. `serverRules.e2e.ts`: `describe.skipIf`-style gate: if `findNginx()` is undefined, then when `process.env.CI` is set the suite **fails** with the message "nginx ontbreekt in CI (BR-HST-24)", otherwise it is skipped and prints one visible line `nginx niet gevonden: serverregeltests overgeslagen (zie BR-HST-24)`. First version tests, against real nginx and the fixture: every row of infrastructure-design.md § 3.1 (status, `Location` path+query, which fixture file was served by the marker text, `404.html` body on 404); the five security headers + `Cache-Control` + `X-Robots-Tag` on 200, 301 and 404 responses (V2, V4); `/soorten-fotoshoots` serves the file and `/soorten-fotoshoots/` redirects (V3); `/` works without an `index` directive; HEAD on a page and on an unknown URL; `/robots.txt` returns `Disallow: /`; `Content-Encoding: gzip` for `.html`, `.js`, `.css`, `.svg`, `.json`, `.xml`, `.txt`, none for `.woff2` and `.png`, in both mime variants (V5); a raw HTTP/1.0 request over `node:net` with `Accept-Encoding: gzip` also gets gzip; `Vary: Accept-Encoding` present; `/assets/*` has exactly **one** `Cache-Control` header, `public, max-age=31536000, immutable` (count the raw header lines through `node:http` `rawHeaders`, not through the merged `fetch` Headers object), all else `no-cache`; the full header set is present on a 301, on the 404 page, on `/404` and `/404.html` (the `error_page` path) and on `/assets/*`; hostile paths (`//evil.example/`, `/\evil.example`) never yield a 3xx whose `Location` starts with `//` or `/\`.
|
||||
- Done when: `pnpm exec tsc --noEmit`, `pnpm lint` clean; `pnpm exec vitest run --config vitest.e2e.config.ts e2e/serverRules.e2e.ts` either passes against a local nginx (if Step 1 found one) or prints the skip line (no nginx locally) and exits 0 outside CI; with `CI=true` and no nginx it fails with the message above (run it once to prove the gate; then unset `CI`).
|
||||
- Record: which nginx version ran, or "skipped: no local nginx".
|
||||
- Skipped: no local nginx. Gate proven: without CI one visible skip line, exit 0; with CI=true the suite fails with "nginx ontbreekt in CI (BR-HST-24)". The harness has never started a real nginx (only type-checked), so a first CI run may still show harness defects.
|
||||
|
||||
### Step 5: Install nginx and lftp in the CI job (V12) [ ]
|
||||
### Step 5: Install nginx and lftp in the CI job (V12) [x]
|
||||
|
||||
- Executor: Sonnet.
|
||||
- Implements: BR-HST-24; V12.
|
||||
@@ -221,6 +224,7 @@ The riskiest mechanism is the nginx block (a `map`, a server-level `if` and `rew
|
||||
- Do: in job `lighthouse`, before the `Browsertests` step add a step "Install nginx and lftp (serverregeltests)": `sudo apt-get update && sudo apt-get install -y nginx lftp`, then stop a service the package may have started (`sudo service nginx stop || true`), then `nginx -v`. Give the `Browsertests` step `CI: 'true'` in its `env` (so a missing nginx fails the job; do not rely on the runner setting it). Do not touch the deploy jobs yet (Step 15). Keep the file's Dutch comment style and explain why the packages are installed (the Ubuntu runner image carries nginx 1.24; the Pi runs 1.30.6; accepted gap, BR-HST-24).
|
||||
- Done when: the YAML parses (`pnpm exec prettier --check ../.gitea/workflows/continuous_integration.yaml` or, if prettier rejects the path, `node -e` with the `yaml` parser is NOT available: use `pnpm exec prettier --parser yaml --check` on the file contents via stdin); the diff shows only the new step and the env line.
|
||||
- Record: the exact diff.
|
||||
- Done: one new step "Install nginx and lftp (serverregeltests)" before Browsertests, plus `CI: 'true'` in the env of Browsertests, with Dutch comments. See `git diff .gitea`.
|
||||
|
||||
### Step 6: Checkpoint CP1: the nginx proof [ ] STOP-AND-ASK if no local nginx
|
||||
|
||||
|
||||
Reference in New Issue
Block a user