Skip to content

Ferdinand Agyei-Yeboah

Host Based Routing With AWS ALB

March 24, 2022

There are many routing options when using AWS ALB (Application Load Balancer). You can route based on url paths, http headers, host headers, and more.

Host based routing lets you route traffic to specific (or the same) backends depending on the incoming hostname (domain1.com vs. domain2.com)

This article will show how to configure host based routing using an AWS ALB.

Implementing host based routing

To implement host based routing, you should have a DNS record you want to check as the host. This means you may need to create a domain, subdomain, cname or anything else you want to use to as the host. This DNS record would then need to point to your load balancer.

The target group on your load balancer is what will determine the routing logic. Configure your target group to route based on host header. Like shown below.

Host Based Routing Listener

In this example I have two host based rules. Requests coming in from anotherdomain.com and yourdomain.com each go to a specific target group (tg-example for both in in this case, but can go to different target groups). As mentioned before, those records (anotherdomain.com and yourdomain.com) would need to point to this load balancer.


More Reading


Software Engineering Tutorials & Best Practices