18.16 Internet-facing and internal load balancers
Why there are two schemes
Users on the internet must reach the web tier. They type a public name. The app tier must not be reachable from the internet. If it is, anyone can call the API and skip the checks the web tier was supposed to do. Two balancers, two schemes, is how you keep those doors apart.
What the scheme changes
You choose the scheme when you create the balancer. You do not flip it later. Changing scheme means creating a new balancer and moving the listeners. The console will not turn an internal balancer into an internet-facing one in place.
| Scheme | Addresses | DNS name | Who can open it |
|---|---|---|---|
| Internet-facing | Public addresses, placed in public subnets | A public DNS name | Users on the internet, if the security group allows them |
| Internal | Private addresses only | A DNS name that resolves inside the VPC | Instances in the VPC, not a laptop on the internet |
A public subnet in this lesson has a route to an internet gateway. A private subnet does not.
How the two balancers are placed
Worked example in one VPC. The ranges are private ranges we chose for the drawing. They are not a claim about your default VPC.
Users reach the public ALB in public subnets and the web tier. The web tier calls the internal ALB in private subnets. A red X blocks the internet from the internal balancer.
Internet-facing Application Load Balancer:
- Scheme is Internet-facing.
- Subnet one is
172.16.0.0/24, a public subnet. - Subnet two is
172.16.1.0/24, a public subnet in a second Availability Zone. - Its security group allows TCP 80 and TCP 443 from
0.0.0.0/0. - It forwards to the web target group.
Internal Application Load Balancer:
- Scheme is Internal.
- Subnet one is
172.16.10.0/24, a private subnet. - Subnet two is
172.16.11.0/24, a private subnet in a second Availability Zone. - Its security group allows TCP 8080 only from the web tier security group.
- It does not allow 8080 from
0.0.0.0/0. - It forwards to the app target group on port 8080.
The path of one user:
- A user in Pune opens
https://www.example.com. - DNS sends them to the internet-facing balancer.
- That balancer sends the request to a web EC2.
- The web EC2 calls
http://internal-api-lb.example.internal:8080. - That name is a private record we point at the internal balancer. The AWS DNS name of an internal balancer also resolves to private addresses inside the VPC. It does not have a route from the internet.
- The internal balancer sends the call to an app EC2.
- The app EC2 is not on the internet. Its subnet is private. Its security group does not allow the world.
Public ALB security group allows 443 from 0.0.0.0/0. Internal ALB security group allows 8080 only from the web security group.
How to set the scheme in the console
Button names may vary.
- Choose Create load balancer, then Application Load Balancer.
- On the scheme control, choose Internet-facing for the public balancer.
- Pick the two public subnets.
- Finish that balancer.
- Start a second Application Load Balancer.
- On the scheme control, choose Internal.
- Pick the two private subnets.
- You should see the scheme listed on each balancer's description. One says internet-facing. One says internal.
- If you picked the wrong scheme, do not hunt for an edit that flips it. Create a new balancer with the right scheme and delete the wrong one when nothing still points at it.
What goes wrong if the app balancer is internet-facing
Second example, the failure.
- The app balancer is created as internet-facing by mistake.
- It receives public addresses.
- Its security group is left open, or a later edit allows 8080 from
0.0.0.0/0. - Anyone who learns the DNS name can call the API directly.
- The web tier's checks are skipped.
- The fix is a new internal balancer in the private subnets, a security group that allows 8080 only from the web tier, and a private DNS name. You do not "switch" the old one.
Ravindra Bagale's Tip
If you make the app-tier balancer internet-facing, anyone can hit the API directly and skip the web tier's checks. Keep the scheme Internal.
Ravindra Bagale's Tip – मराठी
अॅप टियरचा बॅलन्सर internet-facing ठेवला तर कोणीही API ला थेट हिट करतो, वेब टियरचे चेक स्किप होतात. स्कीम Internal ठेवा.
Ravindra Bagale's Tip – हिंदी
ऐप टियर का बैलेंसर internet-facing रखा तो कोई भी API को सीधे हिट करता है, वेब टियर के चेक स्किप हो जाते हैं. स्कीम Internal रखो.