[SOLVED] Apache reverse Proxy websocket

Hi im trying to be able to connect to HA from my own domain, but i have some problems.
I can reach the login page, but after i log in i only get “Unable to connect to Home Assistant.”

If i look in the console i see that i get a 400 on the websocket.
So i think it somthing with my virtual host config for websockets
I have followd this guid Reverse Proxy with Apache but without success.

My setup is that i have computer that is connected to the internet, then that computer in turn use proxy to HA that is on a other machine.

My current config is now

<VirtualHost *:443>
	ServerName ha.domain.com
	serverAlias www.ha.domain.com

	ProxyPreserveHost On
	ProxyRequests off
	ProxyPass /api/websocket ws://192.168.1.XX:8123/api/websocket
	ProxyPassReverse /api/websocket ws://192.168.1.XX:8123/api/websocket
	ProxyPass / http://192.168.1.XX:8123/
	ProxyPassReverse / http://192.168.1.XX:8123/

        ErrorLog ${APACHE_LOG_DIR}/error-ha_page.log
        CustomLog ${APACHE_LOG_DIR}/access-ha_page.log combined

	RewriteEngine on
	RewriteCond %{HTTP:Upgrade} =websocket [NC]
	RewriteRule /(.*)  ws://192.168.1.XX:8123/$1 [P,L]
	RewriteCond %{HTTP:Upgrade} !=websocket [NC]
	RewriteRule /(.*)  http://192.168.1.XX:8123/$1 [P,L]
</VirtualHost>

And i can login and use HA when i go to http://192.168.1.XX:8123 but i cant use HA when i use https://ha.domain.com

is there somthing im missing or any one that have any tip how to get this to work

// Best regards romaswe

I use this with success:

<VirtualHost *:443>
    ServerName ******.duckdns.org
	ServerAlias home.*******.nrw

	SSLEngine on
    SSLCertificateFile /usr/local/apache2/conf/server.crt
    SSLCertificateKeyFile /usr/local/apache2/conf/server.key
	
	SSLProxyEngine on
	SSLProxyVerify none 
	SSLProxyCheckPeerCN off
	SSLProxyCheckPeerName off
	SSLProxyCheckPeerExpire off
	
	# Home Assistant WebSockets
	ProxyPass /api/websocket wss://192.168.178.10:443/api/websocket
	ProxyPassReverse /api/websocket wss://192.168.178.10:443/api/websocket
	
    # Home Assistant HTTP
    ProxyPass / https://192.168.178.10:443/
    ProxyPassReverse / https://192.168.178.10:443/

</VirtualHost>

Maybe there is something wrong with your SSL config, but it’s really hard for me to find out without having the URL of your instance. Nevertheless, I advise not to post the URL publicly.

I fixed it, it was me that was stupid (as it usually is)

But if someone stubel on to this thread with the same problem.

Because i use letsencrypt to create my SSL it created new config files in apache
So i change my original file, and then the let’s encrypt generate ones overwritten it, and that’s why the changes didn’t work, so my config that is in the question works

Did you change your HA config HTTP instance to be on port 443 or is it still 8123? Your ProxyPass lines confuse me.

Yes, I did.

OMG, thanks !. Finally solve the issue. After weeks and weeks try to solve.Its just LetsEncrpyt generated conf file that needs to rewrite.

1 Like