2016-09-27 116 views
0

我遇到過502 BadGateway錯誤。如何解決這個問題?如何解決這個錯誤Nginx和uwsgi 502壞網關

我逮住nginx的訪問日誌和錯誤日誌

訪問日誌

120.142.184.164 - - [27/Sep/2016:16:15:48 +0000] "GET/HTTP/1.1" 502 583 "-" "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.116 Safari/537.36" 

錯誤日誌

2016/09/27 16:15:48 [crit] 3585#0: *1 connect() to unix:/tmp/PROJECT_NAME.sock failed (13: Permission denied) while connecting to upstream, client: 120.142.184.164, server: 52.78.105.246, request: "GET/HTTP/1.1", upstream: "uwsgi://unix:/tmp/PROJECT_NAME.sock:", host: "52.78.105.246:8000" 

nginx的配置文件

server { 

    listen 8000; 
    server_name 52.78.105.246; 
    access_log /var/log/nginx/example_access.log; 
    error_log /var/log/nginx/example_error.log; 

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

    location/{ 
     include   uwsgi_params; 
     uwsgi_pass  unix:/tmp/PROJECT_NAME.sock; 
    } 
} 

uwsgi配置文件

[uwsgi] 
vhost=true 
project = PROJECT_NAME 
base = /home/ghdalsrn 
plugin = python 

chdir = %(base)/%(project) 
home = %(base)/.virtualenvs/ENV_NAME 
module = %(project).wsgi:application 

enable-threads = true 
master = true 
processes = 5 

socket = /tmp/%(project).sock 
chmod-socket=666 


vacuum = true 

我使用Django和Nginx的的c​​onfigtest說好,不許失敗。

我甚至作爲root用戶,這個錯誤總是發生。

的nginx/1.4.6 // Ubuntu的14 //

和PIP3凍結版本

chardet==2.2.1 
colorama==0.2.5 
command-not-found==0.3 
html5lib==0.999 
language-selector==0.1 
pbr==1.10.0 
pycurl==7.19.3 
pygobject==3.12.0 
python-apt==0.9.3.5ubuntu2 
requests==2.2.1 
six==1.10.0 
stevedore==1.17.1 
uWSGI==2.0.13.1 
ufw==0.34-rc-0ubuntu2 
unattended-upgrades==0.1 
urllib3==1.7.1 
virtualenv==15.0.3 
virtualenv-clone==0.2.6 
virtualenvwrapper==4.7.2 
wheel==0.24.0 

我該如何解決呢?

你能幫我嗎?

編輯

使用命令在TMP/*襪子

srw-rw-r-- 1 root  www-data 0 Sep 27 14:17 /tmp/PROJECT_NAME.sock 
srwxrwxr-x 1 ghdalsrn ghdalsrn 0 Sep 27 16:59 /tmp/uwsgi.sock 
+1

能否請您發佈。 'ls -la/tmp/*。sock'對我們的結果? – 2ps

+0

我剛剛加了@ 2ps – touchingtwist

+2

看看這個主題:你可能需要在uwsgi ini文件中設置uid和gid設置:http://stackoverflow.com/questions/22071681/permission-denied-nginx -and-uwsgi-socket – 2ps

回答

0

運行uswgi文件:

uwsgi --ini mysite_uwsgi的.ini

+0

在問題中做了什麼錯誤?任何相關的文檔鏈接? – melwil

+0

http://uwsgi-docs.readthedocs.io/en/latest/WSGIquickstart.html。 uwsgi需要啓用親切的重啓。如果不是,上述命令就足夠了。 –