Recently i was working in a nodejs application which uploads images and video files to AWS S3 and our deployment environment is Elastic Beanstalk.
With the default Nginx configuration i came across following error when i try to upload large files.
------------------------------------- /var/log/nginx/error.log ------------------------------------- 2017/08/17 08:12:16 [error] 20884#0: *526 client intended to send too large body: 41324010 bytes, client: 10.0.0.10, server: , request: "POST /filelink/upload HTTP/1.1", host: "fileuploader***.elasticbeanstalk.com" -------------------------------------
As clearly mentioned in the log Nginx doesn't allow requests with large body to pass through it. Default max value is ~2MB.
Elastic beanstalk allows this kind of configurations to be manipulated via, .ebextensions. What we need to do is to create a folder as .ebextensions in your root directory of the node project and add a SOME_NAME.config file to it with the following Nginx configuration. Here we are changing the property, client_max_body_size to 50M which increases the pass through file size.
files: /etc/nginx/conf.d/proxy.conf: content: | client_max_body_size 50M;
Here is a sample nginx configuration from official documentation.
Let me know your thoughts.