我上面有一个VPS和NGINX,我正在尝试运行flask应用程序,并且我希望flask应用程序的地址类似于site.com/flask
,但是该位置对此无效,它仅运行主地址{{1} }
site.com
但是如果我删除server {
listen 80;
listen 443 ssl;
ssl_certificate /etc/letsencrypt/live/bot.itarashe.zone/cert.pem ;
ssl_certificate_key /etc/letsencrypt/live/bot.itarashe.zone/privkey.pem ;
ssl_trusted_certificate /etc/letsencrypt/live/bot.itarashe.zone/chain.pem ;
server_name bot.itarashe.zone www.bot.itarashe.zone ;
location = ~^/flask/ {
include proxy_params;
proxy_pass http://unix:/home/saeb/py/flask/myproject/myproject.sock;
}
location / {}
}
它在主地址工作
~^/flask
我尝试了
ssl_certificate /etc/letsencrypt/live/bot.itarashe.zone/cert.pem ;
ssl_certificate_key /etc/letsencrypt/live/bot.itarashe.zone/privkey.pem ;
ssl_trusted_certificate /etc/letsencrypt/live/bot.itarashe.zone/chain.pem ;
server_name bot.itarashe.zone www.bot.itarashe.zone ;
location / {
include proxy_params;
proxy_pass http://unix:/home/saeb/py/flask/myproject/myproject.sock;
}
}
他们都没有工作, 访问日志是:
location /flask {}
location /flask/ {}
location ~^/flask {}
location = ...
,错误日志未显示任何错误:
104.244.78.207 - - [27/Sep/2018:01:50:13 -0400] "GET /flask/ HTTP/1.1" 404 209 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:62.0) Gecko/20100101 Firefox/62.0"
答案 0 :(得分:0)
好了,我的问题解决了,Nginx完成了它需要做的事情,它调用套接字,但是使用/flask
而且我没有定义@app.route('/flask')