502错误的网关nginx / 1.14.0(Ubuntu)Django

好吧,我已经在DigitalOcean上部署了Django应用程序,并使用了我购买的域。现在,它显示了502 Bad Gateway nginx/1.14.0 (Ubuntu),而不是默认的应用程序页面。并且nginx错误日志返回以下错误:

*4 connect() to unix:/home/username/project.sock failed (111: Connection refused) while connecting to upstream,client: 82.194.22.116,server: challenge.com,request: "GET / HTTP/1.1",upstream: "http://unix:/home/username/project.sock:/",host: "challenge.com"

我的nginx配置:

server {
    listen 80;
    server_name challenge.com;

    location = /favicon.ico { access_log off; log_not_found off; }
    location /static/ {
        root /home/username;
    }

    location / {
        include proxy_params;
        proxy_pass http://unix:/home/username/ccproject.sock;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-Host $server_name;
    }
}

我在settings.py中的设置:

ALLOWED_HOSTS = ['64.225.1.249','challenge.com']

我的套接字文件在/home/username/

独角兽状态:

(env) progbash@challengers:~/ccproject$ sudo systemctl status gunicorn
● gunicorn.service - gunicorn daemon
   Loaded: loaded (/etc/systemd/system/gunicorn.service; enabled; vendor preset: enabled)
   active: failed (Result: exit-code) since Thu 2019-12-12 10:27:02 UTC; 1min 56s ago
  Process: 29262 ExecStart=/home/username/ccproject/env/bin/gunicorn --access-logfile - --workers 3 --bind unix:/home/username/ccproject.sock
 Main PID: 29262 (code=exited,status=1/FAILURE)

Dec 12 10:26:57 challenge systemd[1]: Started gunicorn daemon.
Dec 12 10:26:57 challenge gunicorn[29262]: [2019-12-12 10:26:57 +0000] [29262] [INFO] Starting gunicorn 20.0.4
Dec 12 10:26:57 challengers gunicorn[29262]: [2019-12-12 10:26:57 +0000] [29262] [ERROR] retrying in 1 second.
Dec 12 10:26:58 challenge gunicorn[29262]: [2019-12-12 10:26:58 +0000] [29262] [ERROR] retrying in 1 second.
Dec 12 10:26:59 challengers gunicorn[29262]: [2019-12-12 10:26:59 +0000] [29262] [ERROR] retrying in 1 second.
Dec 12 10:27:00 challenge gunicorn[29262]: [2019-12-12 10:27:00 +0000] [29262] [ERROR] retrying in 1 second.
Dec 12 10:27:01 challenge gunicorn[29262]: [2019-12-12 10:27:01 +0000] [29262] [ERROR] retrying in 1 second.
Dec 12 10:27:02 challenge gunicorn[29262]: [2019-12-12 10:27:02 +0000] [29262] [ERROR] Can't connect to /home/username/ccproject.sock
Dec 12 10:27:02 challenge systemd[1]: gunicorn.service: Main process exited,code=exited,status=1/FAILURE
Dec 12 10:27:02 challenge systemd[1]: gunicorn.service: Failed with result 'exit-code'.
diegod3433 回答:502错误的网关nginx / 1.14.0(Ubuntu)Django

您的Unix套接字是如何诞生的?您是否有/etc/systemd/system/gunicorn.socket个脚本,如下所示:https://docs.gunicorn.org/en/stable/deploy.html

本文链接:https://www.f2er.com/2935260.html

大家都在问