簡體   English   中英

Django-Gunicorn / Nginx-502錯誤網關

[英]Django - Gunicorn/Nginx - 502 Bad Gateway

在502 Bad Gateway ngnix / 1.10.3上需要幫助

我已經使用Nginx / Gunicorn配置了Django應用程序。 在我對代碼進行一些更改並重新加載服務器之前,它運行良好。

僅供參考:我的settings.py具有ALLOWED_HOSTS = ['*']

在此處輸入圖片說明

錯誤日志:

2018/06/27 08:36:38 [crit] 7444#7444: *35 connect() to unix://home/ubuntu/www/MySite/MySite.sock failed (13: Permission denied) while connecting to upstream, client: 106.51.16.0, server: 18.191.255.247, request: "GET /report/ HTTP/1.1", upstream: "http://unix://home/ubuntu/www/MySite/MySite.sock:/report/", host: "18.191.255.247"
2018/06/27 08:36:40 [crit] 7444#7444: *35 connect() to unix://home/ubuntu/www/MySite/MySite.sock failed (13: Permission denied) while connecting to upstream, client: 106.51.16.0, server: 18.191.255.247, request: "GET /report/ HTTP/1.1", upstream: "http://unix://home/ubuntu/www/MySite/MySite.sock:/report/", host: "18.191.255.247"
2018/06/27 08:36:41 [crit] 7444#7444: *35 connect() to unix://home/ubuntu/www/MySite/MySite.sock failed (13: Permission denied) while connecting to upstream, client: 106.51.16.0, server: 18.191.255.247, request: "GET /report/ HTTP/1.1", upstream: "http://unix://home/ubuntu/www/MySite/MySite.sock:/report/", host: "18.191.255.247"
2018/06/27 08:39:06 [crit] 7444#7444: *41 connect() to unix://home/ubuntu/www/MySite/MySite.sock failed (13: Permission denied) while connecting to upstream, client: 106.51.16.0, server: 18.191.255.247, request: "GET /report/ HTTP/1.1", upstream: "http://unix://home/ubuntu/www/MySite/MySite.sock:/report/", host: "18.191.255.247"

更新1:

這是我的Nginx配置。 這有什么問題嗎?

在/ etc / nginx的/網站可用/ mysite的

server {
    listen 80;
    server_name 18.191.255.247;

    location = /favicon.ico { access_log off; log_not_found off; }
    location /static/ {
        root /home/ubuntu/www/MySite;
    }

    location / {
        include proxy_params;
        proxy_pass http://unix://home/ubuntu/www/MySite/MySite.sock;
    }
}

我如何驗證Nginx守護程序對項目文件夾的權限(// unix:// home / ubuntu / www / MySite)

嘗試將代理傳遞URL手動設置為在服務器上運行項目的端口gunicorn,如下所示:

location / {
                proxy_pass         http://localhost:8000;
                proxy_redirect     off;
                proxy_set_header   Host              $http_host;
                proxy_set_header   X-Real-IP         $remote_addr;
                proxy_set_header   X-Forwarded-For   $proxy_add_x_forwarded_for;
                proxy_connect_timeout 500;
                proxy_read_timeout 600;
        }

暫無
暫無

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

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