@danielperna84, thank you for your reply. I was making a lot of mistakes, many I have now corrected, but I am still not there yet.
I created a CNAME for hass.mydomain.com
and created a simple virtual host for apache to match ServerName hass.mydomain.com
. I gave it a different DocumentRoot and serve a unique index.html out of it so I can now prove that my CNAME records are working and Apache is correctly matching server names such that I get the expected pages if browsing to mydomain.com
or hass.mydomain.com
(or any other subdom.mydomain.com
that I set up to play around).
However, I still cannot get the Apache to proxy to the HA websocket.
At first I tried this VIrtual Host config:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName hass.mydomain.com
ProxyPreserveHost On
ProxyRequests off
ProxyPass /api/websocket ws://localhost:8123/api/websocket
ProxyPassReverse /api/websocket ws://localhost:8123/api/websocket
ProxyPass / http://localhost:8123/
ProxyPassReverse / http://localhost:8123/
RewriteEngine on
RewriteCond %{HTTP:Upgrade} =websocket [NC]
RewriteRule /(.*) ws://localhost:8123/$1 [P,L]
RewriteCond %{HTTP:Upgrade} !=websocket [NC]
RewriteRule /(.*) http://localhost:8123/$1 [P,L]
</VirtualHost>
The above was exactly what is shown in the HA documents for a Apache proxy I noted in my earlier post. But I see you are doing it slightly differently so I tried to emulate yours more closely:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName hass.mydomain.com
ProxyPreserveHost On
ProxyRequests off
ProxyPass / http://192.168.1.81:8123
ProxyPassReverse / http://192.168.1.81:8123
ProxyPass /api/websocket ws://192.168.1.81:8123/api/websocket
ProxyPassReverse /api/websocket ws://192.168.1.81:8123/api/websocket
RewriteEngine on
RewriteCond %{HTTP:Upgrade} =websocket [NC]
RewriteRule /(.*) ws://192.168.1.81:8123/$1 [P,L]
RewriteCond %{HTTP:Upgrade} !=websocket [NC]
RewriteRule /(.*) http://192.168.1.81:8123/$1 [P,L]
</VirtualHost>
In both cases it fails and I get a 500 Internal Server error. FWIW, I did play around with the ServerAdmin value so I could confirm on the browser’s 500 error page that Apache was still correctly matching the virtual host to hass.mydomain.com
.
Any thoughts on how I might proceed to further troubleshoot this. I am now going to start looking for logs, but I don’t really know what logs to target so this may take a while.
BTW, I certainly intend to use SSL and Fail2ban but for now just trying to get this proxy thing sorted out before I add those complexities.
I appreciate the help very much. Thank you.
EDIT: I have found the following in the Apache error.log:
No protocol handler was valid for the URL /. If you are using a DSO version of mod_proxy, make sure the proxy submodules are included in the configuration using LoadModule.
And
No protocol handler was valid for the URL /favicon.ico. If you are using a DSO version of mod_proxy, make sure the proxy submodules are included in the configuration using LoadModule
But I am not too sure what to make of this. I don’t know what /favicon.ico
is. And proxy_wstunnel.load
us in my mods-enabled folder (running Debian flavor Linux) so it looks good. Not sure how to figure out what other module is missing