Problem with Web UI connection when using hostname alias after upgrade

I have setup a CNAME host alias (like hass.example.com) which points to my all-purpose server (say server.example.com). I have an apache2 configuration like this:

<VirtualHost *:80> 
  ProxyPreserveHost On
  ProxyRequests Off
  ServerName hass.example.com
  ProxyPass / http://server.example.com:8123/
  ProxyPassReverse / http://server.example.com:8123/
</VirtualHost>

This makes me able to access Home Assistant on port 80 on hass.example.com, even though port 80 on server.example.com is used by apache for different purposes.

This has worked flawlessly for me since I installed Home Assistant. But now, after some recent upgrade (not really sure when, but I’m running 0.35.3 now), this has stopped working.

That is, it almost works. Everything seems in order, but there’s a black bar at the bottom saying “Connection lost. Reconnecting…”, and streamed updates does not work, so I get no UI responses. :frowning:

I’m quite well-versed in the server code of HA, but I know next to nothing about the web frontend. Does anyone here have an idea on what might have happened in the latest releases which can have affected this, or how I could go on debugging this issue?

I use nginx and had same issues around 35.x somewhere. adding lines below corrected this issue

        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";

Im sure apache has similar setting.
I got these from https://home-assistant.io/ecosystem/nginx/

nginx runs on seprerate server in my case

This issue appeared after a change in 0.34 on how the UI talks to the backend.
Have a look at the Apache Configuration, and in particular the recently added entries to forward websocket requests:

  ProxyPass /api/websocket ws://localhost:8123/api/websocket
  ProxyPassReverse /api/websocket ws://localhost:8123/api/websocket

Once added (and adapted to your server name), the UI will be able to receive and show updates again.

1 Like

There’s documentation!?! :smiley:

And I painfully produced my own Apache configuration. sigh As they say, two months in the lab can save you an hour in the library. :slight_smile:

It works perfectly now. Thank you @exxamalte!