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

2 minute read

I want to use an Application Load Balancer to perform a specific action on requests based on the value of a custom HTTP header.


  1. Create an Application Load Balancer.
  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 listener, and then from the Actions dropdown, choose View listener details.
  7. Under Rules, choose Manage rules.
  8. Choose the Add rules icon (the plus sign), and then choose Insert rule.
  9. Choose Add condition, and then choose Http header.
  10. 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 isn't case sensitive. Wildcards aren't supported.
  11. Specify the values (comparison strings) of the custom header.
    Note: The maximum size of each comparison string is 128 characters. The comparison string isn't not case sensitive. The asterisk (*) and question mark (?) wildcard characters are supported.
  12. Choose Add action, and then select the required action. For example:
    Forward – To forward to a different target group.
    Redirect to - To redirect to a different URL.
    Return fixed response – To block or provide a custom response to particular clients based on the value of custom header.
  13. Choose Save.

Related information

Listener rules for your Application Load Balancer

AWS OFFICIALUpdated a year ago