This is an old revision of the document!
How to Set Up LSWS as a WebSocket Proxy
What's a WebSocket?
WebSocket changes the way the Internet works: It is a protocol that allows the server and the client to have a bidirectional conversation. The client doesn’t just request content from the server. The server also sends content to the client whenever there’s content to be sent (without waiting to be asked). This bidirectional conversation allows for realtime web experiences. While HTTP tries to simulate real-time interaction at great expense (through incessant refreshing), WebSocket makes realtime interaction a reality. This upgrades all sorts of web applications: stock tickers, data center monitors, news feeds… But probably the most exciting feature of realtime Internet is the ability for multiple users to see and react to things they each do in real time.
LiteSpeed Web Server can work as a WebSocket proxy. See how:
Setup WebSocket Backend
The first step is to have a working WebSocket backend set up, but explaining how to do that is out of this wiki's scope. You can consult online tutorials. One example involves using an Nginx backend with an nchan module.
Test the Backend WebSocket
Assuming you have a backend WebSocket up and running on port 80 at ws://domain.com/sub/xx1
, you will need to test it to ensure it is working.
There are many tools available for such testing. You can either try some online tools such as Echo Test or download chrome extension tools like Simple WebSocket Client. We will use Chrome Simple WebSocket Client as an example in this wiki.
As you can see, it tested successfully.
If it had failed, you would see a Simple WebSocket Client undefined
error, like so:
How to Configure LSWS as a WebSocket Proxy
In the LSWS Web Console, navigate to Virtual Host (Native) > General > Web Socket Proxy Setup
Set up URI and Address.
Save and restart LSWS.