2

So, I've got a WebSocket server in C++, that is a completely stand-alone entity - handles header parsing, receiving, sending, all of it on its own, listening directly to the port.

Problem is, it needs to run on a server alongside Apache, and that's a bit of a problem. Now, there was a solution here to a similar issue involving mod_proxy, but I'm hoping I can intercept and redirect WebSocket communication before Apache even knows about it, possibly with iptables.

So the question is, is it possible to direct traffic bound for chat.mysite.net to a WebSocket server on, say, port 8080, while anything else headed to mysite.net proceeds as expected to Apache?

DigitalMan
  • 179
  • 1
  • 9

2 Answers2

2

It turns out this is actually pretty easy; just code the client to access the server at ws://mysite.com:8080. With all the touting of WebSockets being able to use port 80, I was quite surprised to learn it doesn't need to.

DigitalMan
  • 179
  • 1
  • 9
1

Sorry, it's not possible with iptables because iptables doesn't speak/understand http protocol. Someone should write ip_conntrack_http so this could actually work (something similar as ftp conntrack thingie) ;-) Till then you should probably use apache with mod_proxy or nginx.

FINESEC
  • 1,371
  • 7
  • 8
  • I'm assuming that both servers are binded to the same IP address because otherwise this question doesn't make much sense (the answer would be too simple) – FINESEC Nov 05 '12 at 23:20