Amazon Elastic Beanstalk ebextension - amazon-web-services

I want to config the nginx config with the ebextension at Amazon Elastic Beanstalk,
The content of the conf as below:
files:
"/etc/nginx/conf.d/custom-nginx-proxy.conf" :
mode: "000755"
owner: "root"
group: "root"
content: |
client_max_body_size 60M;
contatiner_commands:
reload_nginx:
command: "sudo service nginx reload"
but always got the error about the content,
nginx: [emerg] unknown directive "files:" in /var/elasticbeanstalk/staging/nginx/conf.d/custom-nginx-proxy.conf:7
I put this file at
ROOT.war
|- ROOT/
|- .ebextensions
|- nginx
|- conf.d
|- custom-nginx-proxy.conf
|- Others content

Your extension should be placed at .ebextensions/01-custom-nginx-proxy.config. Also, the second block should start with container_commands:, not contatiner_commands:, and you don't need sudo as the deployment will already be running as root. If that doesn't help, try using two spaces per indent level. EB extensions are written in YAML, which is very sensitive to whitespace.
If you're still stuck, please post the contents of /var/elasticbeanstalk/staging/nginx/conf.d/custom-nginx-proxy.conf - the file that gets created after your deployment.

Related

Elasticbeanstalk Python environment Nginx conf file

I have an AWS Elasticbeanstalk Python environment and I'd like to change default 1 MB nginx configuration limit for file upload to a bigger value (15 MB).
So I thought to add a config file in .ebextensions:
files:
"/tmp/my.nginx.conf" :
mode: "000755"
owner: root
group: root
content: |
client_max_body_size 15M;
"/tmp/install-nginx-config.sh" :
mode: "000755"
owner: root
group: root
content: |
#!/bin/sh
cp /tmp/my.nginx.conf /etc/nginx/conf.d/elasticbeanstalk/01_max-size.conf
container_commands:
01_runmyshellscript:
command: "sudo /tmp/install-nginx-config.sh"
02_reload_nginx:
command: "sudo service nginx reload"
The idea is to add the new config file in /etc/nginx/conf.d/elasticbeanstalk after the elasticbeanstalk nginx config files are created, so to no to to interfere with the creation of the EB environment, like suggested in many articles on Internet.
But if I deploy the above file in .ebextensions then the environment fails and if I SSH the EC2 I find out that in /etc/nginx/conf.d/elasticbeanstalk there is my 01_max-size.conf but the nginx configuration file created by Elasticbeanstalk isn't there anymore.
This is strange, beacause container_commands should be exetuced after the end of environment creation, so I have no clue of how solve this issue.

AWS Elastic Beanstalk - Spring Boot application deployed as Jar. Need to change Ngnix to allow large files

I tried the option of adding.platform or .ebextensions folder to the zip file to modify the ngnix setting to allow more than 1MB file but it did not work. I deployed my spring boot as a jar in Elastic Beanstalk. Can you please help me? Appreciate it. Thank you.
Update on the structure. I have used the following directory structures:
1)
root of the zip folder
.platform
ngnix
- conf.d
- ngnix.conf
application.jar
the contents of proxy.conf are:
client_max_body_size 100M;
2)root of the zip folder
.ebextensions
ngnix
- myconf.conf
application.jar
The content of the conf file myconf.conf:
files:
"/etc/nginx/conf.d/proxy.conf":
mode: "000755"
owner: root
group: root
content: |
client_max_body_size 100M;
I have referred to the following links:
https://medium.com/innovation-res/how-to-configure-aws-ebs-to-handle-large-files-10411b9cecf0
https://dev.to/rasoolk16/elastic-beanstalk-update-media-upload-size-53go
https://harishkm.in/2020/08/06/uploading-large-files-to-aws-elastic-beanstalk-fails-with-http-413-request-entity-too-large/
Thank you,
Jeelani
Update:
I've tried keeping the config file directly under .ebextensions and used the following formats to try it out.
files:
"/etc/nginx/conf.d/proxy.conf":
mode: "000755"
owner: root
group: root
content: |
client_max_body_size 100M;
Noticed the following error:
The configuration file __MACOSX/.ebextensions/._01_nginx.config in application version showkase-source-20 contains invalid YAML or JSON. YAML exception: Invalid Yaml: org.yaml.snakeyaml.error.YAMLException: java.nio.charset.MalformedInputException: Input length = 1, JSON exception: Invalid JSON: Unexpected character (�) at position 0.. Update the configuration file.
2) client_max_body_size 100M;
Let me go through the links you have provided and see what am I doing wrong. Thank you. Will keep you posted. But with either of these formats, I don't see the file appearing in /var/app/current. I see only the applicaiton.jar and Procfile.
Contents of config file:
files:
"/etc/nginx/conf.d/01_proxy.conf":
mode: "000644"
owner: root
group: root
content: |
client_max_body_size 20M;
You have used two different methods (via .platform/nginx hook and via .ebextensions). They are both valid, but only one should be needed.
While your platform hook seems fine, the .ebextensions is not according to the AWS documentation. It needs to have the file extension .config (not .conf) and the file needs to lie directly in the .ebextensions/ directory (not .ebextensions/nginx).
Some hints on debugging if this doens't fix your problem:
Check the following CloudWatch logs:
/aws/elasticbeanstalk/<yourAppName>/var/log/eb-engine.log
/aws/elasticbeanstalk/<yourAppName>/var/log/eb-hooks.log
/aws/elasticbeanstalk/<yourAppName>/var/log/nginx/error.log
Log into the EC2 instance via the Session Manager (located at the Systems Manager) to check the following:
Do you see all files of your zip in /var/app/current/?
What is the content of /etc/nginx/conf.d?
If this does not help, you can try the method in this SlackOverflow question.
There, you will run a platform hook script that writes the config file manually.
Edit after you have corrected the above errors:
The contents of your config file seems to be correct. But the error message suggests that you have an invalid file encoding or a special character not matching the encoding (e.g., by copy and pasting from a website). You can use file 01_nginx.config to see the encoding. Best you delete the current config file and write it again by hand (without any copy & pasting) to ensure that no special characters sneak in.

Change nginx.conf on Elastic Beanstalk?

So all I'm trying to do is add "client_max_body_size 5000m;" to my nginx.conf file.
I can ssh in and add the line manually, and that will work, but I know there's a way to do that automatically with my files in the .ebextensions folder.
If I use
files:
"/etc/nginx/nginx.conf":
mode: "000644"
owner: root
group: root
content: |
#Elastic Beanstalk Nginx Configuration File...
nothing seems to change.
if I use
files:
/.platform/nginx/conf.d/proxy.conf:
mode: "000644"
owner: root
group: root
content: |
#Elastic Beanstalk Nginx Configuration File...
I can see that the proxy.conf file is where I would expect it to be, but it still has no impact on my nginx settings, even though the AWS documentation and other posts on here would lead me to believe that EB should copy that file into /etc/nginx/conf.d/elasticbeanstalk/
but it does not, and manually specifying anywhere other than .platform doesn't seem to do anything.
I feel like I'm close, but for the life of me I can't figure it out.
You are trying to use (/etc/nginx/conf.d/proxy.conf) which is for Amazon Linux 1 (AL2). It will not work in AL2 as you should be using .platform/nginx/conf.d/, NOT .ebextentions as shown in the docs.
Therefore, you could have the following .platform/nginx/conf.d/myconfig.conf with content:
client_max_body_size 5000M;

unable to increase client_max_body_size

I have been struggling for the past few days now to increase the upload limit on nginx, which is apart my elastic beanstalk instance. From my understanding i need an ebextensions file to set the client_max_body_size. Which I have tried several different ways to configure, like directly overwriting nginx.conf to inserting client_max_body_size in nginx.conf on the live server. None of these methods have worked. I was sure to manually reload the file just after each attempt. As it stands, this is what my config file looks like at the moment(after several iteration):
.ebextensions/01_nginx.config
files:
/etc/nginx/conf.d/proxy.conf:
content: |
client_max_body_size 2G;
If anyone can help me that would be awesome.
You can either extend it or override it.
Elastic Beanstalk provides a default nginx configuration that you can
either extend or override completely with your own configuration
Overriding
~/workspace/my-app/
|-- .ebextensions
| `-- nginx
| `-- conf.d
| `-- myconf.conf
Source
Your Config looks right from your question compared to the example from the docs. Verify location of your nginx conf by sshing into the
$ eb ssh environment-name
$ sudo service nginx configtest
nginx: the configuration file /${LOCATION}/nginx.conf syntax is ok
nginx: configuration file /${LOCATION}/nginx.conf test is successful
Doc Example
"/home/ec2-user/myfile2" :
content: |
# this is my file
# with content
Also try adding the nginx reload to the .ebextensions if you have the right path to your nginx config.
files:
/etc/nginx/conf.d/proxy.conf:
mode: "000644"
owner: root
group: root
content: |
client_max_body_size 2G;
commands:
01_reload_nginx:
command: "sudo service nginx reload"
Source
Helpful blog post that runs thru most of this: "Getting to Know and Love AWS Elastic Beanstalk Configuration Files"(.ebextensions)
This might be helpful as it worked for me. Taking reference form aws ebs docs
To extend the Elastic Beanstalk default nginx configuration, add .conf configuration files to a folder named .platform/nginx/conf.d/ in your application source bundle. The Elastic Beanstalk nginx configuration includes .conf files in this folder automatically.
~/workspace/my-app/
|-- .platform
| `-- nginx
| `-- conf.d
| `-- myconf.conf
`-- other source files
myconf.conf
client_max_body_size 50M;
Note
When you add or edit an nginx .conf configuration file, be sure to encode it as UTF-8.

Increasing client_max_body_size in Nginx conf on AWS Elastic Beanstalk

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.
Supported/recommended in AWS documentation
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
Configuring the Reverse Proxy - Java SE
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;
Create the Nginx config file directly
For some other application types, 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
I have tried all .ebextensions method of adding implementation level configuration and it didn't helped me in the latest Amazon Linux AMI. I have did a lot research and after going through the logs i can find the deployment task runner is checking for a folder called .platform everytime and i thought of add one just like the .ebextensions. Below is the settings i have done in my root folder of my project.
Add the below folder setup in the root level of your project folder.
Folder structure (.platform/nginx/conf.d/proxy.conf)
.platform/
nginx/
conf.d/
proxy.conf
00_myconf.config
Content of File 1 - proxy.conf (Inside .platform/nginx/conf.d/ folder)
client_max_body_size 50M;
Content of File 2 - 00_myconf.config (Inside .platform/ folder)
container_commands:
01_reload_nginx:
command: "service nginx reload"
Care full with the extensions. First file is .conf and second file is .config.
Now redeploy your project to Amazon Elastic Beanstalk and you will see the magic. This configuration will be added to all your EC2 instances, created as part of auto scaling.
Detailed folder structure below.
When using Amazon Linux 2 (regardless of platform)
The accepted answer is correct when you're using an older Elastic Beanstalk environment using Amazon Linux AMI. Newer Elastic Beanstalk environments use the Amazon Linux 2 AMI.
When using Amazon Linux 2 you need to specify the custom Nginx config in the .platform/ directory instead of the .ebextensions/.
This means that you'll need to create the file .platform/nginx/conf.d/proxy.conf with the content client_max_body_size 50M; instead.
The .platform/ directory was also mentioned in another answer, but that still required reloading the Ngix config, with Amazon Linux 2 reloading is no longer needed.
You can find more options about this in the Extending Elastic Beanstalk Linux platforms documentation.
files:
"/etc/nginx/conf.d/proxy.conf" :
mode: "000755"
owner: root
group: root
content: |
client_max_body_size 20M;
Modified the above answer for the sake of security (and the syntax was wrong, see, two 'owner:' entries in the YAML), guys, please don't set 777 permissions on ANYTHING. Unless you enjoy being hacked, and set the owner of Nginx config files to root.
Also see the below answer to make nginx pickup this change after deployment.
EDIT: After you've deployed a build with the instructions in the accepted answer by Nick Parsons, you may need to restart the nginx server to pick up the changes.
To do this, ssh to the instance and do
sudo service nginx reload
To learn more about reloading, see http://nginx.org/en/docs/beginners_guide.html.
In a previous version of Elastic Beanstalk, I was able to add a container_command to accomplish this, but now I am finding, like #cdmckay, that this causes a deployment failure. If you rebuild your environment it will pick up the client_max_body_size settings as well as long as that instruction is in your config file.
The accepted answer didn't work for me since I have a JVM-based app and it seems to do NGINX configuration differently. I would see a proxy.conf file being created during the deploy but then later deleted before the deploy was completed. AWS documentation explains how to configure the proxy:
Create an .ebextensions/nginx/conf.d/proxy.conf file that contains just the line: client_max_body_size 40M;
Super Simple Solution for Amazon Linux 2:
On the same level as .ebextensions and .elasticbeanstalk, create a
directory called .platform
Create a file (full path shown) under this directory called: .platform/nginx/conf.d/client_max_body_size.conf
Add this one line to the client_max_body_size.conf file: client_max_body_size 20M;
Deploy!!
This is based on AWS NGINX "Reverse proxy configuration" Documentation.
(This worked w/ Django 3.1.4 + Python 3.7 running on 64bit Amazon Linux 2/3.2.0)
Following on from the accepted answer, you need may need to reload the nginx config file.
In order to do this add the following command
container_commands:
01_reload_nginx:
command: "service nginx reload"
This would be better practice than ssh'ing into your eb instance and manually doing it with a command.
This combined with the accepted answer solved the same issue for me. (Rails, Puma, NGINX)
The only thing that worked for me was to create a ".config" file inside .ebextensions like this:
.ebextensions/
proxy.config
with only this content in the .config file:
files:
"/etc/nginx/conf.d/proxy.conf":
content: |
client_max_body_size 50M;
no need for subfolders, no need to restart the application server, pay attention that is a ".config" not a ".conf" file inside .ebextensions and the use of proper indentation to avoid errors in the aws console the rest is the same doesn't matter the name of the file,
thanks to :
http://kroltech.com/2014/09/14/quick-tip-increase-upload-size-in-aws-elastic-beanstalk-node-js-env/
The accepted answer did not work for me, so instead I overrode the nginx configuration with my own.
I created a file called nginx.conf under the directory .ebextensions/nginx/
I SSHed into a running instance of my Beanstalk app, and copied the contents of the nginx.conf file, using cat /etc/nginx/nginx.conf and copying from the terminal.
I pasted the contents into the nginx.conf file I previously created in .ebextensions/nginx/, and modified the http directive to include client_max_body_size 50M;. I finally redeployed my app using eb deploy and it worked. You should get the following message during deployment:
INFO: Nginx configuration detected in the '.ebextensions/nginx'
directory. AWS Elastic Beanstalk will no longer manage the Nginx
configuration for this environment.
These are the contents of my .ebextensions/nginx/nginx.conf file:
# Elastic Beanstalk Nginx Configuration File
user nginx;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
worker_processes auto;
worker_rlimit_nofile 33193;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
include conf.d/*.conf;
map $http_upgrade $connection_upgrade {
default "upgrade";
}
server {
listen 80 default_server;
access_log /var/log/nginx/access.log main;
client_header_timeout 60;
client_body_timeout 60;
keepalive_timeout 60;
gzip off;
gzip_comp_level 4;
gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript;
# Include the Elastic Beanstalk generated locations
include conf.d/elasticbeanstalk/*.conf;
}
client_max_body_size 50M;
}
I did not have to restart the nginx service nor the environment.
Note: Make sure your .ebextensions is part of the .zip file created and uploaded to Beanstalk during deployment (it's not ignored in .gitignore or .ebignore if you're using it).
This is the AWS provided solution, and it works (adjust the size to your needs)
files:
"/opt/elasticbeanstalk/hooks/appdeploy/enact/12_add_nginx_configuration.sh":
mode: "000755"
owner: root
group: root
content: |
#!/usr/bin/env bash
/bin/echo "client_max_body_size 50M;" > /etc/nginx/conf.d/proxy.conf
/sbin/service nginx reload
For those who are stumbling on here:
I followed Jijo Cleetus answer but did not work, but definitely pointed to the right direction.
But I am wordering why because if I see nginx.conf file, it does contain include conf.d/*.conf so it should include the proxy file as the answer mentioned.
Also the default server listening on 80 and marked as default_server, has include conf.d/elasticbeanstalk/*.conf
But this answer did solve the issue, in gist, the .conf files directory have to be .platform/nginx/conf.d/elasticbeanstalk instead of .platform/nginx/conf.d/.
So:
.platform/nginx/conf.d/elasticbeanstalk/01-request-body.conf
.platform/nginx/conf.d/elasticbeanstalk/02-timeouts.conf
are some examples
I also confirmed it by logging into the ec2 instance and running nginx -T which prints the running config to verify if my custom configs were included.
Also there I saw, the default application proxy config is named 00_application.conf and nginx includes files in alphabetical order, so named it by prefixing numbers.
Added notes to those who are deploying via CodePipeline:
Make sure to include .platform/**/* in buildspec.yaml -> artifacts section
After 3 long days of trying to figure this one out, I jumped on a call with the amazing AWS support team and they gave me some clues about how to solve it.
First, my project is in JAVA and I use maven and spring boot to run it through Elastic Beanstalk (EBS).
As explained on AWS' documentation, you need to have the custom nginx settings stored in the root level of your project.
To do that I have created a client_max_body_size.conf file and placed it in the following path:
myprojectname/src/main/resources/ebextensions/nginx/conf.d/client_max_body_size.conf
This file contains only the following line:
client_max_body_size 10M;
Configure maven to add this file in the root folder of my project during the build.
This was a bit tricky, I needed to add the following configuration (source) in my POM.xml:
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<id>copy-resources</id>
<!-- here the phase you need -->
<phase>validate</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/target/.ebextensions</outputDirectory>
<resources>
<resource>
<directory>src/main/resources/ebextensions</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
You can now already build your project locally and run the following SSH command to validate it's actually located in the root of your project:
jar tf main-1.0-SNAPSHOT.jar | grep .ebextensions
Now it's the tricky part. When you upload it to EBS, your file should contain only the SNAPSHOT.jar file and the .ebextensions folder. For example, if now you will zip the jar file and the folder and upload it manually, it will work!
Since I am using Jenkins for my deployment, and specifically the AWS EBS Deployment Plugin - you need to change the settings of the files/folder you include in the deployment.
Now for some reason I wasn't able to include the .ebextensions folder so I just excluded everything else except the folder and the .jar file.
This works!
If you are running EC2 and installed nginx yourself, your best solution is to create a new file in
/etc/nginx/conf.d
folder:
sudo nano /etc/nginx/conf.d/proxy.conf
and then add the following line there:
client_max_body_size 20M;
then save and restart nginx:
sudo systemctl restart nginx
For Golang without Docker I followed these instructions from aws doc:
Configuring the Reverse Proxy
If you want to include directives in addition to those in the nginx.conf http block, you can also provide additional configuration files in the .ebextensions/nginx/conf.d/ directory of your source bundle. All files in this directory must have the .conf extension.
http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/go-environment.html#go-complex-apps
I created the file proxy.conf in .ebextensions/nginx/conf.d/ at the root of my project, with simply 1 line inside:
client_max_body_size 20M;
If it still doesn't work, make sure .ebextensions folder and sub-folders are included in your deployment zip. No need to restart Nginx manually.
I was struggling with the same issue but wasn't able the resolve it, finally its working.
here is my congfig file,
files:
"/etc/nginx/conf.d/01_proxy.conf":
mode: "000755"
owner: root
group: root
content: |
client_max_body_size 50M;
client_body_buffer_size 16k;
container_commands:
01_reload_nginx:
command: "sudo service nginx reload"
The issue was,
I was using a python script for code pipeline which does not include
the .ebextensions folder while creating the build.
Here are my few cents,
make sure that your .ebextensions folder is included in your build's zip folder which is located in s3bucket of your aws account
make sure it is not in the .gitignore file
if you are using a script to generate the build make sure it
includes .ebextensions
Late to the party but for .NET Core the following solution works:
Make a file in /.platform/nginx/conf.d/proxy.conf with the content:
client_max_body_size 100M;
Make sure in properties on Visual Studio that Copy to output directory is set to "Always" for this file and that the build action is "content."
Any of the above options may or may not work,
...but if you're line endings of the proxy.config file are not correct then AWS will just error when trying to deploy your code to the instance.
We created the .platform/nginx/conf.d/proxy.config file, but because we are developing and building the code on a windows platform, the line endings were set to Windows (CRLF).
But our AWS instances were all Linux, which expect the Unix (LF) ending.
So when Linux tried to read the file it just failed...it didn't even give us a decent error in the events or logs, it just said failed.
Maybe a last thing to check if nothing else works :)
Alternatively you could change the proxy server to Apache.
To do this, go to the Configuration and Edit the Software Configuration. The first option here is “Proxy server”, select “apache”.
For Java Platform
To create the NGINX config proxy file you should just add
.ebextension/nginx/conf.d/proxy.conf file
with the content client_max_body_size 20M; in it.
"proxy.conf" will be deployed to "/etc/nginx/conf.d/proxy.conf" and automatically included by the NGINX config.
In addition to client_max_body_size, I had to add client_body_buffer_size. Here is the dot config file that worked, for a 2 MB attachment:
files: "/etc/nginx/conf.d/proxy.conf" :
mode: "000755"
owner: root
group: root
content: |
proxy_buffering on;
proxy_buffer_size 128k;
proxy_buffers 8 256k;
client_body_buffer_size 2M;
proxy_busy_buffers_size 256k;
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
client_max_body_size 3M;
Creating a file in the .ebextensions directly is the only method I found that has worked for me. Create a new file called 01_files.config and paste in the following:
files:
"/etc/nginx/conf.d/proxy.conf" :
mode: "000755"
owner: root
group: root
content: |
client_max_body_size 20M;
This will create a config file for you on deploy that sets the client_max_body_size to 20MB (change the # to suit your needs).
Had a lot of trouble with this even trying all of the solutions here. I got the error message: unknown directive "client_max_body_size" in the eb-engine.log
This page help me solve the issue: https://forums.aws.amazon.com/thread.jspa?threadID=334637
Visual Studio had create the file in some encoding that caused the problem and I could save/convert the file to ANSI encoding and it worked as expected.
Hope this can help someone stuck with the same problem.
For Spring Boot / Java / Fat-Jar deployments on AWS Beanstalk:
The previous answer using .platform is required in AWS Linux 2, but, unlike .ebextensions, you can't include the .platform directory inside the fat jar - it must be outside the Java jar.
This useful post describes how to set up Maven to create an AWS fat jar for deployment.
https://www.coderdreams.com/deploying-spring-boot-app-to-aws-beanstalk-with-nginx-customization/
Note: there's no need to create a script to restart the nginx server as in the previous answer.
Used .platform instead of .ebextensions and all are okay
and here is the content of myconf.conf
client_max_body_size 400M;
Create Auto configuration for Nginx in EBS
Since the EBS is auto scaling we can’t increase the Size and request time out manually so we have to add conf file in you source code which automatically include in the nginx configuration in EBS
https://akshaykrisonz.medium.com/fix-413-request-entity-too-large-nginx-error-on-aws-elastic-beanstalk-via-ebs-configuration-7533ad28ac06