2016-05-25 17 views
1

Meine nginx und uwsgi Konfiguration funktioniert perfekt für die ersten ein oder zwei Anfragen. Dann nginx zeigt 502 Bad Gateway. Wenn ich den uwsgi-Dienst neu starte, passiert dasselbe wieder. Ich benutze Ubuntu 16.04. Hier ist meine alle conf und Fehlerprotokoll:nginx uwsgi 502 Schlecht Gateway

nginx conf:

upstream book { 
    server unix:///tmp/book.sock; 
} 

server { 
    listen 80; 
    server_name example.com; 
    return 301 https://$host$request_uri; 
} 

server { 
    listen 443 ssl http2; 
    server_name example.com; 
    ...... 
    add_header X-Frame-Options DENY; 
    add_header X-Content-Type-Options nosniff; 

    charset utf-8; 

    client_max_body_size 100M; 

    access_log /var/log/nginx/example.com_access.log; 
    error_log /var/log/nginx/example.com_error.log; 

    location /media { 
     alias /home/prism/prod/example.com/media; 
    } 

    location /static { 
     alias /home/prism/prod/example.com/static; 
    } 

    location/{ 
     uwsgi_pass book; 
     include  /etc/nginx/uwsgi_params; 
    } 

} 

/var/log/nginx/example.com_error.log

2016/05/25 17:44:26 [error] 5230#5230: *214 connect() to unix:///tmp/book.sock failed (111: Connection refused) while connecting to upstream, client: 27.*.*.*, server: example.com, request: "GET/HTTP/2.0", upstream: "uwsgi://unix:///tmp/book.sock:", host: "example.com" 

hiren.ini

[uwsgi] 
chdir=/home/prism/prod/example.com 
home = /home/prism/prod/example.com/.env 
module=hiren.wsgi 
master=True 
process = 5 
pidfile=/tmp/book.pid 
socket= /tmp/book.sock 
vacuum=True 
max-requests=5000 
daemonize=/home/prism/prod/example.com/hiren.log 
uid = www-data 
gid = www-data 
die-on-term = true 

und Service-Datei:

[Unit] 
Description=uWSGI instance to serve example.com 

[Service] 
User=prism 
ExecStart=/bin/bash -c 'cd /home/prism/prod/example.com; source .env/bin/activate; uwsgi --ini hiren.ini' 

[Install] 
WantedBy=multi-user.target 
+0

Bad Gateway Fehler zeigt den Zusammenhang zwischen nginx und Ihre App zwicken gebrochen, so würde ich hier nicht vermuten nginx conf. Dies liegt normalerweise daran, dass die App selbst nicht reagiert. Haben Sie überprüft, dass der uWSGI-Dienst noch läuft? Hast du ein Logbuch von uWSGI? –

Antwort

0

das Problem gelöst durch systemd Skript

[Unit] 
Description=uWSGI instance to serve example.com 

[Service] 
ExecStart=/bin/bash -c 'su prism; cd /home/prism/prod/example.com; source .env/bin/activate; uwsgi --ini hiren.ini' 

[Install] 
WantedBy=multi-user.target 
Verwandte Themen