Search code examples
djangonginxhttp-headershttp-errorchunked-encoding

Receiving 411 errors with Haproxy + Nging when uploading with chunked encoding


here is my server architecture:

port 443 --> haproxy 1.6.3 --> nginx 1.1.19 --> uwsgi 2.0.13.1 --> wsgi python server (Django)

I know it's weird to use both haproxy+nginx but I have no choice because I need haproxy for another project on the same server on port 443.

here is my haproxy config:

frontend www-https
   bind *:443 ssl crt /etc/ssl/private/
   mode     http
   option   httpclose
   acl nginx hdr_end(host) -i example.com

backend nginx
    mode                http
    balance             leastconn
    option              forwardfor
    option              http-server-close
    option              forceclose
    no option           httpclose
    server nginx-01 nginx:52654 check

and here is my nginx config

server {
    listen      52654 default_server;
    charset     utf-8;
    client_max_body_size 75M;
    chunked_transfer_encoding on;
    location / {
        uwsgi_pass  django;
        proxy_buffering off;
        uwsgi_param  QUERY_STRING       $query_string;
        uwsgi_param  REQUEST_METHOD     $request_method;
        uwsgi_param  CONTENT_TYPE       $content_type;
        uwsgi_param  CONTENT_LENGTH     $content_length;

        uwsgi_param  REQUEST_URI        $request_uri;
        uwsgi_param  PATH_INFO          $document_uri;
        uwsgi_param  DOCUMENT_ROOT      $document_root;
        uwsgi_param  SERVER_PROTOCOL    $server_protocol;
        uwsgi_param  HTTPS              $https if_not_empty;

        uwsgi_param  REMOTE_ADDR        $remote_addr;
        uwsgi_param  REMOTE_PORT        $remote_port;
        uwsgi_param  SERVER_PORT        $server_port;
        uwsgi_param  SERVER_NAME        $server_name;
    }
}

Problem I have is that when I make an upload wuth a web client using chunked encoding, I get the 411 HTTP error Content-Length required.

If I bypass haproxy it's working fine. But using haproxy + nginx gives me the 411 error for chunked encoding.

Any idea?


Solution

  • Your nginx version is quite old. Try upgrade it.