[英]uWSGI: how to serve static files from root and an app from a sub directory?
[英]How to serve a flask app out of a sub directory with nginx and uwsgi
我最近遇到的一個問題是如何從子目錄中運行一個燒瓶應用程序。 例如,您可能希望mysite.com/myapp運行一個燒瓶應用程序,而mysite.com/some_other則完全運行另一個腳本。 網上有很多關於如何從mysite.com/運行燒瓶應用程序的好教程,但是當我去解決子目錄問題時,我發現了一些過時的信息。
當我第一次開始研究這個時,我發現有很多網站主張我應該在nginx配置文件中放置uwsgi_param SCRIPT_NAME /mysubdir
和uwsgi_modifier1 30
。 顯然,這是截至2017年的過時信息(nginx nginx / 1.10.3和uwsgi 2.0.15)。
下面的配置文件是子目錄所需的全部內容。
server {
listen 80;
server_name wf.idt.com;
location /mysubdir {
include /etc/nginx/uwsgi_params;
uwsgi_pass unix:///var/python/myapp/myapp.sock;
}
}
接下來,您需要在uwsgi ini文件中添加一些項目。 我的存儲在與python文件相同的目錄中。 這些是要添加的行。
## Settings to deal with the subdirectory
manage-script-name = true
mount=/mysubdir=wsgi.py
所以完整的.ini文件現在看起來像這樣
[uwsgi]
module = wsgi:application
#location of log files
logto = /var/log/uwsgi/app/%n.log
master = true
processes = 5
## Settings to deal with the subdirectory
manage-script-name = true
mount=/myapp=wsgi.py
socket = myapp.sock
chmod-socket = 660
vacuum = true
die-on-term = true
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.