How to reverse proxy web socket traffic

#1
We have several virtual hosts defined which reverse proxy web traffic to another host. This part is working fine. One of the applications we are running however is also using web sockets to communicate with the browser. Before switching to OpenLiteSpeed we were using Apache as the reverse proxy. Here, all we had to do was:

ProxyRequests Off
ProxyPreserveHost On

ProxyPass / https://backend.domain.com:12345/
ProxyPassReverse / https://backend.domain.com:12345/

to proxy all traffic to the backend. This also forwarded the web socket traffic.

In OpenLiteSpeed we have defined an External App:

extProcessor hd {
type proxy
address https://backend.domain.com:12345
maxConns 100
initTimeout 60
retryTimeout 0
respBuffer 0
}

and used a Rewrite rule in the virtual host definition:

rewrite {
enable 1
RewriteRule ^/(.*)$ https://hd/$1 [P,E=Proxy-Host:hd.domain.com]
}

The reverse proxy works fine, but no web socket traffic is being forwarded.

How do I get the web socket traffic forwarded as well?

Any help would be greatly appreciated.
 
#3
Tishu,

thanks. I had already looked at that page and tried to define a web socket proxy with these controls, with not much luck. I get the distinct impression that this is primarily for a web socket server running on the same machine as OLS, which it is not in my case.

I tried with the following settings:

URI: /
Address: x.x.x.x:12345

where x.x.x.x is the IP address of backend.domain.com

All this added to the virtual host with the rewrite rule as outlined above.

It would be nice if the web socket proxy could be directed to use the external app as well...

Or is there a way to redirect web socket traffic via an additional rewrite rule?
 
#5
Hi,

if that's possible, sure. As I mention in the original post, the Apache setup we had in place was pretty straightforward in that it proxied any and all traffic.

I can see that OLS has the separation as a feature, but in my case I would simply like to forward everything to the backend - I don't need to separate regular and WS traffic.
 

lsqtwrk

Administrator
#6
Hi,

if that's possible, sure. As I mention in the original post, the Apache setup we had in place was pretty straightforward in that it proxied any and all traffic.

I can see that OLS has the separation as a feature, but in my case I would simply like to forward everything to the backend - I don't need to separate regular and WS traffic.
Hi, Unfornately that proxy is only for http and https , for websocket , is must use websocket tab to set backend for websocket :)

Best regards,
 
Top