I have a Node.Js application deployed to Amazon Elastic Beanstalk. When uploading a file, I get the following error:
2019/03/04 17:00:42 [error] 4325#0: *722 client intended to send too large body: 30877841 bytes,
client: my ip,
server: ,
request: "POST /api/files/upload HTTP/1.1",
host: "mydomain.com",
referrer: "mydomain.com/..."
Therefore, I need to add client_max_body_size XXM
to nginx.conf
.
Issues
(1) But as I am using Amazon Elastic Beanstalk, I don't know how to do this, without connecting to every single EC2 instance and updating the file manually.
(2) I also want to increase the max size only for one url.
Best Answer
You can customize the software on a Linux Elastic Beanstalk instance using environment configuration files. For your specific case, in your local application home folder, you should have a .ebextensions directory. In that folder create a new file, let's call it "nginx.config", and place the following into that file:
This instructs Elastic Beanstalk to create a file in /etc/nginx/conf.d/ called 00_client_max_body_size.conf, and to place a single line in this file containing:
Bundle up your application and upload a new version to Elastic Beanstalk. Once you have done this, you will notice the following on your Linux instance:
This will get included by the main
nginx.conf
file that is present on all nodejs elastic beanstalk environments, as this file has a line at the end of its http block as follows: