龙卷风Python:龙卷风服务器与NGINX的集成

时间:2016-04-01 16:59:54

标签: python nginx tornado

我试图在多核CPU上运行Tornado,每个龙卷风IOLoop进程在不同的核心上,我将使用NGINX代理传递给Tornado进程。现在,当我检查http://www.tornadoweb.org/en/stable/guide/running.html

在此处编辑实际配置以获取更多详细信息:

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;
    }
  }
}

现在我以前能够从客户端连接到socket ws:// localhost:8888(当我运行 python main.py 但是现在我无法连接。在服务器上,NGINX正在以某种方式将请求更改为http,我想避免。在龙卷风服务器上访问日志:

WARNING:tornado.access:400 GET /search_image (127.0.0.1) 0.83ms

如何让nginx仅通过ws://而不是http://

进行通信

1 个答案:

答案 0 :(得分:0)

我想出了这个问题,它通过覆盖龙卷风的check_origin函数解决,使其在所有情况下都返回true。谢谢你们。

相关问题