AWS storage file size upload error

Hi community, I created simple application to upload files to S3 bucket. I am using the “fileStorageUploadField” component in my view to select and upload the file.

The application is using the AWS file storage.

From local workstation everything works fine.

When application is deployed to Elastic Beanstalk in AWS and I try to upload the same 2.5mb file I get this error in the NGINX.log: “*515 client intended to send too large body:” and an error message on screen.

I already tried putting this configurations in the application.properties file: (worked in local machine but not in Aws)

spring.servlet.multipart.max-file-size=25MB
spring.servlet.multipart.max-request-size=25MB

Jmix version is 2.3.4 IntelliJ version 2024.1

Has anyone faced this issue before or have some ideas I can try?

Thank you.

Luis Cisneros

Hi,

the problem you are facing is related to Elastic Beanstalk instead of Jmix. Beanstalk (as you mentioned) puts a Nginx reverse proxy in-front of the application to e.g. do TLS termination.

The error in the Nginx logs indicates that the proxy already handles this situation and does not even let the request to the Jmix app. Instead it immediately responds with HTTP 515.

You have to adjust the Nginx configuration of the Beanstalk environment. How it works is described here: Modify client_max_body_size in Elastic Beanstalk | AWS re:Post

Here is an example of the config file that you need to put into your project base directory:

cat .platform/.nginx/conf.d/client_max_body_size.conf
client_max_body_size 50M;

With this gradle task you should be able to create a custom zip file containing the directory:


task createDeployZip(type: Zip) {
    dependsOn bootJar // Ensure the bootJar task runs first
    archiveFileName = "app.zip"
    destinationDirectory = layout.buildDirectory.dir("deployment").get().asFile

    // Add the JAR file to the ZIP
    from(layout.buildDirectory.dir("libs")) {
        include "*.jar"
    }

    // Add the .platform directory to the ZIP
    from(".platform") {
        into(".platform")
    }
}

Note, how you bring the Nginx config file to Beanstalk highly depends on how you deploy your application bundle to beanstalk. So I’m just wildly guessing here when it comes to your bundling strategy.

See also:

I hope this helps to get started!

Cheers
Mario

1 Like

Thanks Mario!. I will reply later as soon as I try this, but I feel confident this will fix my problem!

Luis

Hi Mario, thanks for your help! I made my program work and upload files bigger than 2 MB my requirement. I also just want to mention a little change I had to make to the path of the config file:
instead of: ‘.platform/.nginx/conf.d/client_max_body_size.conf’ I had to put: ‘.platform/nginx/conf.d/client_max_body_size.conf’ (without the . before nginx) and it worked.
Regards,

Luis C.