4

I have a Node 10 app running on Elastic Beanstalk, and it throws 413 errors when the request payload is larger than ~1MB.

<html>

<head>
    <title>413 Request Entity Too Large</title>
</head>

<body>
    <center>
        <h1>413 Request Entity Too Large</h1>
    </center>
    <hr>
    <center>nginx/1.16.1</center>
</body>

</html>

The request is not hitting my app at all; it's being rejected by nginx.

I have tried configuring AWS to increase the size of the allowed request body based on this answer, to no avail.

I've tried adding a file at .ebextensions/01_files.config with the contents:

files:
  "/etc/nginx/conf.d/proxy.conf" :
    mode: "000755"
    owner: root
    group: root
    content: |
      client_max_body_size 20M;

That didn't work, so I tried adding the file directly to .ebextensions/nginx/conf.d/proxy.conf with only:

client_max_body_size 20M;

And this also didn't work. Then I SSH'ed into the instance and added the file directly. Upon re-deploy, the entire conf.d directory was deleted and re-written, without this file.

How can I get AWS Elastic Beanstalk with Node.js 10 running on 64bit Amazon Linux 2/5.1.0 to accept nginx configuration?

Tyler
  • 11,272
  • 9
  • 65
  • 105

3 Answers3

10

The nginx setting you are trying to use (/etc/nginx/conf.d/proxy.conf) is for Amazon Linux 1.

Since you are using Amazon Linux 2 you should be using different files for setting nginx. For AL2, the nginx settings should be in .platform/nginx/conf.d/, not in .ebextentions as shown in the docs.

Therefore, you could have the following .platform/nginx/conf.d/myconfig.conf with content:

client_max_body_size 20M;

The above is an example only of the config file. I can't verify if the setting will actually work, but you are definitely using wrong folders to set nginx options.

My recommendation would be to try to make it work manually through ssh as you are attempting now. You may find that you need to overwrite entire nginx setting if nothing works by providing your own .platform/nginx/nginx.conf file.

Dharman
  • 30,962
  • 25
  • 85
  • 135
Marcin
  • 215,873
  • 14
  • 235
  • 294
  • Forced to move to AL2, default client_max_body_size changed, .ebextensions not working as in docs. Bloody AWS. Thanks! – Pawel Sep 28 '21 at 01:11
2

adding the client_max_body_size 20M; in the folder .platform/nginx/conf.d/proxy.conf fixed it for me. Please make sure to check whether you are using Amazon Linux 2

0

Please refer to the folder structure mentiond in the above answer by Gibson. Documentation - here

App_base_folder/.platform/nginx/conf.d/custom_configuration.conf

Interestingly, in my case i tried the above structure and multiple other structures as well. but as i was using EB CLI to deploy code, it was only accepting the committed codes only. Since after making the folder structure changes, i was not committing the changes it was not reflecting in my EC2 instance configuration file. The moment i committed to git and deployed, it worked.

This should have been a comment, but just posted as a answer as i can't comment.