Low Orbit Flux Logo 2 D

Nginx Buffered to a Temporary File

Sometimes you might see an error like the following in your logs when trying to upload a large file using NGINX:

a client request body is buffered to a temporary file /var/lib/nginx/body/0000000001

There is an in-memory buffer which is reserved for uploads. When you see the above warning it means that the file being uploaded is larger than this buffer. If the buffer isn’t large enough to hold the file it will be written to a temporary file on disk.

The size buffer can be controlled with the following variable:


If your uploads tend to be small then it could be a waste to reserve this much RAM for your buffer. If you have a large upload this performance gain likely doesn’t mean that much. It probably doesn’t matter if you spend a few more seconds. If you have plenty of RAM it may be completely OK to assign a large value to this variable.

No memory should be used unless an upload is in progress. Memory should be freed after uploading is complete. If there is an upload in progress you will want to consider the size of the file being uploaded times the number of uploads that are occurring at the same time.

You might want to set this value by editing the configuration like this:

vi /etc/nginx/conf.d/default.conf

client_body_buffer_size 10M;

Restart NGINX like this so that it will take affect:

service nginx restart