From 4b48303c4e68290938f8ab288bbffd3807f77ac8 Mon Sep 17 00:00:00 2001 From: Fred Boniface Date: Mon, 2 Oct 2023 20:39:00 +0100 Subject: [PATCH] Add custom 404 page --- nginx.conf | 12 +++++++++++- src/routes/err/404/+page.svelte | 23 +++++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 src/routes/err/404/+page.svelte diff --git a/nginx.conf b/nginx.conf index 12058cd..cc4e535 100644 --- a/nginx.conf +++ b/nginx.conf @@ -42,14 +42,24 @@ http { add_header Content-Security-Policy "default-src 'self'"; + error_page 404 /404.html + + location /404.html { + root /err/; + } + location / { root /usr/share/nginx/html; index index.html; gzip_static on; brotli_static on; error_page 500 502 503 504 /50x.html; - try_files $uri $uri.html $uri/ =404; + try_files $uri.html $uri $uri/ =404; add_header Cache-Control "public, no-transform, max-age=1209600"; + + if ($uri ~* \.html$) { + return 404; + } } location /misc/ { diff --git a/src/routes/err/404/+page.svelte b/src/routes/err/404/+page.svelte new file mode 100644 index 0000000..488e9c4 --- /dev/null +++ b/src/routes/err/404/+page.svelte @@ -0,0 +1,23 @@ + + +
+

There's no light at the end of this tunnel

+

The page you were looking for wasn't found

+

Use the menu bar to try another destination

+
+

Status: 404
Message: NOT_FOUND

+