- locally, home assistant is at http://192.168.1.125:8123
- I need reverse proxy available at https://example.com/home-assistant
- Virtual host https://example.com exsits and it should not be touched
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/
?
/css/style.css
to/home-assistent/css/style.css
- a long time ago I wrote a longer explanation here serverfault.com/a/561897/37681 for Apache 2.2 that is still mostly relevant and there is a second answer there as well for the current Apache 2.4 version