How can I set up host-based routing using an Application Load Balancer?
Last updated: 2021-03-05
I have multiple domains that are served by the same Application Load Balancer. I'm using different target groups for each domain. I need to forward the traffic for each domain to their respective target groups. How can I set up host-based routing using an Application Load Balancer?
- Open the Amazon Elastic Compute Cloud (Amazon EC2) console.
- On the navigation pane, choose Load Balancers under Load Balancing.
- Select your load balancer, and then choose Listeners.
- Choose View/edit rules for the load balancer listener that you want to use.
- Choose the Add rule icon (the plus sign).
- Choose Insert Rule.
- Choose Add condition.
- Choose Host header.
- Enter the hostname for your domain (for example, example1.com).
Choose the checkmark icon to save the condition.
- Choose Add action to add the desired actions for your condition. To save the actions, choose the checkmark icon.
- Choose Save.
- Repeat steps 5-12 to add additional rules to route different domains to different target groups.
- To use the same set of target groups to serve multiple domains, add multiple hostnames for your domains.
- Rules are prioritized based on their position in the rule list. If necessary, you can reorder rules to modify the rule priorities.
- If a request's host header doesn't match the host headers in any of the rules, the actions configured in the listener's default rule are performed.