I asked this question on Stack Overflow first, but then I thought Server Fault could be a better place to post it.

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?

  • The solution on how to do so can be find in the original SO post.
    – mrz
    Feb 20 '13 at 8:33

It seems that you need to add a reverse proxy between your firewall and your servers.

By using websocket apache module you should be able to forward websocket requests to your servers through your reverse proxy.

  • 1
    Does websocket apache module let me to pass websocket request without striping anything from the request header?
    – mrz
    Feb 18 '13 at 12:20

I would suggest the mod_proxy_wstunnel module available in Apache 2.4.5 onwards. It allows you to relay from a URL to another websocket server on any port.

e.g. To take your example:

ProxyPass /ws1/  ws://websocketserverA:800/
ProxyPass /ws2/  ws://websocketserverB:801/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.