nginx / uwsgi与django 1.9.8 - 错误的网关502错误上游过早关闭连接从上游读取响应头?

时间:2016-09-18 18:05:40

标签: django nginx uwsgi

我的 nginx_app.conf -

server
{

    listen 8000;
    #server_name
    access_log   /var/log/tw-access.log;
    error_log    /var/log/tw-error.log;
    root         /var/www/djangoapp;
    access_log    on;
    error_log     on;
    location /static/
    {
            alias /var/www/djangoapp/apptw/static/;
    }

    location /
     {
            uwsgi_pass          127.0.0.1:8800;
            include             uwsgi_params;
            uwsgi_read_timeout       500;


       }

}

和我的 uwsgi_app.ini -

    # djangoapp_uwsgi.ini file
[uwsgi]

# Django-related settings
# the base directory (full path)
chdir           = /var/www/djangoapp
# Django's wsgi file
module          = djangoapp.wsgi:application

# process-related settings
# master
master          = true
# maximum number of worker processes
processes       = 5
# the socket (use the full path to be safe
socket          = 127.0.0.1:8800
# ... with appropriate permissions - may be needed
chmod-socket    = 664
# clear environment on exit
vacuum          = true 
max-requests = 5000
uid = www-data
gid = www-data
enable-threads = true
buffer-size = 65535 

当我用server-IP:8000打开它时,它显示502-bad Gateway和nginx错误文件显示: -

    upstream prematurely closed connection while reading response header from upstream, 
client: 223.181.31.8, server: , request: "GET / HTTP/1.1", upstream: "uwsgi://127.0.0.1:8800", host: "server-IP:8000"

uwsgi日志: -

uwsgi logs :-

Sun Sep 18 01:35:19 2016 - -- unavailable modifier requested: 0 --
Sun Sep 18 13:38:49 2016 - -- unavailable modifier requested: 0 --
Sun Sep 18 13:38:49 2016 - -- unavailable modifier requested: 0 --
Sun Sep 18 13:47:03 2016 - SIGINT/SIGQUIT received...killing workers...
Sun Sep 18 13:47:04 2016 - worker 1 buried after 1 seconds
Sun Sep 18 13:47:04 2016 - worker 2 buried after 1 seconds
Sun Sep 18 13:47:04 2016 - worker 3 buried after 1 seconds
Sun Sep 18 13:47:04 2016 - worker 4 buried after 1 seconds
Sun Sep 18 13:47:04 2016 - worker 5 buried after 1 seconds
Sun Sep 18 13:47:04 2016 - goodbye to uWSGI.
Sun Sep 18 13:47:04 2016 - VACUUM: unix socket /run/uwsgi/app/tw/socket removed.
Sun Sep 18 13:47:05 2016 - *** Starting uWSGI 2.0.12-debian (64bit) on [Sun Sep 18 13:47:04 2016] ***
Sun Sep 18 13:47:05 2016 - compiled with version: 5.3.1 20160412 on 13 April 2016 08:36:06
Sun Sep 18 13:47:05 2016 - os: Linux-2.6.32-042stab113.17 #1 SMP Wed Feb 10 18:31:00 MSK 2016
Sun Sep 18 13:47:05 2016 - nodename: cot-stg-1
Sun Sep 18 13:47:05 2016 - machine: x86_64
Sun Sep 18 13:47:05 2016 - clock source: unix
Sun Sep 18 13:47:05 2016 - pcre jit disabled
Sun Sep 18 13:47:05 2016 - detected number of CPU cores: 4
Sun Sep 18 13:47:05 2016 - current working directory: /
Sun Sep 18 13:47:05 2016 - writing pidfile to /run/uwsgi/app/tw/pid
Sun Sep 18 13:47:05 2016 - detected binary path: /usr/bin/uwsgi-core
Sun Sep 18 13:47:05 2016 - setgid() to 33
Sun Sep 18 13:47:05 2016 - setuid() to 33
Sun Sep 18 13:47:05 2016 - chdir() to /var/www/django_app
Sun Sep 18 13:47:05 2016 - your processes number limit is 514923
Sun Sep 18 13:47:05 2016 - your memory page size is 4096 bytes
Sun Sep 18 13:47:05 2016 - detected max file descriptor number: 1024
Sun Sep 18 13:47:05 2016 - lock engine: pthread robust mutexes
Sun Sep 18 13:47:05 2016 - thunder lock: disabled (you can enable it with --thunder-lock)
Sun Sep 18 13:47:05 2016 - uwsgi socket 0 bound to UNIX address /run/uwsgi/app/tw/socket fd 3
Sun Sep 18 13:47:05 2016 - uwsgi socket 1 bound to TCP address 127.0.0.1:8800 fd 5
Sun Sep 18 13:47:05 2016 - your server socket listen backlog is limited to 100 connections
Sun Sep 18 13:47:05 2016 - your mercy for graceful operations on workers is 60 seconds
Sun Sep 18 13:47:05 2016 - mapped 805242 bytes (786 KB) for 5 cores
Sun Sep 18 13:47:05 2016 - *** Operational MODE: preforking ***
Sun Sep 18 13:47:05 2016 - *** no app loaded. going in full dynamic mode ***
Sun Sep 18 13:47:05 2016 - *** uWSGI is running in multiple interpreter mode ***
Sun Sep 18 13:47:05 2016 - !!!!!!!!!!!!!! WARNING !!!!!!!!!!!!!!
Sun Sep 18 13:47:05 2016 - no request plugin is loaded, you will not be able to manage requests.
Sun Sep 18 13:47:05 2016 - you may need to install the package for your language of choice, or simply load it with --plugin.
Sun Sep 18 13:47:05 2016 - !!!!!!!!!!! END OF WARNING !!!!!!!!!!
Sun Sep 18 13:47:05 2016 - spawned uWSGI master process (pid: 8733)
Sun Sep 18 13:47:05 2016 - spawned uWSGI worker 1 (pid: 8735, cores: 1)
Sun Sep 18 13:47:05 2016 - spawned uWSGI worker 2 (pid: 8736, cores: 1)
Sun Sep 18 13:47:05 2016 - spawned uWSGI worker 3 (pid: 8737, cores: 1)
Sun Sep 18 13:47:05 2016 - spawned uWSGI worker 4 (pid: 8738, cores: 1)
Sun Sep 18 13:47:05 2016 - spawned uWSGI worker 5 (pid: 8739, cores: 1)
Sun Sep 18 13:47:27 2016 - -- unavailable modifier requested: 0 --
Sun Sep 18 13:55:41 2016 - -- unavailable modifier requested: 0 --
Sun Sep 18 13:55:43 2016 - -- unavailable modifier requested: 0 --
Sun Sep 18 13:57:03 2016 - -- unavailable modifier requested: 0 --

我该怎么办?请建议。

提前谢谢你......

0 个答案:

没有答案