Course contentsShow
← Cloud and Infrastructure
Lesson 248 of 2,9895. Load Balancing and Traffic ManagementFree lesson

Host-Based Routing

Route requests to different target groups based on the hostname in the HTTP header for multi-tenant applications.

Host-Based Routing

What you'll learn: How to route incoming requests to different application backends based on the hostname used in the request.


What Is Host-Based Routing?

Host-based routing lets your Application Load Balancer (ALB) direct traffic to different target groups based on the hostname in the HTTP request's Host header. This means a single load balancer can serve multiple websites or applications, each identified by its domain name.

Think of it like a receptionist at a large office building. When visitors arrive asking for "CompanyA.com" or "CompanyB.com," the receptionist directs them to completely different floors—even though they entered through the same front door.

How It Works

When a request arrives at your ALB with a specific hostname (like api.example.com or shop.example.com), the ALB checks its listener rules. If a rule matches that hostname, the request gets routed to the corresponding target group.

Example scenario:

  • api.example.com → routes to your API server target group
  • shop.example.com → routes to your e-commerce backend target group
  • blog.example.com → routes to your blogging platform target group

All three hostnames point to the same ALB's IP address via DNS, but the ALB intelligently separates the traffic based on the Host header.

Why Use Host-Based Routing?

This is especially valuable for multi-tenant applications, where different customers or departments share infrastructure but need isolated backends. Instead of deploying separate load balancers for each tenant, you configure routing rules that direct tenant1.yourapp.com and tenant2.yourapp.com to their respective target groups.

It also reduces costs and simplifies management—one load balancer handles multiple applications.

Key Takeaway: Host-based routing uses the hostname in HTTP requests to direct traffic to different target groups, enabling a single ALB to serve multiple applications or tenants efficiently.