Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to extend nginx config in elastic beanstalk (Amazon Linux 2)

I followed the advice here to configure the nginx reverse proxy to allow files larger than the default 1mb. So, my code in /.platform/nginx/conf.d/prod.conf looks like this:

http {
  client_max_body_size 30M;
}

However, this seems to have no effect, and nginx still registers an error when I try to upload a file larger than 1mb.

I also tried doing this without the http and braces, as detailed in the accepted answer to this question, like this:

client_max_body_size 30M;

This also had no effect.

I thought it might be necessary to restart nginx after applying the configuration, so I added a file in the .ebextensions directory called 01nginx.config, which looks like this:

commands:
  01_reload_nginx: 
    command: "sudo service nginx reload"

This also had no effect.

I have seen this question and the above-referenced question, as well as this one. However, they all seem either outdated or non-applicable to an Amazon Linux 2 instance, since none of them mention the .platform directory from the above-referenced elastic beanstalk documentation. In any case, none of their answers have worked for me thus far. So, what am I missing?

like image 204
adam tropp Avatar asked Nov 30 '22 07:11

adam tropp


2 Answers

I has a similar issue when moving to Amazon Linux 2.

Simply creating a file at .platform/nginx/conf.d/ called proxy.conf with the content below was enough for me.

client_max_body_size 50M;

If you go digging around the main config for nginx you'll see how this file is included into the middle of the file so there's no need to have it wrapped with http.

This is similar to adam tropp's answer, but it follows the example given by AWS

like image 170
mattchad Avatar answered Dec 31 '22 08:12

mattchad


Below worked for me:

~/my-app/
|-- web.jar
|-- Procfile
|-- readme.md
|-- .ebextensions/
|   |-- options.config        # Option settings
|   `-- cloudwatch.config     # Other .ebextensions sections, for example files and container commands
`-- .platform/
    |-- nginx/                # Proxy configuration
    |   |-- nginx.conf
    |   `-- conf.d/
    |       `-- custom.conf
like image 42
santhanakrishnan Avatar answered Dec 31 '22 06:12

santhanakrishnan