0

My virtual host setup:

<VirtualHost *:443>
ProxyPreserveHost On
    ProxyRequests off
    ProxyPass /home-assistant/api/websocket ws://192.168.1.125:8123/api/websocket
    ProxyPassReverse /home-assistant/api/websocket ws://192.168.1.125:8123/api/websocket
    ProxyPass /home-assistant http://192.168.1.125:8123
    ProxyPassReverse /home-assistant http://192.168.1.125:8123

    RewriteEngine on
    RewriteCond %{HTTP:Upgrade} =websocket [NC]
    RewriteRule /home-assistant/(.*)  ws://192.168.1.125:8123/$1 [P,L]
    RewriteCond %{HTTP:Upgrade} !=websocket [NC]
    RewriteRule /home-assistant/(.*)  http://192.168.1.125:8123/$1 [P,L]


SSLEngine On


    DocumentRoot /home/michal/sites/webmail


ServerAlias www.mydomain.com
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/mydomain.com/fullchain.pem

SSLCertificateKeyFile /etc/letsencrypt/live/mydomain.com/privkey.pem </VirtualHost>

But it does not work. When accessing https://example.com/home-assistant home assistant logo is loaded and I can see home assistant sitl tries to load its resources from example.com/ url, not example.com/home-assistant/ url, so it won't load.

How to make it working? I guess it will work if proxy is at top level '/', but not at '/home-assistant'

How to fix my rewrite rules to get all redirections made to example.com/home-assistant instead of example.com/?

1 Answers1

3

Configure home assistant with the correct URL.

Go to Configuration > General Input your external and internal url in the appropriate boxes. Press save

https://community.home-assistant.io/t/base-url-deprecation-but-unclear-what-to-do-about-it/200377

It's always preferable to fix these issues by configuring the backend properly instead of having the reverse proxy rewrite the HTML on the fly.

Gerald Schneider
  • 26,582
  • 8
  • 65
  • 97