I'm running into "413 Request Entity Too Large" errors when posting files larger than 10MB to our API running on AWS Elastic Beanstalk.
I've done quite a bit of research and believe that I need to up the client_max_body_size for Nginx, however I cannot seem to find any documentation on how to do this using Elastic Beanstalk. My guess is that it needs to be modified using an ebetension file.
Anyone have thoughts on how I can up the limit? 10MB is pretty weak, there has to be a way to up this manually.
There are two methods you can take for this. Unfortunately some work for some EB application types and some work for others.
For some application types, like Java SE, Go, Node.js, and maybe Ruby (it's not documented for Ruby, but all the other Nginx platforms seem to support this), Elasticbeanstalk has a built-in understanding of how to configure Nginx.
To extend Elastic Beanstalk's default nginx configuration, add .conf configuration files to a folder named
.ebextensions/nginx/conf.d/
in your application source bundle. Elastic Beanstalk's nginx configuration includes .conf files in this folder automatically.~/workspace/my-app/ |-- .ebextensions | `-- nginx | `-- conf.d | `-- myconf.conf `-- web.jar
To increase the maximum upload size specifically, then create a file at .ebextensions/nginx/conf.d/proxy.conf
setting the max body size to whatever size you would prefer:
client_max_body_size 50M;
After much research and hours of working with the wonderful AWS support team, I created a config file inside of .ebextensions
to supplement the nginx config. This change allowed for a larger post body size.
Inside of the .ebextensions
directory, I created a file called 01_files.config
with the following contents:
files:
"/etc/nginx/conf.d/proxy.conf" :
mode: "000755"
owner: root
group: root
content: |
client_max_body_size 20M;
This generates a proxy.conf file inside of the /etc/nginx/conf.d directory. The proxy.conf file simply contains the one liner client_max_body_size 20M;
which does the trick.
Note that for some platforms, this file will be created during the deploy, but then removed in a later deployment phase.
You can specify other directives which are outlined in Nginx documentation.
http://wiki.nginx.org/Configuration
Hope this helps others!