disable request body buffering for file upload

garyc nginx-forum at forum.nginx.org
Thu Jul 20 10:36:21 UTC 2017


Hi Maxim,

> With "fastcgi_request_buffering off;" nginx will send the request 
> body to the FastCGI application immediately, without trying to 
> buffer it anywhere.

I have been monitoring the disk space while uploading a test file of 1.1 GB
in size and have confirmed that with the fastcgi_request_buffering directive
set to 'on' the disk space reduces by approximately 2.2 GB. 

With the fastcgi_request_buffering directive set to 'off' the disk space
reduces by approximately 1.1GB so it does look like the
fastcgi_request_buffering directive is doing what it should however nginx
still appears to cache the entire request body before it is proxied to
fastcgi.

> It is up to your FastCGI application to handle this though, 
> and PHP as well as PHP-FPM may impose additional limitations 
> and/or require additional configuration for this to work.

I am still looking into PHP & php5-fpm configuration parameters in case this
having an effect but it all feels like this cache is happening before the
proxy.

>From what i have researched so far it looks like nginx may always initially
cache the entire request body in some form before the request is proxied.

Another approach we could take would be to add a disk space check api to our
web app so we can confirm we have sufficient space before the upload POST
call is made.

I appreciate that running a web server in a low disk space environment is
not a common scenario however, in your opinion, should it be possible to get
details of the upload POST request to a script before the entire request
body is written to disk by nginx?

Many thanks
Gary

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,275567,275584#msg-275584



More information about the nginx mailing list