连接到unix:/run/gunicorn.sock失败(111:连接被拒绝),同时连接到上游 - 尝试将django应用程序上传到digitalocean

问题描述 投票:0回答:1

我正在尝试将我的 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
所以我需要这方面的帮助。

python django nginx gunicorn
1个回答
0
投票
您需要使用 certbot 生成 ssl 证书,这是完整过程的教程,certbot 部分在 57:30 分钟内

© www.soinside.com 2019 - 2024. All rights reserved.