Deploy a Simple web application in EC2 using NGINX and certify using Certbot

Deploy a Simple web application in EC2 using NGINX and certify using Certbot

Setup a barebone Ubuntu Server in AWS

Requirements:

  1. Must use a imported ssh key (Use ed25519 key)(done)

  2. should have a elastic IP attached (done)

  3. Must allow ssh key pair

Setup a Webserver

Domain to use: custom domain name(if you have)

Must have SSL/TLS enabled (Use certbot for this) Certbot

https://certbot.eff.org/favicon.ico

Must use NGINX as a webserver (done)

References:

How To Generate ed25519 SSH Key

https://www.unixtutorial.org/favicon.ico


  1. Generating ssh key in ubuntu server

  2. Importing ssh key

  3. Deleting the Existing ssh key and updating with the self generated key pair (imported) using VIM editor.ssh/authorized_keys file on the ubuntu instance.

passphrase: mercantilesshpassphrase

  1. Adding additional ssh key pair

  2. Attaching Elastic IP

Elastic IP

An Elastic IP address is a static IPv4 address designed for dynamic cloud computing. An Elastic IP address is allocated to your AWS account, and is yours until you release it. By using an Elastic IP address, you can mask the failure of an instance or software by rapidly remapping the address to another instance in your account. Alternatively, you can specify the Elastic IP address in a DNS record for your domain, so that your domain points to your instance. For more information, see the documentation for your domain registrar, or Set up dynamic DNS on your Amazon Linux instance.

An Elastic IP address is a public IPv4 address, which is reachable from the internet. If your instance does not have a public IPv4 address, you can associate an Elastic IP address with your instance to enable communication with the internet. For example, this allows you to connect to your instance from your local computer.

Elastic IP: 13.200.34.252

  1. Installing Certbot
sudo apt-get install certbot python3-certbot-nginx
  1. Route S3 for personal Domain

Creating a custom record in route 53 for domain

www.lajahmercantile.test.mercantilecloud.com.np

Route53 successfully redirecting to the instance that is hosting webpage using Nginx server

  1. Managing Website Files

Cloning the static website example into the instance working repository

Copying the website files to the /var/www/lajahmercantile@mercantilecloud.com.np directory

  1. Configuring NGINX to serve my static website:

→Modifying the default configuration file /etc/nginx/sites-enable/default for the server to locate our custom website

sudo vim default

→ changing the default root location to the location containing out sample html file.

  1. Restarting Nginx

sudo systemctl restart restart nginx
  1. Verifying the changes

Sample website Sucessfully hosted on nginx server sunning on Ubuntu webserver on custom domain created via Route 53