1

I'm developing Django Web Services. I'm trying to avail PUSH using WebSocket (ws://). Till now there is no support for ws in nGINX. So I'm using Tornado Server to host WebSocket. Many (almost all) Tutorials have solution using Socket.io. I dont want to use Socket.io coz its not pure WebSocket (as per me). I just want to use ws and not Socket.io (Node.js).

Well, my front-end server should be nGINX to serve HTTP Requests. ws:// Requests should be passed to Tornado Server (or any other Server if supported)

Kartik Rokde
  • 3,633
  • 8
  • 27
  • 33

2 Answers2

1

Here is NGINX configuration snippet

map $http_upgrade $connection_upgrade {
    default upgrade;
    '' close;
}

upstream websocket {
    server 192.168.100.10:8010;
}

server {
    listen 8020;
    location / {
        proxy_pass http://websocket;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection $connection_upgrade;
    }
}

More details could be found in theirs blog https://www.nginx.com/blog/websocket-nginx/

frist
  • 1,918
  • 12
  • 25
0

At the time of writing Nginx didn't support websockets - now supported in 1.3.13 (Feb 2013)

The problem is that nginx does not support websockets, since it terminates and proxies the data to the downstream service. You'll need to put HAProxy in front of your nginx server to route traffic the way you want.

Good example is here - HAProxy + WebSocket Disconnection - while they're talking about nodejs as the backend service, everything is in essence the same.

Community
  • 1
  • 1
koblas
  • 25,410
  • 6
  • 39
  • 49