The purpose of this task is to:
-
Set up two instances in a private network in AWS and deploy an Ngix webserver on both.
-
Create an ALB to route requests to these instances and ensure they display their hostname or IP adress.
The first step in this task is to ensure that an AWS account has been created. log in to account and choose a preferred region.
search for VPC in the services section.
choose the VPC and others option , so that it automatically creates the subnets, route tables for you.
Click on nat gateway, so that it creates one nat gateway to give internet access to your private instances.
Two subnets each are created for private and public. Preview the subnets and route-tables and click on create VPC.
You would need to create two private instances and one bastion host.
click on launch instance.
Create a name for you instance.
Choose your preferred linux distro. For the purpose of this course, we would use Ubuntu.
Choose a key pair
Click on edit network configurations.
-
Choose the newly created VPC as the option for your instance to be placed in.
-
Place it in one of the private subnets.
-
Disable the automatic creation of a public IP adress
-
Create a security group and click launch instance. Repeat same for the second instance.
A bastion host is a server with which you can access your private instances.
-
Create a name for your bastion host.
-
select a key pair
-
place the instance in the newly created VPC and in the public subnet this time around. Enable public IP and choose existing security group.
-
click on launch instance.
-
Now ssh into your bastion host with your key pair.
-
chmod 400 the selected key pair and ssh with the ip into your bastion host
-
The bastion host would now be used to log-in to your private instances.
-
copy key pair into your bastion host chmod 400 the copied key and use it to ssh into instance.
-
sudo apt update
-
sudo apt update; sudo apt install nginx -y; sudo su to log into the root user and install ngix server.
-
Use the command echo "
" > /var/www/html/index.nginx-debian.htmlecho to displa our servername -
Use the cat to confirm that it was successful
- cat /var/www/html/index.nginx-debian.html do the same for second instance.
choose your target group name.