Refactor Dashy configuration for improved proxy handling and convenience redirects

This commit is contained in:
Nik Afiq 2026-01-24 20:54:47 +09:00
parent ea8e732cb3
commit d3ea74d718

View File

@ -13,9 +13,13 @@ server {
access_log off; access_log off;
error_log /var/log/nginx/nik4naohomearpa_error.log warn; error_log /var/log/nginx/nik4naohomearpa_error.log warn;
# ---- Convenience redirects ---- # ---- Dashy at / (root) ----
location = / { location = / {
return 302 /admin/; proxy_pass http://127.0.0.1:8084;
include snippets/proxy-common.conf;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
} }
location = /pihole { location = /pihole {
return 302 /admin/; return 302 /admin/;
@ -147,35 +151,21 @@ server {
proxy_set_header X-Forwarded-Prefix /jd-bridge; proxy_set_header X-Forwarded-Prefix /jd-bridge;
} }
# ---- Dashy at /dashy/ ---- # ---- Dashy convenience redirects (Dashy is served at /) ----
location = /dashy { location = /dashy {
return 302 /dashy/; return 302 /;
}
location ^~ /dashy/ {
return 302 /;
} }
location ^~ /dashy/ { # ---- Default: serve Dashy for everything else ----
proxy_pass http://127.0.0.1:8084/; # All more specific locations above (/admin/, /api/, /jellyfin/, etc.) will still win.
location / {
proxy_pass http://127.0.0.1:8084;
include snippets/proxy-common.conf; include snippets/proxy-common.conf;
add_header X-Dashy-Proxy 1 always;
access_log /var/log/nginx/dashy_access.log;
proxy_set_header Host $host; proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Prefix /dashy;
proxy_redirect / /dashy/;
proxy_cookie_path / /dashy/;
proxy_set_header Accept-Encoding "";
sub_filter_once off;
sub_filter_types text/html text/css application/javascript application/json;
sub_filter '<base href="/">' '<base href="/dashy/">';
sub_filter 'href="/' 'href="/dashy/';
sub_filter 'src="/' 'src="/dashy/';
sub_filter 'content="/' 'content="/dashy/';
sub_filter 'action="/' 'action="/dashy/';
sub_filter 'url(/' 'url(/dashy/';
} }
} }