0

I'm writing to you in hope to get a help on a problem I'm facing, so basically I created a spring boot rest API for my app and I used AWS Elasticbeanstalk to deploy, now when I try to upload a file to my S3 bucket using the rest API, I'm facing an error saying that the body of my request is too large, even for some image files not larger than 1MB, that has something to do with nginx conf. So please how can I solve that issues.

Here's the error part of the logs of the app: 2023/03/21 05:12:26 [error] 2736#2736: *56 client intended to send too large body: 3527163 bytes, client: ..., server: , request: "POST /mobile/create_post HTTP/1.1", host: "..."

.platform/nginx/conf.d/proxy.conf content: client_max_body_size 50M; I tried this solution by adding .conf file to my projects root folder before building a jar file with "mvn clean install" and then deploy to elastic beanstalk. but it didn't work

2nd Solution I tried, it didn't work .ebextensions/nginx/nginx.conf content: client_max_body_size 50M;

1 Answers1

0

The nginx config file you are trying to set in .ebextensions is only possible in Amazon Linux 1 (AL1).

This question is actually already answered. and I will copy some bits over from that answer:

For AL2, the nginx config files should be provided (aws docs) using:

  • .platform/nginx/conf.d/

or if you want to overwrite main nginx config file, use

  • .platform/nginx/nginx.conf

If it does not work, you can inspect nginx logs in /var/log or nginx config folder to check if the file is correctly placed in nginx config folder.

An example for such a nginx config file for specifing max_body_size but for a PHP laravel application is found here (which is similar to what you are trying to accomplish):

https://github.com/rennokki/laravel-aws-eb/blob/master/.platform/nginx/conf.d/elasticbeanstalk/laravel.conf

Max Visser
  • 577
  • 4
  • 10