socket.io icon indicating copy to clipboard operation
socket.io copied to clipboard

Using a custom location for websockets on nginx with socket.io

Open brunogsa opened this issue 10 years ago • 1 comments

Hi, guys!

We developed a Chat Server for our Web Client using socket.io and the initial setup is working. The current architecture is the following:

  • Chat Server is waiting for a WS connection on port 2020.
  • Nginx is waiting for a WSS connection on port 2019. It'll proxy it to port 2020.
  • Web Client opens a WSS connection on port 2019.
  • Nginx and Chat Server are hosted in the same machine.

i.e.: Web Client --wss--> (ipx:2019) Nginx --ws--> (ipx:2020) Chat Server

We want now that Web Client sends all its requests to port 443. We'll configure different locations on Nginx, but all requests must pass through port 443.

i.e.: Web Client --wss--> (ipx:443/sip) Nginx --ws--> (ipx:10010) Sip Server Web Client --wss--> (ipx:443/chat) Ngnix --ws--> (ipx:2020) Chat Server

This configuration worked as a charm with our Sip Server, which use its own websocket mechanism. I couldn't make our Chat Server work with this configuration, however.

Chat Server with socket.io is answering 405 to Web Client on this request:

Request: POST /socket.io/?EIO=3&transport=polling&t=LK2PT5O HTTP/1.1 Host: 192.168.17.135 Connection: keep-alive Content-Length: 3 Pragma: no-cache Cache-Control: no-cache Origin: https://192.168.17.135 User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.94 Safari/537.36 Content-type: text/plain;charset=UTF-8 Accept: / Referer: https://192.168.17.135/meeting_room/1571217396 Accept-Encoding: gzip, deflate, br Accept-Language: en-US,en;q=0.8,pt;q=0.6 Cookie: io=egbmNeD7OJyB61ttAAAA

Payload: 1:1

Response: HTTP/1.1 405 Not Allowed Server: nginx/1.10.0 (Ubuntu) Date: Mon, 30 May 2016 16:01:15 GMT Content-Type: text/html Content-Length: 584 Connection: keep-alive

I think this issue has something with the multiplexing feature from socket.io. Can I make it work in some way? Am I missing some setup on Chat Server?

brunogsa avatar May 30 '16 16:05 brunogsa

That issue was closed automatically. Please check if your issue is fixed with the latest release, and reopen if needed (with a fiddle reproducing the issue if possible).

darrachequesne avatar Jan 12 '17 16:01 darrachequesne