Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
    
Not if they have the same IP address. You need HTTP header inspection to figure out if it's a websocket connection. –  David Schwartz Nov 5 '12 at 23:06

2 Answers 2

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.

share|improve this answer
    
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 5 '12 at 23:20
up vote 1 down vote accepted

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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