HomeAssistant through Apache2 reverse proxy

Hi all,

I have installed Home Assistant on a Debian with Docker.

I would like to expose it externally as https ://www.mysite.org/ha

I already have other apps configured and working like https ://www.mysite.org/app1, https ://www.mysite.org/app2, etc. and www.mysite.org has the correct SSL certificate, which I would like to use with Home Assistant via Apache reverse proxy.

I read some articles about this, but I didn’t solve:

  • https ://www.mysite.org/ha responds with a “400: Bad Request”
  • I tried to change the external url to HA from the settings, but I get a “url is not allowed to have a path component for dictionary value @ data[‘external_url’]. Got https ://www.mysite.org/ha’”
  • I read that it might be necessary to remove the base_url, but where can I find the configuration.yaml file?

This is my apache configuration (sorry if it’s not the best one :():

<VirtualHost *:80>
 ServerAdmin [email protected]
 DocumentRoot /var/www/html/
 ServerName mysite.org
 ServerAlias ​​www.mysite.org
 Permanent redirect / https://www.mysite.org/
</VirtualHost>

<VirtualHost *:443>
 ServerAdmin [email protected]
 DocumentRoot /var/www/html/
 ServerName mysite.org
 ServerAlias ​​www.mysite.org

 Alias ​​/zm /usr/share/zoneminder/www
 ScriptAlias ​​/cgi-bin "/usr/lib/cgi-bin"

 #CrowdSecurity
 ProxyPass "/cs" "http://localhost:3000"
 ProxyPassReverse "/cs" "http://localhost:3000"

 # RSpamD
 RewriteEngine on
 ProxyPass "/rspamd" "http://localhost:11334"
 ProxyPassReverse "/rspamd" "http://localhost:11334"
 RewriteRule ^/rspamd$ /rspamd/ [R,L]
 RewriteRule ^/rspamd/(.*) http://localhost:11334/$1 [P,L]

 # HomeAssistant
 RewriteEngine on
 ProxyPass "/ha" "http://localhost:8123"
 ProxyPassReverse "/ha" "http://localhost:8123"
 ProxyPass "/ha/api/websocket" "ws://localhost:8123/api/websocket"
 ProxyPassReverse "/ha/api/websocket" "ws://localhost:8123/api/websocket"
 #RewriteRule ^/ha$ /ha/ [R,L]
 #RewriteRule ^/ha/(.*) http://localhost:8123/$1 [P,L]
 #RewriteCond %{HTTP:Upgrade} =websocket [NC]
 #RewriteRule /ha/(.*) ws://localhost:8123/$1 [P,L]
 #RewriteCond %{HTTP:Upgrade} !=websocket [NC]
 #RewriteRule /ha/(.*) http://localhost:8123/$1 [P,L]

 Aliases / /var/www/html/nextcloud/
 <Directory /var/www/html/nextcloud/>
[...]

Any ideas?

Thank you,
Matteo