From edb60952c7e5c5cae4d9e1a127e1b4b8171d7a8c Mon Sep 17 00:00:00 2001 From: Nik Afiq Date: Thu, 20 Nov 2025 23:32:59 +0900 Subject: [PATCH] Added custom page --- default.conf | 28 +++++++ http/404.html | 95 ++++++++++++++++++++++ http/50x.html | 178 +++++++++++++++++++++++++++++++++++++++++ nik4nao.home.arpa.conf | 18 +++++ nik4nao.xyz.conf | 17 ++++ upstreams.conf | 8 +- 6 files changed, 343 insertions(+), 1 deletion(-) create mode 100644 default.conf create mode 100644 http/404.html create mode 100644 http/50x.html diff --git a/default.conf b/default.conf new file mode 100644 index 0000000..3256d35 --- /dev/null +++ b/default.conf @@ -0,0 +1,28 @@ +server { + listen 80 default_server; + listen [::]:80 default_server; + + root /var/www/html; + + index index.html index.htm index.nginx-debian.html; + + server_name _; + + # === custom error pages === + error_page 404 /errors/404.html; + error_page 500 502 503 504 /errors/50x.html; + + location = /errors/404.html { + root /var/www; + internal; + } + + location = /errors/50x.html { + root /var/www; + internal; + } + + location / { + try_files $uri $uri/ =404; + } +} \ No newline at end of file diff --git a/http/404.html b/http/404.html new file mode 100644 index 0000000..7ee00ee --- /dev/null +++ b/http/404.html @@ -0,0 +1,95 @@ + + + + + 404 | Page Lost in the Void + + + +
+
404
+
NOT FOUND
+

+ The page you’re looking for has drifted out of this universe.
+ Check the URL or head back to the safe zone. +

+ Return to Home +
+ + \ No newline at end of file diff --git a/http/50x.html b/http/50x.html new file mode 100644 index 0000000..038a008 --- /dev/null +++ b/http/50x.html @@ -0,0 +1,178 @@ + + + + + 5xx | Server is on Fire + + + +
+
5XX
+
SERVER IS ON FIRE
+ +
+ Something on the backend just went very wrong.
+ Your request didn’t make it through, but the logs definitely did. +
+ +
+ Tip: If you’re the admin, check your upstreams, containers, and error logs.
+ If you’re not, maybe just pretend this never happened. +
+ + + +
+
+
+
+
+
+
+
+ + \ No newline at end of file diff --git a/nik4nao.home.arpa.conf b/nik4nao.home.arpa.conf index 7c1a0ae..8e1fdba 100644 --- a/nik4nao.home.arpa.conf +++ b/nik4nao.home.arpa.conf @@ -35,6 +35,24 @@ server { # proxy_redirect off; } + # ---- Jellyfin at /anime/ ---- + location = /anime { return 302 /anime/; } # enforce trailing slash + + location /anime/ { + proxy_pass http://anime_upstream/; # uses upstream (or use the raw URL) + proxy_next_upstream error timeout invalid_header http_502 http_503 http_504; + include snippets/proxy-common.conf; + + # Jellyfin behind subpath specifics + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection $connection_upgrade; + proxy_set_header X-Forwarded-Host $host; + proxy_set_header X-Forwarded-Prefix /anime; + + # (Optional) if you see odd redirects, uncomment: + # proxy_redirect off; + } + # ---- Pi-hole admin at /admin/ ---- # Pi-hole’s UI lives under /admin/, so keep the trailing slash in proxy_pass. location /admin/ { diff --git a/nik4nao.xyz.conf b/nik4nao.xyz.conf index 7ccef11..dcc8702 100644 --- a/nik4nao.xyz.conf +++ b/nik4nao.xyz.conf @@ -57,6 +57,11 @@ server { add_header X-Frame-Options "DENY" always; add_header X-Robots-Tag "noindex, nofollow, noimageindex, nosnippet, noarchive" always; + # Custom error pages for public site + proxy_intercept_errors on; + error_page 404 /errors/404.html; + error_page 500 502 503 504 /errors/50x.html; + # (Optional) Block noncompliant AI bots (requires $block_ai map in nginx.conf) if ($block_ai) { return 403; } @@ -109,6 +114,18 @@ server { proxy_read_timeout 60s; } + # Deny anything unexpected + # Pretty error pages (served from disk, not directly reachable) + location = /errors/404.html { + root /var/www; + internal; + } + + location = /errors/50x.html { + root /var/www; + internal; + } + # Deny anything unexpected location / { return 404; diff --git a/upstreams.conf b/upstreams.conf index 53506f2..0f6b4f9 100644 --- a/upstreams.conf +++ b/upstreams.conf @@ -12,4 +12,10 @@ upstream pihole_upstream { upstream watchparty_upstream { server 192.168.7.96:3000; keepalive 16; -} \ No newline at end of file +} + +upstream anime_upstream { + server 192.168.7.78:8096 max_fails=2 fail_timeout=3s; + server 192.168.7.7:8096 backup; + keepalive 16; +}