Relative path for home assistant

Please give a configuration parameter for hosting this somewhere other than the root of a domain:

https://test.server/test/homeassistant/

This would be a very valuable config parameter, rather than assuming that everyone wants to create a new domain and host this at the root.

If there’s already a way to do this, please close and contact me on how to do this.

Thanks!

Home Assistant is starting its own webserver. What you want to do is proxy it from another server like nginx, Apache or Træfik for example. And that’s on this webserver you will choose to map /test/homeassistant/ to http://localhost:8123 (probably).

Great suggestion. Unfortunately it does not work. Please try it. :slight_smile:

Actual behavior:
/test/homeassistant/ 200 OK
/static/favicon-192x192.png 404 Not Found
/static/core-…js 404 Not Found
/static/webcomponents-lite.min.js 404 Not Found

It’s not written in such a way that proxy functionality will work. It looks hardcoded to use the root directory, which is not the best practice for creating a web server. I’m sure that there are tons of individuals who implement workarounds rather than relying on this basic functionality.

Oh well, you’re right (I didn’t try as I use hass on a subdomain). So there is an issue here: all the assets are loaded with a / in front of their path, which is obviously causing problems when hass is expected to be in a sub-folder. You should probably open an issue on GitHub.

The setup of apache is documented here.

I’m not using Apache so I didn’t try this setup exactly, but the (light) tries I made with Træfik exposed an issue: some requests made by hass are directly referring to /static/whatever. It seems the leading / is causing issues when you host hass in a (virtual) subdirectoy via any kind of proxy.

+1 for this request. I am trying to configure a reverse proxy with nginx and still there is static content pointing to the root /.

Has anybody figure it out the way to make it work with current version? 0.31.1

There appears to be a way to vote for this feature, here:

https://community.home-assistant.io/t/configurable-webroot/516

Unfortunately, when I click the “vote” button, nothing happens, but I may not have enough forum cred to count? :slight_smile:

I came across this issue myself recently and after a great deal of head scratching managed to make some progress. Here is my Nginx config:

location /hass/ {
        proxy_pass http://127.0.0.1:8123; 
        proxy_set_header Host $host;
        proxy_http_version 1.1;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }

Notice that there is no “/” after the proxy destination. Here is the request behavior under this config:

/hass/homeassistant/ 200 OK
/static/core-…js 200 OK
/static/webcomponents-lite.min.js 200 OK
/static/mdi-…html 404 not found
/static/frontend-…html 200 OK
/static/favicon-192x192.png 200 OK
/api/websocket/ 404 not found

The last 404 just keeps repeating. Setting:

        proxy_buffering off;

In my Nginx config simply makes the websocket requests get dropped faster.

Hope this provides some insight. I’ll let you know if I figure out how to pass the websocket requests through Nginx.

Any luck configuring this? Even as I add your configuration, it doesn’t seem to work for me.

Any updates on this working or not?

Hi,

A bit strange it is not possible for such a modern project.
I do not have a domain, I remotely connect to my server via IP and I would want to have access through Apache reverse proxy in a sub-directory!
That feature would be awesome…
Thanks

I can’t believe how many projects fail to implement this…

+1

1 Like

I have also tried to setup nginx as reverse proxy for that. No luck, i can login but the dashboard is loading endlessly:

map $http_upgrade $connection_upgrade {
    default upgrade;
    ''      close;
}

server {
    server_name servername.de;

    listen [::]:80 default_server ipv6only=off;

    proxy_buffering off;

    location ~/ha(.*)$ {
        proxy_set_header X-Real-IP  $remote_addr;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header Host $host;

        proxy_pass http://127.0.0.1:8123$1;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection $connection_upgrade;
    }

    location ~/api(.*)$ {
        proxy_set_header X-Real-IP  $remote_addr;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header Host $host;

        proxy_pass http://127.0.0.1:8123/api$1;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection $connection_upgrade;
    }

    location ~/static(.*)$ {
        proxy_set_header X-Real-IP  $remote_addr;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header Host $host;

        proxy_pass http://127.0.0.1:8123/static$1;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection $connection_upgrade;
    }

    location ~/frontend_latest(.*)$ {
        proxy_set_header X-Real-IP  $remote_addr;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header Host $host;

        proxy_pass http://127.0.0.1:8123/frontend_latest$1;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection $connection_upgrade;
    }

}

Hello, any news here ?
I can’t make the websocket work :frowning:

I would also like to do this.