How can I route traffic based on a custom HTTP header using an Application Load Balancer?

Last updated: 2020-08-14

I want to perform a specific action on requests based on the value of a custom HTTP header using an Application Load Balancer. How can I do this?

Resolution

  1. Create an Application Load Balancer, if you don't already have one.
  2. Open the Amazon Elastic Compute Cloud (Amazon EC2) console.
  3. On the navigation pane, under Load Balancing, choose Load Balancers.
  4. Select your load balancer.
  5. Choose the Listeners tab.
  6. Select your HTTP listener, and then choose View/edit rules.
  7. Choose the Add rules icon (the plus sign), and then choose Insert rule.
  8. Choose Add condition, and then choose Http header.
  9. Specify a header name based on the desired action. For example, "Accept."
    Note: The maximum size of each header name is 40 characters. The header name is not case-sensitive. Wildcards are not supported.
  10. Specify the values (comparison strings) of the custom header.
    Note: The maximum size of each comparison string is 128 characters. The comparison string is not case-sensitive. The asterisk (*) and question mark (?) wildcard characters are supported.
  11. Choose Add action, and then select the required action. For example:
    Forward – To forward to a different target group.
    Return fixed response – To block or provide a custom response to particular clients based on the value of custom header.
  12. To save the condition, choose the checkmark icon.
  13. To save the rule, choose Save.

Did this article help?


Do you need billing or technical support?