1

I'm running into status code 413 Request Entity Too Large. I'm running an Amazon Linux 2 AMI instance on AWS's Elastic Beanstalk, which is running an express server with a post route that uploads files to an S3 Bucket and then both adds some data to a table and produces a kafka message. Everything is working properly with files below 1MB size.

I understand nginx's default max-size value is 1MB and that I must change it.

I tried every answer in this thread Increasing client_max_body_size in Nginx conf on AWS Elastic Beanstalk but despite getting the client_max_body_size 10M; inside the nginx.conf file, and restarting nginx everytime I changed a configuration, using nginx -t to see if anything was wrong with the syntax, resulting in everything being ok, and finally proving via this command that the client_max_body_size 10M; line was in fact there, when it accused of there being a duplicate of it inside the file, all of these configs seemed to be completely ignored by my micro-service whenever I try to post a file greater than 1MB.

enter image description here i added client_max_body_size 10M; manually to show that, when testing, nginx tells me it's duplicate, proving it was already included in the nginx.conf file

I also tried to put my conf files inside a .platform/conf.d/ structure, which did make the client_max_body_size 10M; go inside the nginx.conf file, but still it made no difference for my request.

I've also tried reload and restarting the nginx service, both to no avail.

I don't have much ideas on where to proceed from here. Any tips?

1 Answers1

1

The link you are giving is for Amazon Linux 1 (AL1). These days all EB platform are based on AL2, and nginx is set differently. Namely, you should create .platform/nginx/conf.d/myconfig.conf file in the root of your application, with the content of:

client_max_body_size 10M;
Marcin
  • 215,873
  • 14
  • 235
  • 294
  • I have also tried this .platform way, which if I'm not mistaken is also approached in one of the answers of the thread I sent. As I said, the nginx.conf file ends up adding the *client_max_body_size 10M* to itself, via the ".platform..." method, but it doesn't take it into account at all when I'm making my requests, the 413 still shows – Matheus Ciappina Pereira Dec 22 '21 at 11:38
  • @MatheusCiappinaPereira If its in there, then that's it. If it does not work, then you may probably did some other changes somewhere. There is nothing else to do in-terms of `client_max_body_size` and nginx. – Marcin Dec 23 '21 at 03:31
  • 1
    I found out what the problem was! Or rather, my boss did. We were using a gateway which also had a nginx configuration, which was still set to the default 1MB. It was only a matter of doing the ".platform" syntax to the gateway as well :). I'm still quite new to the grand scheme of things, so I often forget the full environment I'm working on – Matheus Ciappina Pereira Dec 28 '21 at 14:23