AWS Networking Fundamentals
Core Networking Services
Load Balancers Demo
In this hands-on tutorial, you’ll set up an AWS Application Load Balancer (ALB) to distribute HTTP requests across two EC2 web servers running Nginx, each in a different Availability Zone. By the end, you’ll have a resilient, internet-facing load balancer serving content from both servers.
Prerequisites
Note
Make sure you already have:
- Two t2.micro EC2 instances (web-server-1, web-server-2) with Nginx and distinct landing pages.
- A VPC configured with an Internet Gateway.
- Two public subnets in us-east-1a and us-east-1b.
Resource | Description | Details |
---|---|---|
EC2 Instances | Web servers | web-server-1 (us-east-1a), web-server-2 (us-east-1b) |
VPC | Virtual Private Cloud | Includes an Internet Gateway and public subnets |
Public Subnets | Hosts web servers | 10.0.201.0/24 (AZ a), 10.0.202.0/24 (AZ b) |
EC2 Instances
Our EC2 console shows both instances running:
Visiting web-server-1 confirms Nginx is up:
And web-server-2 is similarly healthy:
Network Layout
Your VPC’s public subnets:
- web-us-east-1a: 10.0.201.0/24
- web-us-east-1b: 10.0.202.0/24
These subnets host your web servers and route traffic through the Internet Gateway.
Step 1: Create Dedicated Subnets for the Load Balancer
Add two new public subnets—one in each AZ—for the ALB:
- In the VPC console, click Create Subnet.
- Configure:
- LB-us-east-1a: us-east-1a, 10.0.101.0/24
- LB-us-east-1b: us-east-1b, 10.0.102.0/24
After creation, verify you have four public subnets:
Step 2: Verify Public Subnet Configuration
Note
Confirm each new subnet’s route table includes a default route (0.0.0.0/0
) to the Internet Gateway—this makes the ALB internet-facing.
Select LB-us-east-1a (and LB-us-east-1b) to inspect its Route Table:
Step 3: Create the Application Load Balancer
- In the EC2 console, go to Load Balancers → Create Load Balancer → Application Load Balancer.
- Set:
- Name: web-lb
- Scheme: Internet-facing
- IP address type: IPv4
- VPC: demo
- Select subnets LB-us-east-1a and LB-us-east-1b.
Configure the ALB network mapping:
Attach a security group allowing HTTP (80) and HTTPS (443):
Step 4: Configure Listener and Target Group
Listener
Add an HTTP listener on port 80:
Target Group
- Create a new target group:
- Target type: Instances
- Name: web-targets
- Protocol: HTTP
- Port: 80
- VPC: demo
- Health check path:
/
- Register web-server-1 and web-server-2 on port 80:
- Back in the ALB wizard, set web-targets as the default action for the HTTP listener:
- Review and create the ALB:
Step 5: Test the Load Balancer
Wait until the ALB status is active, then copy its DNS name:
From your terminal or browser:
curl http://<load-balancer-dns-name>
Refreshing the request should alternate responses between server1 and server2, confirming traffic distribution.
Best Practice: Secure Your Web Servers
Warning
Currently, both web servers have public IPs:
To harden your architecture:
- Move web servers into private subnets.
- Keep the ALB in public subnets.
- Configure the web servers’ security group to accept traffic only from the ALB’s security group.
This ensures all external requests pass through the ALB, improving security and isolation.
Links and References
Watch Video
Watch video content