Add SSL certificate for Java Spring Boot App hosted using AWS Elastic Beanstalk using Amazon Linux 2 Add SSL certificate for Java Spring Boot App hosted using AWS Elastic Beanstalk using Amazon Linux 2 nginx nginx

Add SSL certificate for Java Spring Boot App hosted using AWS Elastic Beanstalk using Amazon Linux 2


The following worked for me. In the root directory of your project, create the directories and files shown in the image below:enter image description here

In addition to the steps mentioned in the AWS documentation add the follwowing contents to the Procfile created in the aws folder:

web: java -jar demo-0.0.1-SNAPSHOT.jar

And in your pom.xml file, updated <configuration> like shown below:

<configuration>    <tasks>       <property name="buildName" value="${project.build.finalName}.jar"/>        <copy todir="${project.build.directory}/aws-build/" overwrite="false">           <fileset file="${project.build.directory}/${project.build.finalName}.jar"/>           <fileset dir="./aws" />        </copy>        <replace file="${project.build.directory}/aws-build/Procfile" token="@jarname@" value="${buildName}"/>        <zip compress="false" destfile="${project.build.directory}/aws-build/app-to-deploy.jar" basedir="${project.build.directory}/aws-build"/>    </tasks></configuration>

This will make sure that your certificates are bundled in the build and are uploaded whenever you upload the new build. For my particular case, I then upload the app-to-deploy.jar created after running the following command:mvn clean package

Edit: You should add the nginx server restart command at the end of https-instance.config file to restart the server each time a new build is uploaded like this:

container_commands:      01restart_nginx:        command: "service nginx restart"