Viewed 3k times
I have an application that can accept file uploads and puts those onto S3. Some files have been failing to upload when going through the
nginx
reverse-proxy.Learn how to configure caching, load balancing, cloud deployments, and other critical NGINX features. Download the Complete NGINX Cookbook. Actually, I would rather suggest that it's max_size limit which forces cache files removal (and this indeed changed in 1.0.1, and may theoretically result in incorrect behaviour on some exotic file systems). Limit_access_buffer_size syntax: *limit_access_buffer_size size;* default: *256k* context: *http, server, location* Specify the output buffer size. If you have a large hash table and want to show all the records, your result page may be truncated to the buffer size.
Now, I have
keepalive_timeout 120;
set in the nginx.conf as well as set on my application's sites-available/ sites-enabled configurations.
Even after restarting
nginx
this issue reoccurs. Relevant error.log message:The thing is, I don't think this is actually a timeout issue. Uploading a file takes around 8 seconds total to upload without going through the proxy. Using the proxy will have the file hang for a minute or two and then errors out.
90% of files uploaded into the application are PDF's, all of them underneath the body size limit.
So, what would you suggest?
AlbertEngelBAlbertEngelB36611 gold badge55 silver badges2020 bronze badges
Browse other questions tagged proxynginxupload or ask your own question.
In our last article, we’ve explained about limiting user file upload size in Apache. In this article, we will explain how to limit user file upload size in Nginx. Restricting file upload size is useful to prevent some types of denial-of-service (DOS) attacks and many other related issues.
By default, Nginx has a limit of 1MB on file uploads. To set file upload size, you can use the
client_max_body_size
directive, which is part of Nginx’s ngx_http_core_module module. This directive can be set in the http, server or location context.It sets the maximum allowed size of the client request body, specified in the “Content-Length” request header field. Here’s an example of increasing the limit to 100MB in
/etc/nginx/nginx.conf
file.Set in http block which affects all server blocks (virtual hosts).
Set in server block, which affects a particular site/app.
Nginx Limit Req
Set in location block, which affects a particular directory (uploads) under a site/app.
Save the file and restart Nginx web server to apply the recent changes using following command.
Once you have saved the changes and restarted the HTTP server, if the size in a request exceeds the configured value of 100MB, the 413 (Request Entity Too Large) error is returned to the client.
Note: You should keep in mind that sometimes browsers may not correctly display this error. And setting a valua (size) to 0 disables checking of client request body size.
You might also like to read these following articles related to Nginx web server administration.
Reference: ngx_http_core_module documentation
Nginx Download Size Limited
That’s all! In this short article, we have explained how to limit user file upload size in Nginx. You can share your thoughts with us via the comment form below.
Nginx Request Limit
Share