Welcome! Log In Create A New Profile

Advanced

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

agentzh
January 27, 2013 03:08AM
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

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

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

agentzh 1152 January 27, 2013 03:08AM

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

Maxim Dounin 459 January 28, 2013 06:32AM

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

Valentin V. Bartenev 544 January 28, 2013 12:08PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 210
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready