Categories AWS Cloud Linux

Adding Https to Spring Boot-Angular App

1. Build the app. I have articles writing about how to create a spring boot and angular app all in one.

2. Transfer the jar file to the vps:

scp path/to/myapp.jar username@your_vps_ip:/home/username/

3. Run the app (at best run in the background):

nohup java -jar myapp.jar > myapp.log 2>&1 &

4. Configure Auto-Starting (i will go into details later):

create a file in systemd:

sudo nano /etc/systemd/system/myapp.service

add this content to the file:

[Unit]
Description=My Spring Boot Application
After=syslog.target

[Service]
User=username
ExecStart=/usr/bin/java -jar /home/username/myapp.jar
WorkingDirectory=/path/to
SuccessExitStatus=143
Restart=always
RestartSec=5

# Send output to a specific log file
StandardOutput=append:/var/log/yourapp.log
StandardError=append:/var/log/yourapp.log
[Install]
WantedBy=multi-user.target

reload daemon and start the app, enable it on boot:

sudo systemctl daemon-reload
sudo systemctl start myapp
sudo systemctl enable myapp  # Enable on boot

Note: remember to change User beside other obvious fields. You can see the log of the your service with

journalctl -u myapp.service

append -f to see the log in real time. always is different from on-failure at that it always restarts even you stop it with systemctl stop servicename, on-failure restarts it when the exit code is not 0.

5. Open Firewall (if not opened). You can configure it at aws website or use the reference code below:

sudo ufw allow 80
sudo ufw allow 8080
sudo ufw enable

6. Set up SSL:
There 2 ways to setup ssl, in the spring boot app or with proxy server. To keep SSL management in one place, you should configure it at the proxy server. Here is how you can do it:
Open bncert-tool and follow the the instruction steps:

sudo /opt/bitnami/bncert-tool

Update file /opt/bitnami/apache/conf/extra/httpd-vhosts.conf and restart with the command

More infos at: Adding SSL security to the sub-domains on the AWS Bitnami server

More From Author

Leave a Reply

Your email address will not be published. Required fields are marked *