I am trying to run a flask web app and a flask restful api on the same domain.
They both run fine, when they are run alone.
I am not using venv
.
However, when I try to run them under a same domain, Nginx throws an error - 404, not found. Also, localhost/
runs the web-app fine without errors but localhost/web
and localhost/rest
gives a 404.
The request.url
prints http://localhost/web
and http://localhost/rest
but request is not being sent to flask server responsible for `/rest', it seems, as no data is logged for the second server (the restful api). All logged data is for the 1st server (the web app) only.
#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
Any suggestion would be helpful.