4

I'm trying to increase the size of uploadable files to the server. However it seems there's a cap that prevents anything over 1MB of being uploaded.

I've read a lot of answers and none have worked for me.

I've done everything in this question Stackoverflow question

I did everything here as well. AWS resource

Here's what I have as the full error

2021/01/15 05:08:35 [error] 24140#0: *150 client intended to send too large body: 2695262 bytes, client: [ip-address-removed], server: , request: "PATCH /user HTTP/1.1", host: "host.domain.com", referrer: "host.domain.com"

I've made a file in this directory (which is at the root of my source code)

.ebextensions/nginx/conf.d/myconf.conf

In it I have

client_max_body_size 40M;

I know that EB is acknowledging it because if there's an error it won't deploy it. Other than that I have no idea what to do

Does anybody know what might be the issue here?

Edit: backend is nodejs v12

Edit: Also tried this inside of a .conf file in .ebextensions

files:
    "/etc/nginx/conf.d/myconf.conf":
        mode: "000755"
        owner: root
        group: root
        content: |
          client_max_body_size 20M;
Trevor Wood
  • 2,347
  • 5
  • 31
  • 56

1 Answers1

10

Update:

Beanstalk on Amazon Linux 2 AMI has a little different path for NGINX config extensions:

.platform/nginx/conf.d

There you can place NGINX config extension files with *.conf extension, for example:

.platform/nginx/conf.d/upload_size.conf:

client_max_body_size 20M;

Documentation for this is here.

Original answer:

Nginx normally does not read config from where is serves the content. By default all config nginx read is /etc/nginx/nginx.conf and this file includes other files from /etc/nginx/conf.d/ with *.conf extension.

You need to place client_max_body_size 40M; there.

anemyte
  • 17,618
  • 1
  • 24
  • 45
  • thanks for the help but this isn't working for me either. It looks like EB sets default files from ebextensions. says it here (https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/java-se-nginx.html) so i added this ```files: "/etc/nginx/conf.d/myconf.conf": mode: "000755" owner: root group: root content: | client_max_body_size 20M;``` and it's still not working – Trevor Wood Jan 15 '21 at 06:50
  • 1
    @TrevorWood Oh I missed it is beanstalk. Try the following: from your source root create a file `.platform/nginx/conf.d/upload_size.conf` and put there a single line `client_max_body_size 20M;`. It's from https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/platforms-linux-extend.html – anemyte Jan 15 '21 at 07:06
  • thanks so much man. you're a lifesaver. Been stuck on this all day. You might add your answer to the link I posted in my question. Seems to get a lot of hits – Trevor Wood Jan 15 '21 at 07:22
  • 1
    @TrevorWood glad to help and thanks for the feedback. I've updated the answer. – anemyte Jan 15 '21 at 07:35
  • 2
    You are a saviour. AWS Beanstalk would have killed me otherwise – Nilan Saha Apr 19 '22 at 21:26
  • This was very helpful thanks !!!, changes from Amazon Linux 1 to 2 is not seamless – Rafael Larios May 18 '22 at 21:22