From 8f3b6523e9cd4dd284cab756fd85179280609710 Mon Sep 17 00:00:00 2001 From: Eric Dahl Date: Thu, 3 Dec 2026 01:51:24 -0500 Subject: [PATCH 1/2] Website: /guides, /mixers and /images no longer redirect in a loop Each is a folder in the export, not a page. nginx redirected /guides to /guides/ (its own folder rule), and the trailing-slash rule sent /guides/ back to /guides, forever: a browser showed "too many redirects". - /guides and /guides/ go to the guides hub, /guides/record (301). - The catch-all location no longer tries a folder, so /mixers, /images and /_next are a 404. "/" is unchanged. tests/nginx-redirects.sh checks these against the real nginx in CI; tests/folderRedirects.test.ts pins the rules. The nginx rules were not run locally (no Docker on this machine). Co-Authored-By: Claude Fable 5.2 Claude-Session: https://claude.ai/code/session_01VCgWWseQZtUzcSRzjqqQJQ --- website/README.md | 2 ++ website/nginx.conf | 10 ++++++++-- website/tests/folderRedirects.test.ts | 23 +++++++++++++++++++++++ website/tests/nginx-redirects.sh | 18 ++++++++++++++++++ 4 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 website/tests/folderRedirects.test.ts diff --git a/website/README.md b/website/README.md index f6e2a89e..c3302ba1 100644 --- a/website/README.md +++ b/website/README.md @@ -126,6 +126,8 @@ Coolify's proxy terminates TLS. nginx then: - serves clean URLs: `/privacy` from `privacy.html` - redirects any trailing slash and any `.html` address to the clean URL (301): `/privacy/` and `/privacy.html` to `/privacy`, `/docs/usb-drive.html` to `/docs/usb-drive`, `/index.html` to `/` +- redirects `/guides` to the guides hub, `/guides/record` (301); any other folder that is not a page + (`/mixers`, `/images`) is a 404 - redirects `www.showrecorder.app` to `https://showrecorder.app` with the same path (301) - caches `/_next/static/` for a year (immutable, hashed file names) and everything else for 5 minutes diff --git a/website/nginx.conf b/website/nginx.conf index 4c91a797..136573f2 100644 --- a/website/nginx.conf +++ b/website/nginx.conf @@ -95,9 +95,15 @@ server { return 301 $1$is_args$args; } + # /guides is a folder, not a page: the guides start at /guides/record. People shorten a guide's address by hand. + location = /guides { return 301 /guides/record; } + location = /guides/ { return 301 /guides/record; } + location / { - # /privacy is served from privacy.html. - try_files $uri $uri.html $uri/ =404; + # /privacy is served from privacy.html. No "$uri/": a folder that is not a page (/mixers, /images, /_next) + # is a 404. With it, nginx sent /mixers to /mixers/ and the trailing-slash rule above sent it back, forever. + # "/" itself still matches $uri and is served from index.html. + try_files $uri $uri.html =404; } # Mixer pages as above; an address that is not a page tries the mistyped-mixer redirect. diff --git a/website/tests/folderRedirects.test.ts b/website/tests/folderRedirects.test.ts new file mode 100644 index 00000000..c1467115 --- /dev/null +++ b/website/tests/folderRedirects.test.ts @@ -0,0 +1,23 @@ +import { readFileSync } from "node:fs"; +import path from "node:path"; +import { GUIDES_HUB } from "@/lib/mixerGuides"; + +const ROOT = path.resolve(__dirname, ".."); +const conf = readFileSync(path.join(ROOT, "nginx.conf"), "utf8"); + +// /guides, /mixers, /images and /_next are folders in the export, not pages. nginx used to redirect each to itself +// with a slash, and the trailing-slash rule sent it straight back: a loop (found 2026-12-03). tests/nginx-redirects.sh +// runs the real nginx; this pins the two rules it depends on. +describe("folders that are not pages", () => { + it("are not tried by the catch-all location, so they are a 404 and never a slash redirect", () => { + const catchAll = conf.match(/location \/ \{[\s\S]*?\}/)?.[0] ?? ""; + expect(catchAll).toMatch(/try_files \$uri \$uri\.html =404;/); + expect(catchAll).not.toMatch(/try_files[^;]*\$uri\/[ ;]/); + }); + + it("send /guides, with or without a slash, to the guides hub", () => { + expect(GUIDES_HUB).toBe("/guides/record"); + expect(conf).toContain(`location = /guides { return 301 ${GUIDES_HUB}; }`); + expect(conf).toContain(`location = /guides/ { return 301 ${GUIDES_HUB}; }`); + }); +}); diff --git a/website/tests/nginx-redirects.sh b/website/tests/nginx-redirects.sh index 684a09a1..3a91ead5 100755 --- a/website/tests/nginx-redirects.sh +++ b/website/tests/nginx-redirects.sh @@ -12,6 +12,12 @@ mkdir "$root/mixers" echo x32 >"$root/mixers/x32.html" echo xr18 >"$root/mixers/xr18.html" echo later >"$root/mixers/x32-later.html" +# Folders the export has: /guides and /guides/record hold pages, /images holds files. guides/record is both a +# page (record.html) and a folder. +mkdir -p "$root/guides/record" "$root/images" +echo hub >"$root/guides/record.html" +echo x32guide >"$root/guides/record/x32.html" +echo shot >"$root/images/shot.jpg" # mktemp -d is 0700: on Linux (CI) nginx's worker user can't read it and every page 404s. Docker Desktop on a # Mac hid this. chmod -R a+rX "$root" @@ -53,4 +59,16 @@ check '/mixers/x32-later' 200 '' check '/mixers/x32/' 301 '/mixers/x32' check '/mixers/wing' 404 '' check '/mixers/x32Tell/more' 301 '/mixers/x32' +# A folder that is not a page is a 404, never a redirect to itself with a slash and back (a loop until 2026-12-03). +check '/' 200 '' +check '/mixers' 404 '' +check '/mixers/' 301 '/mixers' +check '/images' 404 '' +check '/images/' 301 '/images' +# /guides goes to the guides hub. +check '/guides' 301 '/guides/record' +check '/guides/' 301 '/guides/record' +check '/guides/record' 200 '' +check '/guides/record/' 301 '/guides/record' +check '/guides/record/x32' 200 '' exit "$fail" From f3de6f69f093b37edf11512942f18cb2874be4c6 Mon Sep 17 00:00:00 2001 From: Eric Dahl Date: Thu, 3 Dec 2026 02:03:24 -0500 Subject: [PATCH 2/2] Website: the home page gets its own nginx rule Without "$uri/" in try_files the catch-all location does not find "/", which is a folder too (the same change on soundcheckplayer.app answered 404 for the home page in CI). "location = /" serves index.html directly, and tests/nginx-redirects.sh checks "/" with and without a query string. Co-Authored-By: Claude Fable 5.2 Claude-Session: https://claude.ai/code/session_01VCgWWseQZtUzcSRzjqqQJQ --- website/nginx.conf | 6 +++++- website/tests/folderRedirects.test.ts | 5 +++++ website/tests/nginx-redirects.sh | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/website/nginx.conf b/website/nginx.conf index 136573f2..abf71f03 100644 --- a/website/nginx.conf +++ b/website/nginx.conf @@ -99,10 +99,14 @@ server { location = /guides { return 301 /guides/record; } location = /guides/ { return 301 /guides/record; } + # The home page. It has its own rule because the catch-all below no longer tries folders, and "/" is one. + location = / { + try_files /index.html =404; + } + location / { # /privacy is served from privacy.html. No "$uri/": a folder that is not a page (/mixers, /images, /_next) # is a 404. With it, nginx sent /mixers to /mixers/ and the trailing-slash rule above sent it back, forever. - # "/" itself still matches $uri and is served from index.html. try_files $uri $uri.html =404; } diff --git a/website/tests/folderRedirects.test.ts b/website/tests/folderRedirects.test.ts index c1467115..ba734140 100644 --- a/website/tests/folderRedirects.test.ts +++ b/website/tests/folderRedirects.test.ts @@ -15,6 +15,11 @@ describe("folders that are not pages", () => { expect(catchAll).not.toMatch(/try_files[^;]*\$uri\/[ ;]/); }); + // "/" is a folder too, so the catch-all alone would answer 404 for the home page. + it("leave the home page with a rule of its own, served from index.html", () => { + expect(conf).toMatch(/location = \/ \{\s*try_files \/index\.html =404;\s*\}/); + }); + it("send /guides, with or without a slash, to the guides hub", () => { expect(GUIDES_HUB).toBe("/guides/record"); expect(conf).toContain(`location = /guides { return 301 ${GUIDES_HUB}; }`); diff --git a/website/tests/nginx-redirects.sh b/website/tests/nginx-redirects.sh index 3a91ead5..661e85d5 100755 --- a/website/tests/nginx-redirects.sh +++ b/website/tests/nginx-redirects.sh @@ -61,6 +61,7 @@ check '/mixers/wing' 404 '' check '/mixers/x32Tell/more' 301 '/mixers/x32' # A folder that is not a page is a 404, never a redirect to itself with a slash and back (a loop until 2026-12-03). check '/' 200 '' +check '/?utm_source=facebook&utm_campaign=x32-group' 200 '' check '/mixers' 404 '' check '/mixers/' 301 '/mixers' check '/images' 404 ''