Anatol Zakrividoroga
Anatol Zakrividoroga

Reputation: 4518

How to Redirect All Requests to One Domain using AWS Load Balancer

I am using a Load Balancer with Elastic Beanstalk. I want to redirect any host that is different than domain.com to domain.com.

Is that possible to achieve with an AWS load balancer?

Upvotes: 2

Views: 1612

Answers (1)

Chris Williams
Chris Williams

Reputation: 35146

This is actually quite easy and fully supported by the AWS ALB.

What you're looking to do is to add a Host header based rule. The steps below should be followed:

  • Find your Application Load Balancer
  • For each listener select View/Edit Rules
  • Click the + symbol at the top of the console to add your rule, specify that the rule is a host header rule with a target of your target group.
  • Edit the default rule, remove the action and set to a redirect action (as show in the below screenshot).

enter image description here

By adding the host header rule with a target as the target group for you app, it will only connect to your hosts for the correct host name.

Otherwise have the default action be a redirect action to redirect to the domain you specify.

Upvotes: 1

Related Questions