uWSGI + nginx:如果指定了Content-Length,请求会挂起

时间:2017-01-16 09:34:24

标签: nginx uwsgi content-length

我正在尝试建立一个非常简单的uWSGI + nginx项目。 我遇到了以下问题

  1. wsgi.input似乎是空的(我发现它试图获得 POST变量)

  2. curl http://localhost:8080/parsings工作正常,但curl http://localhost:8080/parsings --header "Content-Length:1"挂起,然后返回curl: (52) Empty reply from server

  3. nginx error.log上没有任何内容。 uWSGI也没有记录任何内容。看起来好像请求没有到达服务器附近的任何地方。
  4. 以下是配置

    nginx.conf

    user www-data;
    worker_processes auto;
    pid /run/nginx.pid;
    
    events {
        worker_connections 768;
    }
    
    http {
        sendfile on;
        tcp_nopush on;
        tcp_nodelay on;
        keepalive_timeout 65;
        types_hash_max_size 2048;
    
        include /etc/nginx/mime.types;
        default_type application/octet-stream;
    
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
        ssl_prefer_server_ciphers on;
    
        access_log /var/log/nginx/access.log;
        error_log /var/log/nginx/error.log;
    
        gzip on;
        gzip_disable "msie6";
    
        include /etc/nginx/conf.d/*.conf;
        include /etc/nginx/sites-enabled/*;
    
        proxy_buffers 8 32k;
        proxy_buffer_size 64k;
        proxy_connect_timeout   10;
        proxy_send_timeout      15;
        proxy_read_timeout      20;
    }
    

    启用位点-/ mysite的

    server {
        listen 127.0.0.1:8080;
        server_name myproject.local;
        client_max_body_size 2M;
    
        location / {
            include         uwsgi_params;
            uwsgi_read_timeout 300;
            uwsgi_pass      unix:///tmp/my_project.sock;
        }
    }
    

    uwsgi.ini

    [uwsgi]
    module = wsgi:application
    
    master = true
    processes = 5
    static-map = /static/=/home/breln/projects/myproject/static
    socket = /tmp/my_project.sock
    chmod-socket = 777
    chown-socket = www-data
    vacuum = true
    
    die-on-term = true
    

    Nginx是1.11.8(同样的问题出现在1.10.2)。 uWSGI是2.0.14

    任何提示都表示赞赏。

1 个答案:

答案 0 :(得分:0)

可能与uWSGI没有缓冲/从Nginx读取POST数据有关,除非你的WSGI应用程序试图在请求处理程序中使用POST数据:

Nginx connection reset, response from uWsgi lost