WebSocket servers and firewall

firewall, proxy, redirect, websocket

Solution

This is called "WebSockets reverse proxy". You will need another logical or physical node between your firewall and your WebSocket servers. You might be running all three nodes on the same system which is why I mention "logical".

This space is rapidly changing and solutions are fairly immature. Probably the best option for your case is using HAProxy for WebSocket reverse proxy. Search for "WebSocket reverse proxy" for more information. This article is a bit old but should give you a reasonable overview of options.

Update: looks like WebSocket proxy support just landed in Nginx yesterday: press release, commit with example

Problem

I have two WebSocket servers both running on different ports than 80 and 443. These two servers are running behind a firewall which only has port 80 and 443 open. ``` WebSocket Server A:800 | |-----|FireWall:80 & 443|-----> INTERNET WebSocket Server B:801 | ``` What I am looking for is a way for my clients to get connected to the WebSocket servers without knowing their port and without me opening the firewall for any other ports rather than 80 and 443. So I was thinking maybe an intermediary server (or proxy server) between my firewall and WebSocket servers can be configured in a fashion that when clients asks for `www.mywebsite.com/a` on port 80 or 443 (to pass the firewall) the intermediary server connects the client to WebSocket Server A. And when client asks for `www.mywebsite.com/b` on port 80 or 443 the intermediary server connects him to WebSocket Server B. Is this possible? and if so, is there any server you may know of that has this feature implemented? On a different note (maybe not very different), what would be the differences between TCP hole punch and the approach I explained above?

Original source