Refactor Nginx configuration files for improved readability and consistency

This commit is contained in:
Nik Afiq 2026-01-24 20:21:33 +09:00
parent 071e52a0d8
commit c56c154635
5 changed files with 118 additions and 96 deletions

View File

@ -14,12 +14,20 @@ server {
error_log /var/log/nginx/nik4naohomearpa_error.log warn; error_log /var/log/nginx/nik4naohomearpa_error.log warn;
# ---- Convenience redirects ---- # ---- Convenience redirects ----
location = / { return 302 /admin/; } # land on Pi-hole admin by default location = / {
location = /pihole { return 302 /admin/; } # /pihole -> /admin/ return 302 /admin/;
location /pihole/ { return 301 /admin/; } # keep only /admin/ path }
location = /pihole {
return 302 /admin/;
}
location /pihole/ {
return 301 /admin/;
}
# ---- Jellyfin at /jellyfin/ ---- # ---- Jellyfin at /jellyfin/ ----
location = /jellyfin { return 302 /jellyfin/; } # enforce trailing slash location = /jellyfin {
return 302 /jellyfin/;
}
location /jellyfin/ { location /jellyfin/ {
proxy_pass http://jellyfin_upstream/; # uses upstream (or use the raw URL) proxy_pass http://jellyfin_upstream/; # uses upstream (or use the raw URL)
@ -36,7 +44,9 @@ server {
} }
# ---- Jellyfin at /anime/ ---- # ---- Jellyfin at /anime/ ----
location = /anime { return 302 /anime/; } # enforce trailing slash location = /anime {
return 302 /anime/;
}
location /anime/ { location /anime/ {
proxy_pass http://djellyfin_upstream/; # uses upstream (or use the raw URL) proxy_pass http://djellyfin_upstream/; # uses upstream (or use the raw URL)
@ -69,7 +79,9 @@ server {
} }
# redirect /watch-party -> /watch-party/ # redirect /watch-party -> /watch-party/
location = /watch-party { return 302 /watch-party/; } location = /watch-party {
return 302 /watch-party/;
}
# proxy ONLY /watch-party/*, keeping the prefix # proxy ONLY /watch-party/*, keeping the prefix
location ^~ /watch-party/ { location ^~ /watch-party/ {
@ -85,7 +97,9 @@ server {
} }
# ---- qBittorrent at /qbt/ ---- # ---- qBittorrent at /qbt/ ----
location = /qbt { return 302 /qbt/; } location = /qbt {
return 302 /qbt/;
}
location ^~ /qbt/ { location ^~ /qbt/ {
proxy_pass http://qbt_upstream/; proxy_pass http://qbt_upstream/;
@ -103,7 +117,9 @@ server {
} }
# ---- JDownloader2 at /jd2/ ---- # ---- JDownloader2 at /jd2/ ----
location = /jd2 { return 302 /jd2/; } location = /jd2 {
return 302 /jd2/;
}
location /jd2/ { location /jd2/ {
proxy_pass http://127.0.0.1:5800/; proxy_pass http://127.0.0.1:5800/;
@ -116,7 +132,9 @@ server {
} }
# ---- JDownloader-Bridge at /jd-bridge/ ---- # ---- JDownloader-Bridge at /jd-bridge/ ----
location = /jd-bridge { return 302 /jd-bridge/; } location = /jd-bridge {
return 302 /jd-bridge/;
}
location /jd-bridge/ { location /jd-bridge/ {
proxy_pass http://127.0.0.1:8088/; proxy_pass http://127.0.0.1:8088/;

View File

@ -64,7 +64,9 @@ server {
error_page 500 502 503 504 /errors/50x.html; error_page 500 502 503 504 /errors/50x.html;
# (Optional) Block noncompliant AI bots (requires $block_ai map in nginx.conf) # (Optional) Block noncompliant AI bots (requires $block_ai map in nginx.conf)
if ($block_ai) { return 403; } if ($block_ai) {
return 403;
}
# Serve /robots.txt on HTTPS # Serve /robots.txt on HTTPS
location = /robots.txt { location = /robots.txt {
@ -73,7 +75,9 @@ server {
} }
# Enforce trailing slash for subpath and land / on /watch-party/ # Enforce trailing slash for subpath and land / on /watch-party/
location = /watch-party { return 301 /watch-party/; } location = /watch-party {
return 301 /watch-party/;
}
location = / { location = / {
try_files /nik4nao-xyz-landing.html =404; try_files /nik4nao-xyz-landing.html =404;
} }