This topic describes how to configure forwarding rules for listeners that are created for an Application Load Balancer (ALB ) instance. The forwarding rules that you configure for a listener defines how requests are routed to the backend servers in a server group.ALB

Background information

You can configure an inbound or outbound forwarding rule for listeners created for an ALB instance. A forwarding rule defines one or more conditions and corresponding actions. Traffic diagram
Note The outbound forwarding rule supported regions see Release notes.
  • The client sends a request to the ALB instance. The ALB instance routes the request to a backend server based on the specified inbound forwarding rule. The backend server returns the response to the client based on the outbound forwarding rule configured for the ALB instance.
    • In an inbound forwarding rule, you can configure only inbound conditions and actions corresponding to the conditions.
    • In an outbound forwarding rule, you can configure both inbound and outbound conditions. However, you can configure only actions corresponding to the outbound conditions.
  • You must specify at least a Forward action, a Redirect action, or a Return Fixed Responses action when you configure a forwarding rule.
    • You can specify the following inbound conditions: Domain Name, Path, HTTP Header, Query String, HTTP Request Method, Cookie, and Source IP Address.
    • You can specify the following actions corresponding to inbound conditions: Forward, Redirect, Return Fixed Responses, Rewrite, Add Header, Remove Header, Throttle Traffic, and Mirror Traffic.
    • You can specify the following outbound conditions: Response Status Code and Response Header.
    • You can specify the following actions corresponding to outbound conditions: Add Header and Remove Header.
  • Before you create a forwarding rule, you must create a server group and add backend servers to the server group. For more information, see Manage server groups.

Create a forwarding rule

You can specify the default forwarding rule for a listener when you create the listener or create custom forwarding rules after the listener is created.

  1. Log on to the ALB console.
  2. On the Instances page, click the ID of the ALB instance that you want to manage.
  3. On the Listener tab, click View/Modify Forwarding Rule in the Actions column corresponding to the listener for which you want to create forwarding rules.
  4. On the Forwarding Rules tab, select Inbound Forwarding Rules or Outbound Forwarding Rules and then click Add New Rule.
  5. In the Add Forwarding Rules panel, configure the parameters and click OK. The following table describes the parameters that you can configure.
    Note
    • The logical relation among the values of a condition is OR. A request is forwarded if the request matches any of the valid values of a condition.
    • The logical relation among different conditions is AND. A request is forwarded only when the request matches all conditions in the forwarding rule.
    Parameter Description
    Name Enter a name for the forwarding rule.
    Note The name must be 2 to 128 characters in length, and can contain letters, digits, periods (.), underscores (_), and hyphens (-). The name must start with a letter.
    Add Inbound Condition Specify one or more of the following conditions:
    • Domain Name: Add one or more domain names. Example: *.example.com. The domain name must be 3 to 128 characters in length and can contain letters, digits, hyphens (-), and periods (.). Wildcard domain names that contain asterisks (*) and question marks (?) are supported.
    • Path: Enter one or more paths. Example:
    • HTTP Header: Enter the name of the HTTP header in the Key field and the content of the HTTP header in the Value field.
    • Query String: Add one or more query strings, which are key-value pairs.
      Note The value of a query string must be 1 to 128 characters in length and can contain lowercase letters, printable characters, and wildcards including asterisks (*) and question marks (?). The value of a query string cannot contain spaces or the following special characters: # [ ] { } \ | < > &.
    • HTTP Request Method: Add one or more HTTP request methods.
    • Cookie: Add one or more cookies.
      Note The key of a cookie must be 1 to 100 characters in length and can contain lowercase letters, printable characters, and wildcards including asterisks (*) and question marks (?). The key of a cookie cannot contain spaces or the following special characters: # [ ] { } \ | < > &. The value of a cookie must be 1 to 128 characters in length and can contain lowercase letters, printable characters, and wildcards including asterisks (*) and question marks (?). The value of a cookie cannot contain spaces or the following special characters: # [ ] { } \ | < > &.
    • Source IP Address: Add one or more IP addresses or CIDR blocks.
    Add Outbound Condition Specify one or more of the following conditions:
    • Response Status Code: Specify the HTTP status code contained in the response to the client. Valid values: 100 to 599.

      You can enter multiple values by range and separate the values with commas (,). Example: 200-233,301.

    • Response Header: Specify the HTTP headers contained in the response. Enter the name of the HTTP header in the Key field and the content of the HTTP header in the Value field. You can specify multiple HTTP headers.
    Action Specify one of the following actions for each condition:
    • Forward: Select the server group that you want to manage from the drop-down list. You can add multiple server groups and enable Session Persistence for Server Groups.
    • Redirect: Select a protocol from the Protocol drop-down list, and then select a status code from the Status Code drop-down list. Enter the Domain Name, Port, and Path of the destination to which requests are directed, and then enter a query string in the Query field.
    • Return Fixed Responses: Enter a HTTP status code in the Status Code field, select a Response Content Type, and then enter the Response Content.
    • Rewrite: Enter the Domain Name and Path of the destination to which requests are directed, and then enter a query string in the Query field.
    • Add Header: Enter the name and the content of the header that you want to add to the request. The added header overwrites the existing headers in the request.
    • Remove Header: Enter the content of the header that you want to remove from the request.
    • Throttle Traffic: Enter the maximum number of requests per second. Valid values: 1 to 100000. When the QPS of requests reaches the specified limit, new connection requests are dropped.
    • Mirror Traffic: Select the server group from the drop-down list.
    Note Basic Edition ALB instances support only the Forward and Add Header actions.

Modify a forwarding rule

You can modify a forwarding rule at any time.

  1. Log on to the ALB console.
  2. On the Instances page, click the ID of the ALB instance that you want to manage.
  3. On the Listener tab, click View/Modify Forwarding Rule in the Actions column corresponding to the listener for which you want to create forwarding rules.
  4. On the Forwarding Rules tab, select Inbound Forwarding Rules or Outbound Forwarding Rules and then click the 编辑 icon on the right side of the forwarding rule that you want to modify.
  5. Click Save.

Modify the priority of a forwarding rule

Forwarding rules are evaluated in descending order of priority. A lower number indicates a higher priority. You can modify the priority of a custom forwarding rule at any time. The priority of the default forwarding rule cannot be modified.

  1. Log on to the ALB console.
  2. On the Instances page, click the ID of the ALB instance that you want to manage.
  3. On the Listener tab, click View/Modify Forwarding Rule in the Actions column corresponding to the listener for which you want to create forwarding rules.
  4. On the Forwarding Rules tab, select Inbound Forwarding Rules or Outbound Forwarding Rules, move the position of the forwarding rule that you want to modify, and then click Save Priority Changes.

Delete a forwarding rule

You can delete the custom forwarding rules of a listener at any time. The default forwarding rule of a listener cannot be deleted. If you delete a listener, all forwarding rules of the listener are deleted.

  1. Log on to the ALB console.
  2. On the Instances page, click the ID of the ALB instance that you want to manage.
  3. On the Listener tab, click View/Modify Forwarding Rule in the Actions column corresponding to the listener for which you want to create forwarding rules.
  4. On the Forwarding Rules tab, select Inbound Forwarding Rules or Outbound Forwarding Rules and then click the 删除 icon on the right side of the forwarding rule that you want to delete.
  5. In the message that appears, click OK.