Websocket Proxy for Home Assistant

#1
Hi,
How can I setup a websocket proxy for Home Assistant? I've looked on the wiki, however the guide is confusing and ineffective. Please could someone explain the process for Home Assistant.

Thanks,
 
#5
Another guide for setting OLS as a proxy
https://docs.openlitespeed.org/docs/advanced/proxy

Feel free to ask if you have any set questions.
Looking at the recommended Apache configuration here: https://community.home-assistant.io/t/reverse-proxy-with-apache/196942/12

I've come out with this:

Apache config:
#fix detecting incorrect login IP by proxy server
RemoteIPInternalProxy 192.168.1.111
RemoteIPHeader X-Forwarded-For

RewriteEngine On
#RewriteRule ^(.*)$ https://HASS/$1 [P]
#RewriteCond %{HTTP:Upgrade} websocket [NC]
#RewriteRule ^/?(.*) "ws://HASS/$1" [P]
RewriteCond %{HTTP:Upgrade} =websocket
RewriteRule /(.*) ws://srv.maicol07.it:8123/$1 [P]
RewriteCond %{HTTP:Upgrade} !=websocket
RewriteRule /(.*) https://HASS/$1 [P]

#Set security on certan areas(some redacted)
<Location "/">
    Satisfy any
</Location>
<Location "/api">
    Satisfy any
</Location>
where HASS is the name of my external app in LSWC.

The web proxy works, but the websocket doesn't work...
Do you have any clue?

I think the part that's missing is the ProxyPass one, however I don't know how to do it in OLS, since copy-pasting the rules isn't working...
 
Last edited:
#10
Solved this issue with the help of @Cold-Egg and @RukaiWang.
The issue was that SSL was enabled for Home Assistant server and that failed the SSL cert check.
Basically you have to setup a standard reverse proxy with context and webapp in WebAdmin console and a new Websocket proxy like mine:

External app:
1660580168659.png
Context proxy:
1660580198912.png
Websocket proxy:
1660580222880.png
 
Top