【问题标题】:NginX to serve uWSGI running on another instanceNginX 为在另一个实例上运行的 uWSGI 提供服务
【发布时间】:2017-11-07 14:45:57
【问题描述】:

实例 1:我在一个实例上运行 uWSGI 和 Nginx,api.test.com 可以访问该实例。

实例 2:我还有另一个运行 uWSGI 和 Nginx 的 AWS 实例,可以通过 ec2-x-x-x-x.com 访问。

我试图通过使用第一个 url:api.text.com 访问在我的第二个实例中运行的 uWSGi,而不更改任何与域名相关的内容。

初始实例 1:

server {
    listen 80;
    server_name www.api.test.com api.test.com;

    location / {
        include uwsgi_params;
        uwsgi_pass 127.0.0.1:5000;
    }
}

初始实例 2:

server {
    location / {
        include uwsgi_params;
        uwsgi_pass 127.0.0.1:5000;
    }
}

Nginx 和 uWSGI 目前在这两个实例上都运行良好。

没有修改实例 2。最终实例 1:

server {
    listen 80;
    server_name www.api.test.com api.test.com;

    location / {
        include uwsgi_params;
        uwsgi_pass ec2-x-x-x-x.com:80;
    }
}

在实例 1 Nginx 记录上游过早关闭连接时引发错误。读过类似的问题,但想不通!

【问题讨论】:

    标签: nginx amazon-ec2 uwsgi


    【解决方案1】:

    自己解决了!

    uwsgi_pass ec2-x-x-x-x.com:5000; 而不是 uwsgi_pass ec2-x-x-x-x.com:80; 放在修改后的实例 1 中解决了它。我输入 :80 是因为我认为请求必须在实例 2 中通过 Nginx 但不是必需的。

    此外,实例2中的Nginx在从实例1访问实例2的uwsgi时不需要运行。如果你想从像ec2-x-x-x-x.com这样的浏览器访问它,必须有Nginx。

    【讨论】:

      猜你喜欢
      • 2013-09-20
      • 2017-04-06
      • 2016-01-02
      • 2014-07-01
      • 1970-01-01
      • 2019-08-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多