Application Load Balancer (ALB )
Lab Practice
Before we do the lab, we need to setup the infrastructure with these 4 instances as follows:
You need 4 Virtual Linux Machines
PC1 should be called LinuxPic1: us-east-1a
PC2 should be called LinuxPic2 : us-east-1a
PC3 should be called LinuxVideo3: us-east-1c
PC4 should be called LinuxVideo4: us-east-1c
1) Linux PC that is called LinuxPic1 , created two files :
a) index.html —> content will be “This is Main site of Picture1 “
b) picture.html —> content will be ” This is pic1 ” or
1a) Linux PC that is called LinuxPic2 , created two files :
a) index.html —> content will be “This is Main site of Picture2”
b) picture.html —> content will be ” This is pic2 “
==============================================
2) Linux PC that is called Linuxvideo3 , created two files :
a) index.html —> content will be “This is Main site of Video3”
b) video.html —> content will be ” this is Video3″
2a) Linux PC that is called Linuxvideo4 , created two files :
a) index.html —> content will be “This is Main site of Video4”
b) video.html —> content will be ” this is Video4 “
so when I type x.x.x.x/index.html I will see content with main websites ( for Video)
when you type x.x.x.x/video.html I will see content with Video 3 or 4
so when I type x.x.x.x/index.html I will see content with main websites ( for Picture)
when I type x.x.x.x/picture.html I will see content with picture 1 or 2
Please see the codes that we will use it ; during the installation of the Instance
Here is Sample for one of codes the rest will be similar and you will see when you watch the Video
==================================================
#!/bin/bash
yum update -y
yum install -y httpd
service httpd start
chkconfig httpd on
groupadd www
usermod -a -G www ec2-user
echo “hello” > /var/www/html/index.html
chown -R root:www /var/www
chmod -R 2775 /var/www
echo ‘<h1>This is Main site of Picture1 </h1>’>/var/www/html/index.html
echo ‘
echo ‘<h1>This is pic1 </h1>’>/var/www/html/picture.html
===================================================
Make sure check and see all the 4 Linux Machine is working correctly with lab.
Now we will do the Lab
Step 1) before you do anything you need to create two target group
PictureTG
VideoTG
Step 2) Chose create a new target group
Target group name=PictureTG
Pick = Instance
Protocol = http
Chose VA VPC
The rest pick default value
Health check = http
Path=/index.html ( We need to make sure your instance has this file name )
Step 3) When you get to register targets; make sure you pick LinuxPic1 and LinxPic2 Instance ;
Step 4) click include as pending below
Step 5) Then create target group; after it finish ; click on it and you will see it is “unused” ; later on it will be changed .
Step 6) Do same steps in above but called it
Target group name=VideoTG
Pick = Instance
Protocol=http
Chose VA VPC
The rest pick default value
Health check=http
Path=/index.html (We need to make sure your instance has this file name )
Step 6) As we see when we are at target page; we do not see any load Balancer in front of it ; since we have not configured it; but later on we will see it
Step 7) Now we will go and create Application Load Balancer
Step 8) Before you creatin ALB ; make sure you will know what is your security group for you Instance and have it ready
Step 9) Create ALB ;
Name =VAALB
Pick your VPC
Pick both AZ=1a and AZ=1c
Pick Same Security group as above
Listener = 80
Step 9) In front of Listener; you need to pick your Target Group ; in here does not matter which one you will pick ; but I will pick PictureTG
Step 10) Create ALB ; then back to your target group ; click on “PictureTG” you will see statues as initial ; then it will become “Healthy”
Step 11) Now after two mins it become Healthy and when you look at Target Group page we see in column under Load Balancer; it shows name of VAALB with PictureTG ( since we chose it as default) but VideoTG has nothing in it.
Step 12) Now go to VideoTG and click it and you will see “unused”
Step 13) Now we want to make sure we use VideoTG
Step 14) Go to Load Balancer on left ; go to Listener tab
Step 15) Click View/Edit Rule
Step 16) click + sign to add some Rule; click insert rule
Step 17) Pick path then type *video* then action Forward to target Group VideoTG
Step 18) Make sure click Save and do same steps ; but add rule for *picture* and FW to pictureTG
Step 19) Now Click Back ; go back to VAALB and click on description tab and copy and paste the Log DNS name then try with
/picture.html and
/video.html
You should be able to see all the instance is working
http://vaalb-108982661.us-east-1.elb.amazonaws.com/picture.html
http://vaalb-108982661.us-east-1.elb.amazonaws.com/video.html
Step 20) Remember you can go back to your Route53 and create an “A” record and point to the above link
Step 21) Now If I go back to Target Group page; now under ALB column I will see both PictureTG and VideoTG
Step 22) Go and click on VideoTG and now you will see “healthy” Remember ; we had it as “unused”