How can I set up host-based routing using an Application Load Balancer?

2 minute read
0

I have multiple domains that are served by the same Application Load Balancer. I'm using different target groups for each domain. I want 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?

Resolution

  1. Open the Amazon Elastic Compute Cloud (Amazon EC2) console.
  2. On the navigation pane, choose Load Balancers under Load Balancing.
  3. Select your load balancer, and then choose Listeners.
  4. Choose View/edit rules for the load balancer listener that you want to use.
  5. Choose the Add rule icon (the plus sign).
  6. Choose Insert Rule.
  7. Choose Add condition.
  8. Choose Host header.
  9. Enter the hostname for your domain (for example, example1.com).
    Choose the checkmark icon to save the condition.
  10. Choose Add action to add the desired actions for your condition. To save the actions, choose the checkmark icon.
  11. Choose Save.
  12. Repeat steps 5-12 to add additional rules to route different domains to different target groups.

Notes:

  • 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.

Related information

Listener rules for your Application Load Balancer

AWS OFFICIAL
AWS OFFICIALUpdated a year ago