在同一台服务器上运行Tornado和Nginx [英] running Tornado and Nginx on same server

查看:138
本文介绍了在同一台服务器上运行Tornado和Nginx的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在有一个由nginx提供服务的静态网站,并且我想在同一台服务器上使用Tornado开发一个应用程序.

I have a static website served up by nginx right now, and I want to develop an app with Tornado on the same server.

Tornado文档提到wsgi不支持非阻塞请求.

The Tornado documentation mentions that wsgi doesn't support non-blocking requests.

我是否有办法让他们(在同一台服务器上)一起工作?

Is there a way for me to get them to work together (on the same server)?

推荐答案

可以.看看龙卷风首页上的 nginx.conf示例.

Sure you can. Take a look at the nginx.conf example on tornado's homepage.

与您相关的情况是:

http {
    # Enumerate all the Tornado servers here
    upstream frontends {
        server 127.0.0.1:8000;
        server 127.0.0.1:8001;
        server 127.0.0.1:8002;
        server 127.0.0.1:8003;
    }
    ...
    server {
        ...
        # for your "static" website
        location ^~ /static/ {
            root /var/www;
            if ($query_string) {
                expires max;
            }
        }
        # for your tornado's app
        location / {
            proxy_pass_header Server;
            proxy_set_header Host $http_host;
            proxy_redirect false;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Scheme $scheme;
            proxy_pass http://frontends;
        }
        ...
    }
    ...
}

这篇关于在同一台服务器上运行Tornado和Nginx的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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