java maven deployed in elastic bean stalk nginx modification not working

0

I built a java app using the vaadin-flow framework with maven and java 17.

I already deployed the app in elastic bean stalk, connected it to a domain and its working properly.

What i want to do but can't figure out how to do it is to change the max upload size for nginx, it is my understanding that i need to create a .platform directory and put the relevant .conf there and so i did. What i have is my-app/.platform/nginx/conf.d/client_max_body_size.conf => client_max_body_size 40M;

but i still don't see the change taking place when i deploy the app, i am suspecting it has something to do with the way i am packaging my application, but i can't find any maven example that does this same thing or where exactly to put this conf file...

Can someone direct me to a maven example project where its deployed into elastic bean stalk behind an nginx (which is the default) and modifies the client_max_body_size similarly to what i want or does any other modification to nginx.

  • I do something similar but I use Apache instead nginx, but I do something very similar to overwrite the existing apache config file 00_application.conf ; I put the replacement file in the .platform/httpd/conf.d/elasticbeanstalk direct which starts at the root of the artifact ( .war or .zip file ) . It took a while to get it exactly right, I ended up configuring the beanstalk instances so that I could get to them using the SSM agent so I was able to ssh onto them and troubleshoot and check the results.

asked a year ago607 views
2 Answers
0
Accepted Answer

I manually created the zip folder to see if at least it will work this way. So i created a folder (my-app) with a .platform, app.jar & the Procfile, i zipped the content of the folder as per the documentation.

.platform => .platform/nginx/conf.d/client_max_body_size.conf app.jar => application Procfile => web: java -jar app.jar

I made sure the Procfile has no new line at the end, has the necessary file permission 644 cause i read somewhere that this could be an issue.

I connected to the ec2 instance and i could see the Procfile and app.jar file put in the environment correctly and i was also able to run the Procfile command manually.

But nevertheless i was getting this error message from the elastic beanstalk log files

[ERROR] An error occurred during execution of command [self-startup] - [CheckProcfileForJavaApplication]. Stop running the command. Error: there is no Procfile and no .jar file at root level of your source bundle

Now today morning the most weird thing happened, i logged in to the environment to continue from where i left of, i noticed the Procfile and the .jar file were gone, also the instance was updated from t4g.micro to t4g.large... anw i did the same thing uploading the same zip, and this time it worked... :) i don't know what is going on but this is really weird.

Anw i verified that the nginx configuration is correctly put under the /etc/nginx/conf.d directory and indeed the configuration took effect.

I am still left to wonder what i was doing wrong yesterday since this morning i did exactly the same thing... maybe i was too tired

So this can be one workaround for the people trying to deploy their app using a jar file, the optimal solution would be to package the app in such a way automatically but this has to do more with maven and the pom file rather than elastic beanstalk, still it would be good if aws could provided an example project.

answered a year ago
  • I haven't seen any ProcFile in my project structure, is it required for this process? if yes, how do I create it?

0

Hello, I understand that you want to change the max upload size for nginx reverse proxy. Below are the steps to achieve the same :

  1. To extend the Elastic Beanstalk default NGINX configuration, add the .conf configuration file client_max_body_size.conf that includes the following:

client_max_body_size 50M; Note: In the preceding example, the value of the client_max_body_size is updated to 50M. Substitute any value in place of 50 as per your requirements.

  1. Copy the .conf configuration file client_max_body_size.conf 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. Make sure to create this path if it doesn't exist in your source bundle. The following example shows the structure of the .platform directory and .conf file in the application zip file: https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/platforms-linux-extend.html#:~:text=Platform%20script%20tools-,Application%20example%20with%20extensions,-The%20following%20example

Here instead of custom.conf you would put your client_max_body_size.conf file.

The file client_max_body_size.conf has a path like this: my-app/.platform/nginx/conf.d/client_max_body_size.conf.

This example link also shows the project structure consisting of JAR files, Procfiles and your nginx configuration file.

  1. Deploy your code and the new .platform/ directory together as a new application version in your Elastic Beanstalk environment.

  2. After the deployment is completed, log in to the instance running on the Elastic Beanstalk environment. After logging in, check that the settings to the NGINX server are applied. To do this, use the following command:

$ sudo nginx -T | egrep -i "client_max_body_size"

The output of the command :

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful client_max_body_size 50M;

If you have any further query regarding the behaviour of your Beanstalk environment I would suggest you to open a case with AWS Support and share your environment ID there so that they can assist you further.

AWS
answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions