Nginx and socket.io

Currently, it is difficult to work with most reverse proxies (nginx, HAproxy) when working with web sockets. I thought it was possible to do something like this:

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

So, an example workflow:

  • nginx listens on port 80
  • nodejs is listening on port 8080
  • socket.io listens on port 8080 through nodejs application
  • nginx proxies any requests on port 80 to nodejs on 8080
  • The socket.io client connects directly to the node / socket server on port 8080 and communicates directly without a reverse proxy.

I can’t make it work - isn’t that possible, or am I doing something wrong?

EDIT: This really works, my problem was sending _id MongoDB _id .

I wrote a more detailed description here

+4
source share
1 answer

I should be possible with NGINX 1.3 after its release. Version 1.2 added support for the HTTP / 1.1 protocol, which was a significant missing part.

0
source

Source: https://habr.com/ru/post/1403790/


All Articles