【问题标题】:configuring nginx on ubuntu for multiple uwsgi-emperor flask applications在 ubuntu 上为多个 uwsgi-emperor 烧瓶应用程序配置 nginx
【发布时间】:2015-07-18 11:26:28
【问题描述】:

我有两个烧瓶应用程序,我想在同一个网络服务器上托管。
我已经成功地运行了一个或另一个,但我似乎无法同时运行两者。

我使用了http://vladikk.com/2013/09/12/serving-flask-with-nginx-on-ubuntu/的设置

我的 nginx 配置和 uwsgi ini 文件是相同的;除了我根据应用程序和文件夹结构替换不同的文件夹名称,例如我的其他应用的“请求”或“演示应用”。

我的请求应用程序的 nginx 配置文件是

server {
    listen      80;
    server_name localhost;
    charset     utf-8;
    client_max_body_size 75M;

    location / { try_files $uri @yourapplication; }
    location @yourapplication {
        include uwsgi_params;
        uwsgi_pass unix:/var/www/request/request_uwsgi.sock;
    }
}

我的 uwsgi ini 文件是

[uwsgi]
#application's base folder
base = /var/www/request

#python module to import
app = open
module = %(app)

home = %(base)/venv
pythonpath = %(base)

#socket file's location
socket = /var/www/request/%n.sock

#permissions for the socket file
chmod-socket    = 666

#the variable that holds a flask application inside the module imported at line #6
callable = app

#location of log files
logto = /var/log/uwsgi/%n.log

这条线让我的应用程序正常运行

/etc/nginx/sites-enabled$ uwsgi --ini /var/www/request/request_uwsgi.ini


如果我为我的另一个应用程序关闭“请求”,它就会让另一个应用程序正常工作。

我的 nginx error.log 显示当我在站点中启用了两个配置文件时,我得到了这个

2015/05/07 10:03:45 [warn] 7527#0: conflicting server name "localhost" on 0.0.0.0:80, ignored
2015/05/07 10:03:45 [warn] 7527#0: conflicting server name "localhost" on 0.0.0.0:80, ignored
2015/05/07 10:03:46 [warn] 7531#0: conflicting server name "localhost" on 0.0.0.0:80, ignored
2015/05/07 10:03:46 [warn] 7531#0: conflicting server name "localhost" on 0.0.0.0:80, ignored
2015/05/07 10:04:06 [error] 7533#0: *1 connect() to unix:/var/www/demoapp/demoapp_uwsgi.sock failed (111: Connection refused) while connecting to upstream, client: 127.0.0.1, server: localhost, request: "GET /login HTTP/1.1", upstream: "uwsgi://unix:/var/www/demoapp/demoapp_uwsgi.sock:", host: "argonaut"
2015/05/07 10:04:08 [error] 7533#0: *1 connect() to unix:/var/www/demoapp/demoapp_uwsgi.sock failed (111: Connection refused) while connecting to upstream, client: 127.0.0.1, server: localhost, request: "GET /login HTTP/1.1", upstream: "uwsgi://unix:/var/www/demoapp/demoapp_uwsgi.sock:", host: "argonaut"
2015/05/07 10:30:10 [error] 7788#0: *1 open() "/usr/share/nginx/html/login" failed (2: No such file or directory), client: 127.0.0.1, server: localhost, request: "GET /login HTTP/1.1", host: "argonaut"
2015/05/07 10:31:54 [error] 7833#0: *1 open() "/usr/share/nginx/html/request" failed (2: No such file or directory), client: 127.0.0.1, server: localhost, request: "GET /request HTTP/1.1", host: "argonaut"

“argonaut”是我的服务器名称

我找不到任何运行两个烧瓶应用程序的配置示例,甚至找不到关于如何编写 conf 文件的很好的解释。

更新 我正在考虑放弃并在我的服务器上设置一个带有单独 nginx 的虚拟机来托管多个应用程序。

谢谢!

【问题讨论】:

    标签: python ubuntu nginx flask uwsgi


    【解决方案1】:

    在 nginx 中,您可以通过更改 server_name 来重复服务器组件。操作 server_name 可以来自简单的 dns A Record 或 CNAME。完整答案见https://stackoverflow.com/a/27221427/567606/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-09-18
      • 1970-01-01
      • 2013-09-01
      • 1970-01-01
      • 2019-09-29
      • 2012-11-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多