我对django项目的502错误感到困惑。据我所知,nginx未能传递给gunicorn,但我不确定。我非常准确地遵循了这里的所有步骤https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-16-04
/etc/systemd/system/gunicorn.service
:
[Unit]
Description=gunicorn daemon
After=network.target[Unit]
Description=gunicorn daemon
After=network.target
[Service]
User=root
Group=www-data
WorkingDirectory=/home/root/glboy
ExecStart=/home/root/glboy/denv/bin/gunicorn --workers 3 --bind unix:/home/root/glboy/closer.sock closer.wsgi:application
[Install]
WantedBy=multi-user.target
/etc/nginx/sites-available/closer
和/etc/nginx/sites-enabled
:
server {
listen 80;
server_name 46.101.192.66;
location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
root /home/glboy/static;
}
location / {
include proxy_params;
proxy_pass http://unix:/home/root/glboy/closer.sock;
}
}
还找到了/etc/nginx/sites-available/default
也被编辑过的教程,尽管我还没有完全理解其目的,但还是试过了:
server {
listen 80;
server_name 46.101.192.66;
access_log /var/log/nginx/example.log;
location /static/ {
root /home/glboy/static;
expires 30d;
}
location / {
proxy_pass http://127.0.0.1:8000;
proxy_set_header Host $server_name;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
在nginx错误日志中报告缺少套接字
/home/root/glboy/closer.sock failed (2: No such file or directory)
我只是根据指示复制了路径应该如何,但如果错误的路径是对的还是错的呢?