Tornado websocket演示的Nginx配置?

时间:2014-03-13 01:13:02

标签: nginx websocket chat tornado demo

有人可以为我提供Tornado websocket聊天演示的Nginx配置吗?该演示位于/ tornado / demos / websocket ...

1 个答案:

答案 0 :(得分:5)

这样的配置将起作用:

events {
    worker_connections  1024;
}

http {
    upstream chatserver {
        server 127.0.0.1:8888;
    }

    server {
        # Requires root access.
        listen       80;

        # WebSocket.
        location /chatsocket {
            proxy_pass http://chatserver;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
        }

        location / {
            proxy_pass http://chatserver;
        }
    }
}

您需要以root身份运行Nginx才能侦听端口80.现在您可以使用浏览器访问“localhost”。 More info on Nginx and websockets here