【问题标题】:After configure the nginx, I can't see the index page配置好nginx后看不到index页面
【发布时间】:2015-04-22 06:18:27
【问题描述】:

这是我第一次使用nginx

我写了一个简单的python/tornado代码如下,当我使用python server.py时,我可以看到index.html页面。

from tornado.options import define, options
from db import MongoImpl

define("port", default=8000, help="run on the given port", type=int)

class IndexHandler(tornado.web.RequestHandler):

    def get(self):
        self.render("./pages/index.html")

app = tornado.web.Application([(r'/', IndexHandler)],
                            debug=True)
app.listen(options.port)
tornado.ioloop.IOLoop.instance().start()

然后我开始配置 nginx.conf,我在默认的 nginx.conf 中添加了以下内容:

http {
        server{
                listen 8000;
                root /home/ubuntu/work/mytornado/pages;
                index index.html index.htm;
        }

然后我nginx -s reload

但是,当我使用http://myipaddress 时,我只看到 nginx 欢迎页面,而不是我的索引 html....

有什么问题吗?

【问题讨论】:

    标签: python nginx tornado


    【解决方案1】:

    您不能在端口 8000 上同时运行 nginx 和您的龙卷风服务器。您需要为它们各自分配一个不同的端口,并使用 proxy_pass 指令配置 nginx 以代理 tornado(这将替换您拥有的 root 指令这里提供文件系统中的页面。如果您希望 nginx 提供文件系统中的一些文件和龙卷风中的一些文件,那么您需要使用两个 location 块。

    可在文档中找到用于 tornado 的完整 nginx 配置:http://www.tornadoweb.org/en/stable/guide/running.html#running-behind-a-load-balancer

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-08-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-03-20
      • 1970-01-01
      相关资源
      最近更新 更多