【问题标题】:uWSGI + nginx: request hangs if Content-Length specifieduWSGI + nginx:如果指定了 Content-Length,则请求挂起
【发布时间】:2017-05-31 02:29:39
【问题描述】:

我正在尝试建立一个非常简单的 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 也不记录任何内容。看起来好像请求没有到达服务器附近的任何地方。

这里是配置

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;
}

sites-enabled/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

任何提示表示赞赏。

【问题讨论】:

    标签: nginx uwsgi content-length


    【解决方案1】:

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

    Nginx connection reset, response from uWsgi lost

    【讨论】:

      猜你喜欢
      • 2016-03-05
      • 1970-01-01
      • 1970-01-01
      • 2015-12-29
      • 2011-07-06
      • 2020-09-21
      • 1970-01-01
      • 2011-04-20
      • 1970-01-01
      相关资源
      最近更新 更多