I managed to configure Nginx to load the HA dashboard on a subdirectory (public-url-addr /homeassistant), and with some minor hickups, it is working.
The issue I have is that I had to configure a location for each subdirectory that HA uses individually. It might break in the future, would need to add/remove other url paths if stuff change, could potentially break other stuff on my home server etc.
How did others do it? Is there a better way of doing this as subdirectory?
Here is the HA part in my current nginx config:
location = /homeassistant {
port_in_redirect off;
rewrite ^ /homeassistant/ permanent;
}
location /homeassistant/ {
proxy_set_header Host openmediavault.local:8123;
proxy_set_header X-Forwarded-Host $http_host;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_http_version 1.1;
proxy_cookie_path / "/; Secure";
proxy_pass http://openmediavault.local:8123/;
}
location /static/ {
proxy_set_header Host openmediavault.local:8123;
proxy_set_header X-Forwarded-Host $http_host;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_http_version 1.1;
proxy_cookie_path / "/; Secure";
proxy_pass http://openmediavault.local:8123/static/;
}
location /frontend_latest/ {
proxy_set_header Host openmediavault.local:8123;
proxy_set_header X-Forwarded-Host $http_host;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_http_version 1.1;
proxy_cookie_path / "/; Secure";
proxy_pass http://openmediavault.local:8123/frontend_latest/;
}
location /auth/ {
proxy_set_header Host openmediavault.local:8123;
proxy_set_header X-Forwarded-Host $http_host;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_http_version 1.1;
proxy_cookie_path / "/; Secure";
proxy_pass http://openmediavault.local:8123/auth/;
}
location /api/ {
proxy_set_header Host openmediavault.local:8123;
proxy_set_header X-Forwarded-Host $http_host;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_http_version 1.1;
proxy_cookie_path / "/; Secure";
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_pass http://openmediavault.local:8123/api/;
}
Note: I’m running the HA in Docker container on my home OpenMediaVault server.