龙卷风Python:龙卷风服务器与NGINX集成 [英] tornado Python: Tornado server integration with NGINX

查看:152
本文介绍了龙卷风Python:龙卷风服务器与NGINX集成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在多核CPU上运行Tornado,并且每个Tornado IOLoop进程都在不同的内核上,并且我将使用NGINX将代理传递给Tornado进程.现在,当我检查 http://www.tornadoweb.org/en/stable/guide /running.html

I am trying to run Tornado on multicore CPU with each tornado IOLoop process on a different core, and I'll use NGINX for proxy pass to Tornado processes. Now when I check http://www.tornadoweb.org/en/stable/guide/running.html

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

Editing the actual configuration here for more details:

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

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

Now previously I was able to connect to socket ws://localhost:8888 from client (When I was running python main.py but now I can't connect. At the server, NGINX is changing the request to http somehow that I want to avoid. Access logs at tornado server:

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

如何使Nginx仅通过ws://而不通过http://

How can I make the nginx only communicate via ws:// not http://

推荐答案

我解决了这个问题,并通过覆盖所有龙卷风的check_origin函数(在所有情况下均返回true)解决了该问题.谢谢你们.

I figured out the issue and it was solved by override tornado's check_origin function by making it return true in all cases. Thank you all.

这篇关于龙卷风Python:龙卷风服务器与NGINX集成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆