Nginx为同一域下的多个Flask应用程序提供404

时间:2019-02-25 12:04:57

标签: flask uwsgi flask-restful nginx-config

我正在尝试在同一域上运行Flask Web应用程序和Flask Restful API。
当它们单独运行时,它们都运行良好。
我没有使用venv

但是,当我尝试在同一个域中运行它们时,Nginx抛出错误-404,未找到。另外,localhost/可以正常运行网络应用,没有错误,但是localhost/weblocalhost/rest给出了404。

request.url打印http://localhost/webhttp://localhost/rest,但是请求没有发送到负责`/ rest'的烧瓶服务器,因为第二个服务器未记录任何数据(宁静的api)。所有记录的数据仅适用于第一台服务器(Web应用程序)。

#Nginx.conf:

server {
  listen      80;
  server_name localhost;   

  location /web {
    include uwsgi_params;
    uwsgi_pass unix:/var/www/webproject/web_uwsgi.sock;
  }    

  location /api {
    include uwsgi_params;
    uwsgi_pass unix:/var/www/restproject/rest_api_uwsgi.sock;
  } 

}

#webproject.ini                    #restproject.ini
[uwsgi]                            [uwsgi]
vhost = true                       vhost = true
project = webproject               project = restproject
base = /var/www/                   base = /var/www/
chdir = %(base)%(project)          chdir = %(base)%(project)
wsgi-file = run.py                 wsgi-file = api.py
callable = app                     callable = ap
mount = /webproject = app          mount = /restproject = ap
manage-script-name = true          manage-script-name = true
plugins = python                   plugins = python
socket = /var/www/webproject/%n.   socksocket = /var/www/restproject/%n.sock
chmod-socket    = 666              chmod-socket    = 666
logto = /var/log/uwsgi/%n.log      logto = /var/log/uwsgi/%n.log

任何建议都会有所帮助。

0 个答案:

没有答案