502错误的网关Nginx与Gunicorn和Django

时间:2019-10-08 10:06:09

标签: django nginx deployment gunicorn

我正在使用gunicorn和nginx部署django项目。我的nginx设置是

server {
listen 8000;
server_name 0.0.0.0;

location = /favicon.ico { access_log off; log_not_found off; }

location /static/ {
        root /home/gagan/saporawebapp;
}

location / {
        include proxy_params;
        proxy_pass http://unix:/home/gagan/saporawebapp/saporawebapp.sock;
}
}

我跑步时

sudo nginx -t

它表明设置正确。然后我开始使用

gunicorn --daemon --workers 3 --bind unix:/home/gagan/saporawebapp/saporawebapp.sock saporawebapp.wsgi

然后nginx显示502错误的网关。相应的错误日志是

2019/10/08 07:51:34 [emerg] 3988#3988: open()     "/etc/nginx/sites-enabled/saporawebapp" failed (2: No such file or directory) in /etc/nginx/nginx.conf:62
2019/10/08 07:59:54 [crit] 4278#4278: *1 connect() to unix:/home/ubuntu/myproject/myproject.sock failed (2: No such file or directory) while connecting to upstream, client: 42.108.169.252, server: 0.0.0.0, request: "GET /signup/ HTTP/1.1", upstream: "http://unix:/home/ubuntu/myproject/myproject.sock:/signup/", host: "157.245.108.160:8000"
2019/10/08 08:05:19 [crit] 4278#4278: *5 connect() to unix:/home/ubuntu/myproject/myproject.sock failed (2: No such file or directory) while connecting to upstream, client: 42.108.169.252, server: 0.0.0.0, request: "GET /signup/ HTTP/1.1", upstream: "http://unix:/home/ubuntu/myproject/myproject.sock:/signup/", host: "157.245.108.160:8000"
2019/10/08 08:06:24 [crit] 4744#4744: *1 connect() to unix:/home/ubuntu/myproject/myproject.sock failed (2: No such file or directory) while connecting to upstream, client: 42.108.169.252, server: 0.0.0.0, request: "GET /signup/ HTTP/1.1", upstream: "http://unix:/home/ubuntu/myproject/myproject.sock:/signup/", host: "157.245.108.160:8000"
2019/10/08 08:14:47 [alert] 5279#5279: 768 worker_connections are not enough
2019/10/08 08:14:47 [error] 5279#5279: *763 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 157.245.108.160, server: 0.0.0.0, request: "GET /signup/ HTTP/1.0", upstream: "http://157.245.108.160:8000/signup/", host: "157.245.108.160:8000"
2019/10/08 09:49:53 [crit] 11601#11601: *1 connect() to unix:/home/gagan/saporawebapp/saporawebapp.sock failed (2: No such file or directory) while connecting to upstream, client: 42.108.169.252, server: 0.0.0.0, request: "GET / HTTP/1.1", upstream: "http://unix:/home/gagan/saporawebapp/saporawebapp.sock:/", host: "157.245.108.160:8000"

0 个答案:

没有答案