Create an HTTP listener for your Application Load Balancer - Elastic Load Balancing
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Create an HTTP listener for your Application Load Balancer

A listener checks for connection requests. You define a listener when you create your load balancer, and you can add listeners to your load balancer at any time.

The information on this page helps you create an HTTP listener for your load balancer. To add an HTTPS listener to your load balancer, see Create an HTTPS listener for your Application Load Balancer.

Prerequisites

  • To add a forward action to the default listener rule, you must specify an available target group. For more information, see Create a target group for your Application Load Balancer.

  • You can specify the same target group in multiple listeners, but these listeners must belong to the same load balancer. To use a target group with a load balancer, you must verify that it is not used by a listener for any other load balancer.

Add an HTTP listener

You configure a listener with a protocol and a port for connections from clients to the load balancer, and a target group for the default listener rule. For more information, see Listener configuration.

To add another listener rule, see Listener rules.

Console
To add an HTTP listener
  1. Open the Amazon EC2 console at https://console.amazonaws.cn/ec2/.

  2. On the navigation pane, choose Load Balancers.

  3. Select the load balancer.

  4. On the Listeners and rules tab, choose Add listener.

  5. For Protocol, choose HTTP. Keep the default port or enter a different port.

  6. For Default action, select one of the following routing actions and provide the required information:

    • Forward to target groups – Choose a target group. To add another target group, choose Add target group, choose a target group, review the relative percentages, and update the weights as needed. You must enable group-level stickiness if you enabled stickiness on any of the target groups.

      If you don't have a target group that meets your needs, choose Create target group to create one now. For more information, see Create a target group.

    • Redirect to URL – Enter the URL by entering each part separately on the URI parts tab, or by entering the full address on the Full URL tab. For Status code, select either temporary (HTTP 302) or permanent (HTTP 301) based on your needs.

    • Return fixed response – Enter the Response code to return for dropped client requests. Optionally, you can specify the Content type and a Response body.

  7. (Optional) To add tags, expand Listener tags. Choose Add new tag and enter the tag key and tag value.

  8. Choose Add.

Amazon CLI
To create a target group

If you don't have a target group that you can use for the default action, use the create-target-group command to create one now. For examples, see Create a target group.

To create an HTTP listener

Use the create-listener command. The following example creates an HTTP listener with a default rule that forwards traffic to the specified target group.

aws elbv2 create-listener \ --load-balancer-arn load-balancer-arn \ --protocol HTTP \ --port 80 \ --default-actions Type=forward,TargetGroupArn=target-group-arn
CloudFormation
To create an HTTP listener

Define a resource of type AWS::ElasticLoadBalancingV2::Listener. The following example creates an HTTP listener with a default rule that forwards traffic to the specified target group.

Resources: myHTTPlistener: Type: 'AWS::ElasticLoadBalancingV2::Listener' Properties: LoadBalancerArn: !Ref myLoadBalancer Protocol: HTTP Port: 80 DefaultActions: - Type: "forward" TargetGroupArn: !Ref myTargetGroup