【问题标题】:running nginx, uwsgi, bottle on ec2 micro instance在 ec2 微实例上运行 nginx、uwsgi、bottle
【发布时间】:2013-09-20 16:24:31
【问题描述】:

我正在尝试在 ec2 微型实例上设置 nginx、uwsgi、bottle.py。到目前为止,我已经安装了组件并且 nginx 工作正常,提供了一个测试 index.html 页面。如果我停止 nginx 服务器并在 python 的内部开发服务器上运行一个测试瓶应用程序,它也可以工作。

但是,我的 uwsgi 不工作。这是我在 etc/nginx/site-enabled/ 中的“默认”文件。我正在使用附加到我的微型实例的弹性 ip (xx.xx.xx.xx)。

upstream _bottle {
    server xx.xx.xx.xx:80;
}

server {
    listen 80;
    server_name xx.xx.xx.xx;
    root /var/www/app;

    location / {
        try_files $uri @uwsgi;
    }

    location @uwsgi {
        include uwsgi_params;
        uwsgi_pass _bottle;
    }
}

这是我的 uwsgi 配置文件:

[uwsgi]
chdir = /var/www/app
master = true
plugins = python
file = index.py
uid = www-data
gid = www-data

我还确保:

sudo chown -R www-data:www-data /var/www/app

当我重新启动 nginx 和 uwsgi 并使用浏览器访问弹性 ip 地址时,我得到了 nginx 的错误网关页面。

nginx 错误日志给了我:

*1 upstream prematurely closed connection while reading response header from upstream, client.....

我读过“上游过早关闭”错误表明内存/cpu/资源问题?这是否与使用微实例并且没有足够的资源有关?但是通过浏览器访问这个微实例的唯一人是我。

【问题讨论】:

    标签: nginx amazon-ec2 uwsgi bottle


    【解决方案1】:

    您的 uwsgi 配置文件中似乎缺少 socket 指令。您的设置不正确。

    NGINX 将请求传递给通道上的 uWSGI 进程。它可以是网络套接字或文件套接字(命名管道)。 您没有配置此频道。

    在你的 uwsgi 配置中声明一个文件套接字

    socket = /tmp/bottle.socket
    

    并且在您的 nginx 配置中使用该套接字作为上游:

    upstream _bottle {
        server unix:/tmp/bottle.socket;
    }
    

    还记得在你的位置指令中传递 uwsgi 参数

    include uwsgi_params;
    

    欲了解更多信息,请参阅official documentation

    【讨论】:

      猜你喜欢
      • 2014-01-17
      • 2014-03-31
      • 1970-01-01
      • 2013-04-09
      • 1970-01-01
      • 1970-01-01
      • 2013-10-02
      • 2013-02-19
      • 2019-03-05
      相关资源
      最近更新 更多