최근에 발생한 문제는 하위 디렉토리에서 플라스크 응용 프로그램을 실행하는 방법이었습니다. 예를 들어, mysite.com/myapp가 플라스크 앱을 실행하고 mysite.com/some_other가 다른 스크립트를 완전히 실행하게 할 수 있습니다. mysite.com/에서 플라스크 앱을 실행하는 방법에 대한 웹 튜토리얼이 많이 있지만, 서브 디렉토리 문제를 해결하기 위해 갔을 때 오래된 정보를 발견했습니다.nginx 및 uwsgi를 사용하여 하위 디렉토리에서 플라스크 응용 프로그램을 제공하는 방법
1
A
답변
1
내가 처음에 이것을 조사하기 시작했을 때, uwsgi_param SCRIPT_NAME /mysubdir
과 uwsgi_modifier1 30
을 nginx 설정 파일에 넣어야한다고 주장하는 수많은 사이트를 발견했습니다. 분명히 이것은 2017 (nginx nginx/1.10.3 및 uwsgi 2.0.15)의 오래된 정보입니다.
아래 config 파일은 하위 디렉토리에 필요한 것입니다.
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
처럼 보인다