Content

                                                  Content How to create an AWS free Account? Lab 1: To launch amazon Linux EC2 instance Lab 2: To Connect to the instance from Linux client Operating System Lab 3:To Launch amazon windows instance Lab 4: Installing apache in EC2 instance Lab 5: Installing Nginx in EC2 instance Lab 6: Changing Host Name Lab 7: Creating a user and making as a sudoer Lab 8:Assigning an Elastic ip Lab 9:Creating ebs,attach and detach the volumn to the instance Lab 10:Creating an S3 Bucket and creating cross replication in another region Lab 11:Load Balancer Lab 12:Two instances with Application Load Balancer Lab 13:Launching two instances with load Balancer Lab:14 Creating Own VPC  Lab 15: Two instances which classic load Balance with own VPC Lab 16:Two instances with Application load Balancer with own VPC Lab 17: Relational Data B...

Lab 13:Launching two instances with load Balancer

                                          Launching two instances with load Balancer


Launching two instances with load balancer

There are two users in instance

1.Normal user

2.Admin user

Admin will connect  to server through bastion port number 22

Whereas end user will connect through through load balancer port number 80

The flow will be:

 

First create security group for bastion 2 web servers ,and load balancer

Admin will connect to web server through bastion with ssh support

End user will connect with http support

Create security group for bastion now

Go to ec2 dashboard select security group

Select the region in which region you want to create instances

 

Click on security group

 

Give name for security group and add inbound rules here admin will connect through bastion so inbound rules port ssh-22-anywhere and click on create

 

Now create load balancer group

End user will connect with load balancer group http-80-anywhere

 

Click on create

Now create security group for webservers

htpp-80-loadbalancer-sg

Ssh-22-bastion-sg 

 




Now create three instances bastion,2 webservers

If one servers goes down another webserver will three to connect to server

We can create two webservers at a time why because two websevers

Now create instance for bastion

Refer above [how create an instance]

Click to launch instance

Select the amazon linux instance


 

Select instance type

Go with default t2.micro

 


Now configure instance details

Leave as default only

Click on add storage

 

Leave all as default 

click on add tags




Click on security group

select existing security group 

select bastion security group 

 

click on review and launch

 

click on launch

create new key pair

give name to key pair and download the key pair

 

Click on Launch

 

Go to the dashboard and create 2 instances for webservers

Select amazon linux free tier


Select instance type

Go with default free tier

 


Click on configure instance details

Enter number of instance 2(because two servers are having same rules)

Leave all as default only 

click on add storage

 

Select default storage

 

Click on configuration security Group

 

Select the existing security group

Select web server security group


Click on review and launch

 

Click on launch

Select Existing key pair

 

Instances launched

 



Now create a load balancer

Go to EC2 dashboard select load balancer


Click on load balancer


Select classic load balancer

 

Give a name to load balancer

Leave as default rest

 

And click on security group give load balancer security group


Click on Configure security settings

Click on next

 

Leave as default and click on EC2 instances

Select two webservers and click on add tags

 

Click on Review and create

 

Click on Create


Load Balancer is created

 

Now go to the git bash login with ssh to the bastion using pem file then login to web servers download apache and see whether the page is working or not.

Go to the git bash

Copy the pem file to login to the bastion servers

Refer above how to copy the pem file and how to login to server with ssh

 

Pem file is copied

Now login to bastion

#ssh –I <pemfile>ec2-user@ip address

Use above command to login the bastion server

Give bastion public ip address to login to bastion server

 

Now change permission of the pem file.

#chmod 400<pemfile>

Then login to bastion to webserver

As admin will connect to bastion to web server through ssh

End user will connect load balancer

End user will use lad balancer end point to see the page

Connecting bastion to web server

Here give website ip address

Because we connecting bastion to web server


Now switch to root user

Note: To do any changes and install any packages normal user dosen’t have permission to do

Only root user are having to do that.

After switching  to root user install httpd and check whether page is run or not

Refer above how to install apache and how to check to test the page.

 

 To install and start the service

#yum install httpd –y

After installing start the service

#Systemctl start httpd

 


To check whether service is installed or not run below command

#ps-ef -anlp|grep httpd

or you can netstat command 

#netstat -anip|grep httpd

 


Now check whether page is working or not

Do curl command

#curl httpd://localhost

 


To check the in the browser

Go to the browser enter webserver ip address

 

Now do the same in webserver 2 by installing the apache

 

Now install apache and start the service

We have the page

 

Now for end user he will connect  to the server through load balancer so we will go with load balancer url to the page

 

Go to the load balancer dashboard

Select the created load balancer

 

Copy the load balancer endpoint near dns name.

Go to the browser enter the url to see the page

 

 


Comments

Popular posts from this blog

Lab 21:Installing docker in instance and build an image

Lab 22:Pushing a docker image to docker hub

Lab 5: Installing Nginx in EC2 instance