Take the 2-minute tour ×

Right now, it is hard to work around most reverse proxies (nginx, HAproxy) when dealing with web sockets. I was thinking that it might be possible to do something like this:

io.connect("http://yourdomain:8080/chat"); // with namespace

So a sample workflow would be:

  • nginx listens on port 80
  • nodejs listens on port 8080
  • socket.io listens on port 8080 through nodejs app
  • nginx proxies any requests on port 80 over to nodejs on 8080
  • socket.io client connects directly to node/socket server on port 8080 and communicates directly without involvement of a reverse proxy

I can't get it working - is it not possible, or am I doing something wrong?

EDIT: This DOES actually work, my problem was sending MongoDB _id fields to the client I wrote a more detailed description here: http://nathanstarner.com/post/20202138488/socket-io-and-nginx-workaround

share|improve this question
have you looked at the proxy_buffering option? –  IfLoop Mar 28 '12 at 1:58
See my (unaccepted) answer to [an earlier question][1] [1]: stackoverflow.com/questions/9749070/… –  Dayo Mar 28 '12 at 13:07
Thanks for the comments! What I was trying to do was get around having to make any adjustments to nginx. Actually the above code works, the problem was with mongoDB. So you actually are able to specify a port in the socket.io connect and completely route it around nginx. –  Nate Starner Mar 31 '12 at 1:11
add comment

1 Answer

I should be possible with NGINX 1.3 once it's released. Version 1.2 added support for HTTP/1.1 protocol which was essential missing piece.

share|improve this answer
add comment

Your Answer


