All Products
Search
Document Center

Server Load Balancer:Add an HTTP listener

Last Updated:Jan 08, 2024

Listeners are used to check connection requests. If your applications, such as web applications and mobile games, need to identify data content, you can create an HTTP listener to forward HTTP requests.

Prerequisites

Procedure

This topic describes two procedures to show you how to create an HTTP listener. You can choose one as needed.

  • Manual creation: You can create an HTTP listener and configure advanced features based on business requirements.

  • Quick creation: You can use a template to quickly create an HTTP listener. You only need to specify a listener protocol, a listener port, and a backend server group.

Manual creation

  1. Log on to the ALB console.
  2. In the top navigation bar, select the region in which the ALB instance resides.

  3. Use one of the following methods to open the listener configuration wizard:

    • On the Instances page, find the ALB instance that you want to manage and click Create Listener in the Actions column.

    • On the Instances page, click the ID of the ALB instance that you want to manage. On the Listener tab, click Create Listener.

  4. In the Configure Listener step, configure the parameters that are described in the following table, and click Next.

    Parameter

    Description

    Listener Protocol

    Select a listener protocol.

    In this example, HTTP is selected.

    Listener Port

    Select the port on which the ALB instance listens. The ALB instance listens for requests on the specified port and then forwards the requests to backend servers. Valid values: 1 to 65535. In most cases, port 80 is used for HTTP and port 443 is used for HTTPS.

    Note

    On the same ALB instance, the ports of listeners that use the same protocol must be unique. HTTP listeners and HTTPS listeners must use different ports.

    In this example, port 80 is used.

    Listener Name

    Enter a name for the listener.

    Tag

    Configure the Tag Key and Tag Value parameters to add a tag. You can add one or more tags.

    After you specify tags, you can filter listeners by tag on the Listener tab.

    Advanced Settings

    You can click Modify to configure the advanced settings.

    Idle Connection Timeout Period

    Specify a timeout period for idle connections. Unit: seconds. Valid values: 1 to 60. To specify a longer timeout period,

    go to the Quota Center console.

    If no request is received within the specified timeout period, ALB closes the connection. When another request is received, ALB establishes a new connection.

    Note

    This feature is not available for HTTP/2 requests.

    Connection Request Timeout

    Specify a request timeout period. Unit: seconds. Valid values: 1 to 180. To specify a longer timeout period, go to the Quota Center console.

    If no response is received from the backend server within the request timeout period, ALB returns an HTTP 504 error code to the client.

    Compression

    If you enable compression, specific types of files are compressed. If you disable compression, no file is compressed.

    Brotli supports all file types. GZIP supports the following file types: text/xml, text/plain, text/css, application/javascript, application/x-javascript, application/rss+xml, application/atom+xml, application/xml, and application/json.

    Retrieve Client IP

    Specify whether to enable the ALB instance to retrieve client IP addresses from the X-Forwarded-For header. If you enable this feature, you must specify trusted IP addresses.

    • If you set the trusted IP address list to 0.0.0.0/0, the ALB instance retrieves the leftmost IP address in the X-Forwarded-For header. The IP address is the source client IP address.

    • If you set the trusted IP address list in the format of proxy1 IP, proxy2 IP,.., the ALB instance compares the IP addresses in the X-Forwarded-For header from right to left against the trusted IP address list. The first IP address that is not on the trusted IP address list is considered the source client IP address.

    Usage notes

    If the X-Forwarded-For header contains multiple IP addresses, such as X-Forwarded-For: <client-ip-address>, <proxy1>, <proxy2>, …,

    the leftmost IP address is the source client IP address. If you want to enable the matching based on source IP addresses and throttling based on QPS per client IP address features in ALB forwarding rules, you must turn on the Retrieve Client IP switch to allow the ALB instance to retrieve source client IP addresses from the X-Forwarded-For header. For more information, see Create a forwarding rule.

    Add HTTP Header

    The X-Forwarded-For header is selected by default. The header is used to retrieve source client IP addresses. ALB inserts source client IP addresses into the header and passes the header to backend servers. For more information, see Enable ALB to preserve client IP addresses.

    You can select the following options:

    • Add SLB-ID to Retrieve ALB ID: Add the SLB-ID header to store the ID of the ALB instance.

    • Add X-Forwarded-Proto to Retrieve Listening Protocol: Add the X-Forwarded-Proto header to store the listener protocol.

    • Add X-Forwarded-Port to Retrieve Listening Port: Add the X-Forwarded-Port header to store the listener port.

    • Add X-Forwarded-Client-srcport to Retrieve Client Port: Add the X-Forwarded-Client-srcport header to store the client port.

  5. In the Select Server Group step, select a server group, view the backend servers, and then click Next.

  6. In the Confirm step, confirm the configurations and click Submit.

Quick creation

If you select this method, you need to only specify a listener protocol, a listener port, and a server group.

  1. Log on to the ALB console.
  2. In the top navigation bar, select the region in which the ALB instance resides.

  3. On the Instances page, find the ALB instance that you want to manage and click its ID.

  4. Click the Listener tab. On the Listener tab, click Quick Create Listener.

  5. In the Quick Create Listener dialog box, configure the parameters and click OK. The following table describes the parameters.

    Parameter

    Description

    Listener Protocol

    Select a listener protocol. In this example, HTTP is selected.

    Listener Port

    The frontend port that is used to receive and forward requests to backend servers.

    You can select a commonly used port, or enter a port number. Valid values: 1 to 65535.

    Resource Group

    Select a resource group for the server group.

    Server Group

    Configure the Server Type parameter and select a server group based on the specified server type.

References