Part 10 : Connect your domain to your server and add SSL certificate using LetsEncrypt and Certbot

Nicholas | Feb 3, 2023

Introduction

This article is the ninth part of a 10 part series that I posted as a tutorial for the readers. I will go through step-by-step going over how I created a link shortener app from scratch.

In this post, we will finally make our app go live and make accessible through an IP Address.

In order to proceed with this, we will need to have Digital Ocean account with payment billing (You can set it up here).

Edit Nginx blocks

Run the following in the terminal to start editing your blocks

sudo nano /etc/nginx/sites-available/default

scroll till you see server_name and edit the _ to your domain.

server {
  ....
  server_name _; # Change this to your actual domain
  ....
}

Then restart the nginx service by running this

sudo systemctl restart nginx

Set up DNS

Now we need to do our set up on the DNS Section, for me, it will be Digital Ocean, all you need to do is to add an A record, pointing to your server IP Address.




and now your app should be accessible through your domain! for mine, it is http://kecil.nicholasbudiharsa.xyz

Add SSL using LetsEncrypt

You can install certbot by the following commands

sudo snap install core; sudo snap refresh core
sudo apt remove certbot
sudo snap install --classic certbot
sudo ln -s /snap/bin/certbot /usr/bin/certbot

Also you need to specify to Nginx that we will allow https

sudo ufw allow 'Nginx Full'
sudo ufw delete allow 'Nginx HTTP'

Finally, run the following command to obtain the SSL Certificate

sudo certbot --nginx -d kecil.nicholasbudiharsa.xyz

Conclusion

As we finish this part, your app is now finally complete! 😊 Thankyou for your interest and following the tutorial.