1
votes

I am new to AWS and trying to understand how load balancers route request to real servers. I have two questions:

Question 1:

Suppose I have a web application that runs on 198.1.1.1:80. Users use www.example.com to make a request to my application. Now after the load balancer is created on 197.5.3.5 & security groups are set up, I want requests go to the load balancer first.

Right now, by typing in www.example.com the request will internally be routed from 197.5.3.5 to 198.1.1.1:80. What change needs to be made in order to route www.example.com to the load balancer server (197.5.3.5**)? Also, how does the conversion from domain names to IP address happen? I am new to domain name resource records and DNS servers.

Question 2:

I am setting up EC2 instance, load balancer, and security group from scratch. In this case, should I associate the load balancer IP (197.5.3.5) to www.example.com? In this case, I also need to understand: whatt change needs to be made in order to route www.example.com to the load balancer server (197.5.3.5) ?

2

2 Answers

1
votes

When an Elastic Load Balancer is created, you will be provided with a DNS Name similar to:

myelb-756456754.us-west-2.elb.amazonaws.com

You should use a CNAME record to point your www.example.com domain to the Load Balancer DNS name. When a user goes to the domain name, it will resolve to an IP address for one of the load balancer servers. The IP address should not be cached because load balancing servers can be added and removed. The load balancer should always be referenced by its DNS name (or your domain name, which resolves to the load balancer DNS name).

If you are using your own load balancer on an EC2 instance, then:

  • Create an Elastic IP address for your load balancing instance (this ensures the address does not change in future)
  • Use an A record to direct www.example.com to the Elastic IP address
  • Configure your load balancer to send traffic to the instances (using whatever software you've loaded)

Your security group configurations should be:

  • A Load Balancer Security Group that permits HTTP and HTTPS traffic from 0.0.0.0/0 (everywhere) should be associated with the Load Balancer.
  • An Application Security Group that permits port 80 (and other?) traffic from the Load Balancer Security Group should be associated with each of the EC2 instances behind the Load Balancer.

Note that the Application Security Group is accepting traffic from the Load Balancer Security Group (or, more accurately, from instances associated with the group_.

0
votes

For item #1 you need to update DNS to point at the load balancer's address. The ELB will have X number of machines behind it, all running copies of the same website.

Item #2 is the same thing - you need to "add" the instance to your ELB.