How to Setup an AWS ELB with HTTP Support

How to Setup an AWS ELB with HTTP Support

Amazon Web Services (AWS) provide Elastic Load Balancing to manage traffic on a fleet of Amazon Elastic Compute Cloud (Amazon EC2) instances. In this guide we will show you how to create an Elastic Load Balancer (ELB) with HTTP protocol.

1. Go to the AWS EC2 Console. Check the running instances as well as the Elastic Load Balancers (ELBs).

2. Select  ”Load Balancers” on the left menu. It will show the list of all (elastic) load balancers created in your account. Initially, when no LB has been created, the following screen will appear > Click “Create Load Balancer”.

3. Provide the name of your ELB (name should be alphanumeric only). If you have a VPC configured, there’s an option to create the ELB inside the VPC. If you do not have a VPC configured, by default it will create the LB under the EC2 sections. In the “Listener Configuration” keep the default settings or modify as per server port and configuration. Your Amazon EC2 HTTP servers must be active and accepting requests on port mentioned on “Listener” (in this example, “80″). Click “Continue”.

[Newvem continuously analyzes the status of your instances and identifies unhealthy and over loaded instances that may not perform properly or increase outage and recovery vulnerabilities. Learn More]

4. Configure the health check of your LB. The description of each parameter is shown below.

a. The Ping protocol is what the LB will use as a protocol to ping and check the health of your instance.

b. The LB will ping on the port configured above (here, port 80).

c. If you have a webserver running and it has an index.html file, you can provide the ping path as “/index.html” , otherwise use “/”. For this setup, we installed Apache and created an index.html in Apache for verification so we will use “/index.html”.

d. ”Response Timeout” is the time the LB will wait for a response from the health check.

e. The “Health Check Interval” determines when the LB will ping the instance to run a check.

f. The “Unhealthy Threshold” will determine how many consecutive health checks the LB should run before declaring an instance as unhealthy.

g. ”Healthy Threshold” is similar to the one above, but this count shows how many health checks an instance should pass before being declared as healthy.

h. Also ensure that port 80 (or another port previously configured) is open in the EC2 security group of instance.

i. After making a few changes, we created our sample health check as below.

5. Click “Continue”.

6. It will list all running instances along with their availability zones.

7. Select the instances you want to add to the LB and click “Continue”.

8. Review and modify your settings of the LB, if needed.

9. Click “Create” and it will create an LB named “AWSFirstELB”. On the following confirmation page, click “close” and go to the ELB console.

10. On the LB console, you will see the created LB along with its details.

[Newvem analyzes your baseline disaster recovery (DR) status, reflecting how well AWS DR best practices have been implemented, and recommends AWS features and best practices to reach optimal availability, increase outage protection, and quick recovery. Learn More]

11. On our example, The LB shows on “Status” that both the instances passed the health check previously configured.

12. Instead of accessing an individual instance through their public IP, you can access them through the LB URL.

13. The LB will distribute the load based on an internal mechanism.

14. Both the instances that we added to the LB have Apache running and an index.html file which shows which instance is replying to the request.

15. Try to access the instances through “A Record” (highlighted on the previous image).

16. Sometimes it will show that the data is coming from instance 1 as seen below.

17. But for a few requests to the same URL we see the output coming from the second instance.

The above steps complete the basic configuration of the LB (with HTTP protocol).

Using the Command Line Interface -

19. Set the ELB CLI.

20. Start the command line window. We will create the LB in the US-West-2 region.

21. Set the region for your LB with the following command.


22. Create the LB with the following command.

elb-create-lb AWSFirstELB --headers --listener "lb-port=80, instance-port=80, protocol=http" --availability-zones us-west-2b

23. In the above command, lb-port is the port where the LB will listen and instance-port is where app / web server running on the instance will listen. After you create the LB, run the following command to check the success of the steps.

elb-describe-lbs AWSFirstELB

24. The output of elb-describe-lb will give the IP of the LB to access it from the internet.

25. Register the instances with the LB. Get the instance ID of all the instances you want to register with LB and run the command below.

elb-register-instances-with-lb AWSFirstELB --instances i-f58c81c6,i-6d8e835e

26. The output of each of the above steps is shown as below.

27. To configure the healthcheck of the LB, run the command bellow.

elb-configure-healthcheck AWSFirstELB --headers --target "HTTP:80/index.html" --interval 30 --timeout 10 --healthy-threshold 5 --unhealthy-threshold 7

28. In the above command, the interval is in seconds (on the AWS Console it was in minutes).

29. You can compare the above command with the values we provided on step 4.

30. Run the following command to check the health of the LB and instances registered with it.

elb-describe-instance-health AWSFirstELB

31. The output of both commands is shown as below.

32. Note that currently only one instance is “InService” and in healthy condition since we started the webserver only on that instance. The second instance is in running mode but since the webserver is stopped it is not able to listen to HTTP:80/index.html

[Newvem analytics tracks you AWS cloud utilization:

  • Hourly Utilization Pattern Analysis 
  • Reserved Instances Decision Tool 
  • Resource Resizing Opportunities

Create Your Free Account or Learn More]

Keywords: Amazon web services, Amazon AWS console, AWS S3, Amazon Cloud Services, AWS Management Console, ELB, Elastic Load Balancer, AWS s3, AWS EC2, Command Line Tools, CLI, AWS Console, EC2 Instances

You must be to post a comment.

* As a bonus, you'll receive our weekly newsletter!

Hitchhiker's Guide to The Cloud

Newvem's eBook for Cloud Operations