[BUG] "client_body_in_file_only on" no longer works with upstream modules in nginx 1.3.9+

agentzh agentzh at gmail.com
Sun Jan 27 08:07:37 UTC 2013


Hello!

I've noticed that for nginx 1.3.9+, "client_body_in_file_only on" no
longer always sets r->request_body->bufs, which makes upstream modules
like ngx_proxy send empty request bodies to the backend server.

Here's a minimal example that demonstrates the issue:

    location = /t {
        client_body_in_file_only on;
        proxy_pass http://127.0.0.1:1234;
    }

And run nc to listen on the local port 1234:

    $ nc -l 1234

Then issue a simple POST request to location = /t:

    $ curl -d 'hello world' localhost/t

When using nginx 1.3.9+, we get the raw HTTP request sent by ngx_proxy:

    $ nc -l 1234
    POST /t HTTP/1.0
    Host: 127.0.0.1:1234
    Connection: close
    Content-Length: 11
    User-Agent: curl/7.24.0 (x86_64-redhat-linux-gnu) libcurl/7.24.0 ...
    Accept: */*
    Content-Type: application/x-www-form-urlencoded

That is, when the request body is completely preread into the client
header buffer, the request body will only be hooked into
r->request_body->temp_file but not r->request_body->bufs.

But when the request body is big enough that it is not completely
preread into the client header buffer, then the a in-file buf will
still be properly inserted into r->request_body->bufs and we can get
the expected request body sent from ngx_proxy.

And with nginx 1.3.8 (or any earlier versions), we always get the
expected request:

    $ nc -l 1234
    POST /t HTTP/1.0
    Host: 127.0.0.1:1234
    Connection: close
    User-Agent: curl/7.24.0 (x86_64-redhat-linux-gnu) libcurl/7.24.0 ...
    Accept: */*
    Content-Length: 11
    Content-Type: application/x-www-form-urlencoded

    hello world

Best regards,
-agentzh



More information about the nginx-devel mailing list