I have a Spring Boot application built on Beanstalk (Amazon Linux 2), I need to increase the client_max_body_size because some form data I'm posting contains images and I'm getting the 413: Request Too Large
Nginx error.
I followed AWS's documentation on how to change this property.
My project structure looks like this now:
And the content of the file is:
client_max_body_size 50M;
After deploying I keep getting the same error (with images > 1MB total).
No file has been created in conf.d:
Is this because how my buildSpec
packages my application?
version: 0.2
phases:
install:
runtime-versions:
java: corretto17
pre_build:
commands:
- echo Nothing to do in the pre_build phase...
build:
commands:
- echo Build started on `date`
- mvn package -Dmaven.test.skip
post_build:
commands:
- echo Build completed on `date`
artifacts:
files:
- .platform/nginx/conf.d/proxy.conf
- target/myApp-0.0.1-SNAPSHOT.jar
- appspec.yml
discard-paths: yes
I also tried adding the configuration file into the artifacts.files
section of my buildspec.yml
.
I also tried to create the file its content from the files
section on the buildspec.
I feel like I tried everything, is there anything I may be missing?
For now, my workaround
I manually edited the file:
cd /etc/nginx/
sudo nano nginx.conf
and restarted. That worked, but I want to avoid this manual configuration so it's configured from the application source, as a good practice.
The problem was on my buildspec.
discard-paths: yes
was putting all the files on the root path of the bundle. I needed this so I the jar was on the root, but it was putting the proxy.conf
in the root as well.
Setting that property to no (or removing it) made it work, but I needed a way to change the jar from /target/ to the root so I did it with a post-build command:
version: 0.2
phases:
install:
runtime-versions:
java: corretto17
pre_build:
commands:
- echo Nothing to do in the pre_build phase...
build:
commands:
- echo Build started on `date`
- mvn package -Dmaven.test.skip
post_build:
commands:
- mv target/myApp-0.0.1-SNAPSHOT.jar myApp-0.0.1-SNAPSHOT.jar <------ HERE
- echo Build completed on `date`
artifacts:
files:
- .platform/nginx/conf.d/proxy.conf
- myApp-0.0.1-SNAPSHOT.jar
- appspec.yml