# Problem with request body and client\_body\_in\_single\_buffer

**URL:** <https://www.ruby-forum.com/t/problem-with-request-body-and-client-body-in-single-buffer/208951>\
**Category:** NGINX\
**Created:** [July 1, 2011, 1:48am UTC](https://www.ruby-forum.com/t/problem-with-request-body-and-client-body-in-single-buffer/208951 "2011-07-01T01:48:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [July 1, 2011, 1:48am UTC](https://www.ruby-forum.com/t/problem-with-request-body-and-client-body-in-single-buffer/208951/1 "2011-07-01T01:48:55Z")

</div>

Hi,

I just had a hard time tracking down the following issue:

I have an apache with mod\_perl running behind nginx 0.8.54. In my  
mod\_perl  
application decoding large file uploads in multipart/form-data failed.  
It  
seems that the beginning of the request body was repeated (resulting in  
one small truncated file and one large corrupt file with no ending  
boundary). After deep-debugging my application I disabled nginx and the  
upload worked again. So I inspected the nginx settings and commenting  
out  
the following line makes my problem go away:

client\_body\_in\_single\_buffer on;

Could it be that nginx somehow doubles the beginning of the request body  
if it detects that the client body does not fit in a buffer?

The nginx config also contains the following settings (I left away  
path/file configs and other things that are unlikely to provoke this  
behaviour):

proxy\_redirect off;  
proxy\_set\_header Host $host;  
proxy\_buffering on;  
proxy\_buffer\_size 4k;  
proxy\_buffers 16 4k;  
proxy\_busy\_buffers\_size 8k;

default\_type application/octet-stream;  
access\_log off;  
client\_body\_in\_single\_buffer on;  
client\_header\_buffer\_size 4k;#  
client\_max\_body\_size 10m;  
keepalive\_timeout 10;  
large\_client\_header\_buffers 4 8k;  
server\_tokens off;  
server\_names\_hash\_bucket\_size 128; # this seems to be required for  
some  
vhosts

Hendrik

---

<div class="post-metadata">

**Author:** ![Hendrik\_Schumacher](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/b782af/32.png) [@Hendrik\_Schumacher](https://www.ruby-forum.com/u/Hendrik_Schumacher)\
**Post date:** [July 4, 2011, 7:16pm UTC](https://www.ruby-forum.com/t/problem-with-request-body-and-client-body-in-single-buffer/208951/2 "2011-07-04T19:16:59Z")

</div>

Hello!

On Fri, Jul 01, 2011 at 01:48:11AM +0200, Hendrik Schumacher wrote:

> client\_body\_in\_single\_buffer on;
> 
> Could it be that nginx somehow doubles the beginning of the request body  
> if it detects that the client body does not fit in a buffer?

Yes, thank you for report. Attached patch (for 1.0.4, but will  
apply to 0.8.54 as well) fixes this problem.

Maxim D.
