Alex Hermstad
Alex Hermstad

Reputation: 330

AWS Elastic Beanstalk - Configuring my nginx settings to increase timeout for Java Spring maven app

So I am using AWS Elastic Beanstalk to host my Java Spring app, and there are certain requests which take more than 60 seconds to complete. I wanted to raise the timeout cap so these could complete, so I began to follow this tutorial.

I succeeded in changing the Load Balancer timeout in the ELB console, but I am having trouble changing settings for the nginx proxy. The tutorial suggests to create a file called .ebextensions/nginx-timeout.config where .ebextensions is in the "root of my project." The tutorial is assuming that we are using Beanstalk with Docker, which I am not, so I found this link which suggests to fill the contents of nginx-timeout.config with these contents:

files:
    "/tmp/proxy.conf":
        mode: "000644"
        owner: root
        group: root
       content: |
           proxy_send_timeout 1200;
           proxy_read_timeout 1200;
           send_timeout       1200;
container_commands:
    00-add-config:
        command: cat /tmp/proxy.conf >> /var/elasticbeanstalk/staging/nginx/conf.d/elasticbeanstalk/00_application.conf
    01-restart-nginx:
        command: service nginx restart

One of my problems is that I do not know exactly where the root of my application is. I am using Maven with Java Spring Boot, so my structure is as follows:

enter image description here

I am not sure whether I should place .ebextensions in the base directory where my pom.xml file is, or somewhere else. Also the method in which I am deploying this application is using maven to build a jar, and then uploading the jar, I'm not sure if this changes anything.

Any advice on this problem? I'm currently also trying to see how I might ssh into my instance to possibly change the configuration of the nginx server there, but I am not sure if that will be possible.

Upvotes: 4

Views: 3357

Answers (1)

MxR
MxR

Reputation: 606

Possible duplicate of Where to add .ebextensions in a WAR?, though since you are not using war packaging you can use Procfile-based configuration and archive your jar and .ebextensions into additional zip layer. Then your zip file structure should be looking like this:

your_app.zip
|
|_.ebextensions
|   |_ nginx-timeout.config
|
|_ your_app.jar
|_ Procfile

And your Procfile should contain your jar file launching instructions

$ cat Procfile
web: java -jar your_app.jar

Upvotes: 1

Related Questions