Deploy a Simple web application in EC2 using NGINX and certify using Certbot
Table of contents
No headings in the article.
Setup a barebone Ubuntu Server in AWS
Requirements:
Must use a imported ssh key (Use ed25519 key)(done)
should have a elastic IP attached (done)
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
Generating ssh key in ubuntu server
Importing ssh key
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
Adding additional ssh key pair
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
- Installing Certbot
sudo apt-get install certbot python3-certbot-nginx
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
- 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
- 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.
-
Restarting Nginx
sudo systemctl restart restart nginx
- Verifying the changes
Sample website Sucessfully hosted on nginx server sunning on Ubuntu webserver on custom domain created via Route 53