Slyke
(Slyke)
October 11, 2022, 9:47am
1
Hello,
I have a reverse proxy setup on Kubernetes on machines A, B and C (192.168.5.10, 192.168.5.11, 192.168.5.12) that’s being load balanced, and acting as the SSL termination for mydomain.xyz.
I have Home Assistant setup on a Raspberry Pi (192.168.5.20)
In my reverse proxy config, I have a whole bunch of Authelia stuff, but the main section in regards to Home Assistant is:
location ~/homeassistant/?(.*)?$ {
if ($request_uri ~ /homeassistant$ ) {
add_header Content-Type text/html;
return 200 '<meta http-equiv="refresh" content="0; URL=$uri/" />';
}
proxy_pass http://192.168.5.20:8123;
rewrite /homeassistant/(.*) /$1 break;
include conf.d/proxy.config;
include conf.d/auth.config;
}
In my Home Assistant config, I have the following:
http:
server_port: 8123
use_x_forwarded_for: true
trusted_proxies:
- 192.168.5.10
- 192.168.5.11
- 192.168.5.12
homeassistant:
external_url: "https://mydomain.xyz/homeassistant/"
internal_url: "http://homeassistant.:8123/"
I want to access homeassistant at mydomain.xyz/homeassistant from the internet, and also homeassistant.:8123 (or mydomain.xyz/homeassistant) from when within the LAN.
Right now when navigating to mydomain.xyz/homeassistant I can see that it is loading the Home Assistant index.html page, but it is not adding on the homeassistant directory in the requests. Ie, the first javascript file trying to load is:
https://mydomain.xyz/frontend_latest/core.8b15dd5b.js
and NOT:
https://mydomain.xyz/homeassistant/frontend_latest/core.8b15dd5b.js
I saw that base_url is deprecated, and I’m unsure why Home Assistant is not adding a subpath.
1 Like
tmjpugh
(Tmjpugh)
October 11, 2022, 12:44pm
2
Look at location info in example at link. I forget why but much of that is needed for HA
This guide has been migrated from our website and might be outdated. Feel free to edit this guide to update it, and to remove this message after that.
Using NGINX as a proxy for Home Assistant allows you to serve Home Assistant securely over standard ports. This configuration file and instructions will walk you through setting up Home Assistant over a secure connection.
1. Get a domain name forwarded to your IP
Chances are, you have a dynamic IP address (your ISP changes your address…
Slyke
(Slyke)
October 12, 2022, 8:50am
3
Hey @tmjpugh I checked that thread, some users reported the same issue as me, but I couldn’t see a solution. A workaround was to just home assistant on its own subdomain, but that’s not an option for me. Should I post my question in that thread instead?
wburgers
(Willem)
October 12, 2022, 9:19am
4
Can you try using a sub_filter directive in your location config?
That will parse the response from HA and replace every value of https://mydomain.xyz/ with https://mydomain.xyz/homeassistant/
set sub_filter_once off; such that the filter does not stop after the first instance.
sub_filter https://mydomain.xyz https://mydomain.xyz/homeassistant;
sub_filter_once off;
See also the nginx docs:
https://nginx.org/en/docs/http/ngx_http_sub_module.html
Slyke
(Slyke)
October 14, 2022, 3:15am
5
Hmmm, this seems to break everything. I think Home Assistant doesn’t support subdirectories and must be hosted in a top level directory on a domain.
1 Like
wburgers
(Willem)
October 14, 2022, 7:18am
6
Well, it was worth a shot .
Not sure how home assistant handles the hosting.
Maybe one of the devs or moderators can chime in for a better understanding on why it would not work as a subdirectory.
stewood
(Stephen Woodard)
December 15, 2022, 12:43am
7
Same issue here.
I would love to see this work. I have everything in subfolders except HA.
Slyke
(Slyke)
December 29, 2023, 8:34pm
8
This is still an issue as of version 2023.11.3 and 2023.12.4.
1 Like
jlech
(jlech)
January 10, 2026, 3:21pm
9
Hello,
Seems that I just faced the same issue 3 years later
Is there any solution to this problem?
jlech
(jlech)
January 10, 2026, 3:59pm
10
opened 02:15AM - 24 Feb 19 UTC
closed 03:52AM - 19 Mar 19 UTC
As first discussed at https://github.com/home-assistant/home-assistant/issues/21… 113, Home Assistant doesn't currently support hosting on a path (eg `https://home.example.com/homeassistant`), being only able to be hosted at the root of a domain.
Being able to serving Home Assistant from a subdirectory would allow it to co-exist alongside several other applications on an existing single hostname (served by a web server or reverse proxy, like Nginx) . This would save maintaining a separate hostname for this one application, removing the need for additional firewall, DNS configuration or HTTPS certificate config/renewals and so on.
In other applications, serving an application on a path is common. It usually involves the app's resources being served with either absolute URLs (eg prefixed with a full `base_url` or just a path component), or via relative URLs (possibly with a `<base>` tag in the HTML). Dynamic apps often allow the frontend host to pass the "path" as part of the request (eg `PATH_INFO` in FastCGI), or otherwise applications might statically prefix all the resources on a page and it is up to the user to configure this correctly in the app's settings. I'm only generally familiar with Home Assistant's internals but given the [http `base_url` setting](https://www.home-assistant.io/components/http/#base_url) setting exists already, it appears to be following the latter "static" style of configuration.
To implement the ability for Home Assistant to be served with a path, the simplest solution appears to be a case of ensuring `base_url` affects Home Assistant's URLs correctly, where any assumptions have been made in the code about the app being hosted at the root (`/`) of the domain. For example, resources and links in the frontend HTML currently point at `/frontend_latest` and `/static`, so these would need the ability to be prefixed based on live configuration (or made relative). A comment on the previous issue mentioned there are other components [that rely on knowing the path exposed to the internet](https://github.com/home-assistant/home-assistant/issues/21113#issuecomment-464457085) so these would need adjusting too to make them flexible (& anywhere else that assumes the same).
Is Home Assistant's architecture able to accommodate being served on a path / is this something that can be done? I'm new to the project so happy to contribute a PR but I'd need some initial guidance from the core team to understand the scope and of changes required.
https://t0bst4r.github.io/home-assistant-matter-hub/reverse-proxy/
The last link looked promising but did not work.