Python nginx gunicorn Flask应用程序未指向CentoOS 7上的我的应用程序目录
我正试图在Centos7服务器上部署一个小flask应用程序,我遵循了中的章节,基本上是用Python nginx gunicorn Flask应用程序未指向CentoOS 7上的我的应用程序目录,python,nginx,flask,centos7,gunicorn,Python,Nginx,Flask,Centos7,Gunicorn,我正试图在Centos7服务器上部署一个小flask应用程序,我遵循了中的章节,基本上是用/etc/nginx/conf.d/microblog.conf设置nginx: server { # listen on port 80 (http) listen 80; server_name _; location / { # redirect any requests to the same URL but on https retu
/etc/nginx/conf.d/microblog.conf
设置nginx
:
server {
# listen on port 80 (http)
listen 80;
server_name _;
location / {
# redirect any requests to the same URL but on https
return 301 https://$host$request_uri;
}
}
server {
# listen on port 443 (https)
listen 443 ssl;
server_name _;
# location of the self-signed SSL certificate
ssl_certificate /home/cocchi/git_dir/covid20/certs/cert.pem;
ssl_certificate_key /home/cocchi/git_dir/covid20/certs/key.pem;
# write access and error logs to /var/log
access_log /var/log/covid20_access.log;
error_log /var/log/covid20_error.log;
location / {
# forward application requests to the gunicorn server
proxy_pass http://127.0.0.1:8000;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location /static {
# handle static files directly, without forwarding to the application
alias /home/cocchi/git_dir/covid20/app/static;
expires 30d;
}
}
然后在/etc/systemd/system/covid20.service
()中设置gunicorn
距离:
现在,当我访问HTTPS网站时,我可以看到flask
以某种方式工作,因为它自动重定向到auth/login
,但我看到nginx error
查看/var/log/nginx/error.log
:
2020/04/24 19:19:46 [error] 8391#0: *6 open() "/usr/share/nginx/html/auth/login" failed (2: No such file or directory), client: 10.40.1.217, server: _, request: "GET /auth/login?next=%2F HTTP/1.1", host: "192.168.50.3"
显然与以下事实有关:nginx
没有指向我的项目目录home/cocchi/git\u dir/covid20
,但仍然指向默认的/usr/share/nginx/html
,我不明白为什么
我还将目录的所有权更改为nginx,然后更改为我的用户,但没有成功:
ls-ls/home/cocchi/git\u dir/
0 drwxrwxr-x 10 cocchi nginx 335 Apr 24 17:23 covid20
我在几家指南和网站上四处寻找,但什么也没找到,有人有线索吗??当然,这很简单,我失去了一些东西
提前非常感谢您的帮助 新冠病毒20?冠状病毒19还不够糟糕吗?新冠病毒20?冠状病毒19还不够糟糕吗?
2020/04/24 19:19:46 [error] 8391#0: *6 open() "/usr/share/nginx/html/auth/login" failed (2: No such file or directory), client: 10.40.1.217, server: _, request: "GET /auth/login?next=%2F HTTP/1.1", host: "192.168.50.3"