Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions website/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 12 additions & 2 deletions website/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,19 @@ 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; }

# 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.
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.
try_files $uri $uri.html =404;
}

# Mixer pages as above; an address that is not a page tries the mistyped-mixer redirect.
Expand Down
28 changes: 28 additions & 0 deletions website/tests/folderRedirects.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
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\/[ ;]/);
});

// "/" 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}; }`);
expect(conf).toContain(`location = /guides/ { return 301 ${GUIDES_HUB}; }`);
});
});
19 changes: 19 additions & 0 deletions website/tests/nginx-redirects.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -53,4 +59,17 @@ 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 '/?utm_source=facebook&utm_campaign=x32-group' 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"
Loading