我正在尝试将我的 django 项目上传到 digitalocean Droplet。按照这篇文章https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-20-04上传它。
完成所有步骤后,我收到 502 bad gateway。此外,服务器不是在 SSL 上运行,而是在 http// 上运行。
我遵循了文章提供的每一个步骤。不知何故,在连接到上游时,出现了一个名为“connect() to unix:/run/gunicorn.sock failed (111: Connection Beenrejected)”的错误。
/etc/systemd/system/gunicorn.socket -----
[Unit]
Description=gunicorn socket
[Socket]
ListenStream=/run/gunicorn.sock
[Install]
WantedBy=sockets.target
/etc/systemd/system/gunicorn.service ----
[Unit]
Description=gunicorn daemon
Requires=gunicorn.socket
After=network.target
[Service]
User=sammy
Group=www-data
WorkingDirectory=/home/sammy/myprojectdir
ExecStart=/home/sammy/myprojectdir/myprojectenv/bin/gunicorn \
--access-logfile - \
--workers 3 \
--bind unix:/run/gunicorn.sock \
myproject.wsgi:application
[Install]
WantedBy=multi-user.target
/etc/nginx/sites-available/myproject -----
server {
listen 80;
server_name server_domain_or_IP;
location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
root /home/sammy/myprojectdir;
}
location / {
include proxy_params;
proxy_pass http://unix:/run/gunicorn.sock;
}
}
我运行了这个命令,但没有收到错误
sudo nginx -t && sudo systemctl restart nginx
所以我需要这方面的帮助。