Download as pdf or txt
Download as pdf or txt
You are on page 1of 24

Application Load Balancer Task

Application Load Balancer Task

Create one Linux Machine using the Bootstrap script

Script: Click Here

Check the Web Page, Copy the Public IP & paste in browser

Connect to the machine using putty

Switch User
sudo su

www.selfonlinetraining.wordpress.com ankitnarula1991@gmail.com
Application Load Balancer Task

Switch to html folder


cd /var/www/html

Create Directory
mkdir custom

Switch to new directory


cd custom

Create web page in the directory


echo "Google Drive" > index.html

www.selfonlinetraining.wordpress.com ankitnarula1991@gmail.com
Application Load Balancer Task

Now check the public IP/custom

Create Second Linux Machine using the Bootstrap script

Script: Click Here

Check the Web Page, Copy the Public IP & paste in browser

Connect machine using putty

www.selfonlinetraining.wordpress.com ankitnarula1991@gmail.com
Application Load Balancer Task

Switch User
sudo su

Switch to html folder


cd /var/www/html

Create Directory
mkdir image

Switch to new directory


cd custom

www.selfonlinetraining.wordpress.com ankitnarula1991@gmail.com
Application Load Balancer Task

Create web page in the directory


echo "Google Image" > index.html

Now check the public IP/image

Create Target Group

Target is used to define the EC2 Machine we want to create the Application Load
Balancer.

Load Balancing Target Groups

Click on create target group

www.selfonlinetraining.wordpress.com ankitnarula1991@gmail.com
Application Load Balancer Task

Select target type as instances

Scroll down

Enter target group name

Click on Next

www.selfonlinetraining.wordpress.com ankitnarula1991@gmail.com
Application Load Balancer Task

Select the first machine

Click on Include as pending below

Click on create target group

www.selfonlinetraining.wordpress.com ankitnarula1991@gmail.com
Application Load Balancer Task

Create Another target group for second Linux machine

Click on create target group

Select target type as instances

Enter the name of the target group

Click on Next

www.selfonlinetraining.wordpress.com ankitnarula1991@gmail.com
Application Load Balancer Task

Select the second machine

Click on include as pending below

Click on create target group

www.selfonlinetraining.wordpress.com ankitnarula1991@gmail.com
Application Load Balancer Task

Create Application Load Balancer

Load Balancing Load Balancers

Click on create load balancer

Click on create for application load balancer

www.selfonlinetraining.wordpress.com ankitnarula1991@gmail.com
Application Load Balancer Task

Enter the name of the load balancer

Scroll down

www.selfonlinetraining.wordpress.com ankitnarula1991@gmail.com
Application Load Balancer Task

Select all subnets

Select security group

www.selfonlinetraining.wordpress.com ankitnarula1991@gmail.com
Application Load Balancer Task

Select target group as first machine

Click on Create load balancer

www.selfonlinetraining.wordpress.com ankitnarula1991@gmail.com
Application Load Balancer Task

While creating our load balancer we have given target group as first machine so system
is forwarding our DNS name only to first machine.

Click on view edit rules

We need our DNS name will redirect to our both the machines home page. For this we
need to edit our default rule.

Click on edit.

Click on edit rule

www.selfonlinetraining.wordpress.com ankitnarula1991@gmail.com
Application Load Balancer Task

Click on edit

Select target group as second machine & Enter traffic distribution as 1

Click on the Tick

www.selfonlinetraining.wordpress.com ankitnarula1991@gmail.com
Application Load Balancer Task

Click on update

Now add more rules as per path mention in our Linux machines

Click on add

Click on insert rule

www.selfonlinetraining.wordpress.com ankitnarula1991@gmail.com
Application Load Balancer Task

Click on add condition

Click on path

Enter path as /custom/* (we are entering this path because /custom is path in the first
machine. /* after custom we are entering now because in the first rule we have define
first & second machine as 50-50% so for every path we need to enter as /*. Otherwise if
we create any folder in custom folder system will not pick those folder)

www.selfonlinetraining.wordpress.com ankitnarula1991@gmail.com
Application Load Balancer Task

Click on add action

Click on forward to

Select target group as first machine

Click on check & Click on save

www.selfonlinetraining.wordpress.com ankitnarula1991@gmail.com
Application Load Balancer Task

Click on insert rule

Click on add condition

Click on path

Enter path as /image/*

Click on add action

Click on forward to

Select target group as Second machine

Click on check & Click on save

www.selfonlinetraining.wordpress.com ankitnarula1991@gmail.com
Application Load Balancer Task

Now check the DNS Name

Refresh the page

Now enter the path as /custom

Now enter path as /image

Now Try to create more folder in the custom folder (first machine)

Create directory
mkdir training

www.selfonlinetraining.wordpress.com ankitnarula1991@gmail.com
Application Load Balancer Task

Switch to new directory (training)


cd training

Create web page in the directory


echo "AWS Training" > index.html

Now check the DNS

Now Try to create more folder in the image folder (Second machine)

Create directory
mkdir drive

Switch to new directory (drive)


cd drive

Create web page in the directory


echo "Enjoy Life" > index.html

www.selfonlinetraining.wordpress.com ankitnarula1991@gmail.com
Application Load Balancer Task

Now check the DNS

Now if we enter any other path not which is not in the web server should be redirected
to a success static plain text page with a note “Wrong Page. Please try another Path”

Go to your Application Load balancer & edit the rule

Click on add

Click on insert rule

www.selfonlinetraining.wordpress.com ankitnarula1991@gmail.com
Application Load Balancer Task

Click on add condition

Click on path

Enter the value as *

Click on add action

Select as Return Fixed response

www.selfonlinetraining.wordpress.com ankitnarula1991@gmail.com
Application Load Balancer Task

Select content-type as text/html

In the Response text Enter the text which we want to display <h1> Wrong Page. Please
Try another Path </h1>

Click on check & click on save

Now try the DNS with any other path

www.selfonlinetraining.wordpress.com ankitnarula1991@gmail.com

You might also like