簡體   English   中英

502 Bad Gateway nginx/1.14.0 (Ubuntu) Django

[英]502 Bad Gateway 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'.

你的 Unix 套接字是如何誕生的? 你有/etc/systemd/system/gunicorn.socket腳本嗎: https : //docs.gunicorn.org/en/stable/deploy.html

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM