tencent cloud

Application Load Balancer

Configuring a Forwarding Rule

Download
Focus Mode
Font Size
Last updated: 2026-09-28 16:39:10
AI-Translated
A forwarding rule is used to define how an Application Load Balancer (ALB) listener handles client requests.
After you create a listener, the system creates a default forwarding rule for it. You can manually add multiple forwarding rules for the listener to route client requests with different characteristics to different backend target groups based on specified conditions, achieving fine-grained traffic distribution based on the content.
This document describes how to create, edit, and delete a forward rule and how to adjust the rule priority.

Forwarding Rule Description

Each forwarding rule consists of the following 2 parts: a forwarding condition and a forwarding action. The forwarding condition matches client requests, and the forwarding action defines how to process requests after a successful match.

Default Forwarding Rule

After you create a listener, the system creates a default forwarding rule for it. The forwarding action of this rule is used to forward requests to the target group configured when the listener was created.
The default forwarding rule cannot be deleted, but its forwarding action (for example, changing the target group) can be modified.
The default forwarding rule has the lowest priority, and its priority cannot be adjusted.
When a client request does not match any custom forwarding rule, it is forwarded based on the default forwarding rule.

Matching Principle

Client requests are matched against forwarding rules one by one in order of their priorities. A smaller priority value indicates a higher priority.
When a request matches a forwarding rule, ALB immediately performs the forwarding action defined by the rule and stops matching subsequent rules.
When a request does not match any custom forwarding rule, it is forwarded based on the default forwarding rule.
Note:
ALB matches forwarding rules strictly in ascending order of priority values. It does not automatically sort rules based on the specificity of domain names or paths. To make a more specific rule match first, manually set its priority value to a smaller number (placing it in a higher position).

Prerequisites

An ALB instance has been created. If it is not created, create one by referring to Creating an ALB Instance.
An HTTP or HTTPS listener has been created for the ALB instance. If it is not created, create one by referring to Creating and Managing a Listener.
A target group has been created, and backend services have been added to it. If it is not created, create one by referring to Creating and Managing a Target Group. The forwarding action requires routing requests to a target group. Therefore, prepare a target group first.

Creating a Forwarding Rule

1. Log in to the ALB console and choose ALB > Instance Management in the left sidebar.
2. Select a region above the instance list, locate the target instance, and click the instance ID/name to go to the instance details page.
3. Select the Listener Management tab, locate the target listener, and click it to go to the listener details page.
4. Select the Forwarding Rules tab and click Create Forwarding Rule. Alternatively, click Configure Forwarding Rule in the Operation column.
5. In the Create Forwarding Rule dialog box, configure rule information based on the table below. After the configuration is completed, click OK.
Configuration Item
Description
Rule Name
Enter the name of a forwarding rule, which cannot exceed 255 characters. The value can contain characters such as digits, letters, Chinese characters, hyphens, underscores, and periods. If it is left empty, the system automatically generates a name.
Forwarding Condition
Set a matching condition for requests. Traffic is forwarded only when all conditions are met.
Select Condition Type from the drop-down list and enter the corresponding value. Click + Add Condition to add multiple conditions.
Note:
Up to 10 forwarding conditions are supported.
For details about each condition type, see Forwarding Conditions.
Forwarding Action
Set the action to be performed on a request after a successful match. Traffic is forwarded when any action is performed.
Select Action Type from the drop-down list and complete the configuration. Click + Add Action to add multiple actions.
Note:
Up to 5 forwarding actions are supported.
For details about each action type, see Forwarding Actions.
Priority
Set the order in which forwarding rules take effect within a listener. The value range is 1–10000. A smaller value indicates a higher priority.
Priorities must be unique within the same listener.
You can click View Existing Listener Rule to expand the priorities and rule IDs of existing rules under the current listener, facilitating rational planning and avoiding conflicts.

Forwarding Conditions

A forwarding rule can be configured with one or more forwarding conditions (up to 10). The conditions follow the logic below:
Conditions of different types are combined by using an "AND" relationship: For example, if both a domain name condition and a path condition are configured for the same rule, requests can match the rule only when the domain name and path conditions are simultaneously met.
Multiple values for the same type of condition are combined by using an "OR" relationship: For example, if multiple domain name values are added to a domain name condition, the domain name condition is met when the request domain name matches any one of them.
Forwarding conditions support the following 7 types:
Condition Type
Description
Domain name
Matching based on the domain name in the client request.
It supports exact matching, wildcard matching, and regular expression matching (case-insensitive).
It can contain 3 to 128 characters.
It supports characters such as letters (a–z), digits (0–9), hyphens (-), underscores (_), periods (.), and commas (,).
Path
Matching based on the URL path in the client request.
It supports exact matching, wildcard matching, regular expression matching (case-insensitive), and regular expression matching (case-sensitive).
It can contain up to 128 characters and supports exact matching starting with a forward slash (/).
HTTP Header
Matching based on the key-value pairs in the request HTTP headers.
Enter the header name in the Key field and the header content in the Value field. You can add one or more header key-value pairs.
A key can contain 1 to 40 characters, including letters, digits, and underscores, but cannot be Host/Cookie.
A value can contain up to 128 characters, excluding double quotation marks. It cannot start or end with a space.
Query String
Matching based on the key-value pairs in the request URL's Query String. You can add one or more key-value pairs.
A key can contain 1 to 16 characters, excluding upper letters, spaces, and the following special characters: #[]{}\\
A value can contain up to 128 characters, excluding spaces and the following special characters: #[]{}\\|<>&
HTTP Request Method
Matching based on the HTTP method of the request. Supported methods include HEAD, GET, POST, OPTIONS, PUT, PATCH, and DELETE.
Cookie
Matching based on the key-value pairs in the cookies carried by the request. You can add one or more key-value pairs.
A key can contain 1 to 64 characters, including lowercase letters, digits, underscores, and hyphens.
A value can be up to 128 characters, excluding uppercase letters, control characters, semicolons, commas, spaces, quotation marks, or backslashes.
SourceIp
Matching based on the source IP address or IP range of the client. You can add one or more IP addresses/IP ranges.
It supports the IPv4 CIDR format.
It supports /24 and /32.
It does not support 0.0.0.0/x.

Forwarding Actions

When forwarding conditions are met, one or more configured forwarding actions are executed. The following 6 types of forwarding actions are supported:
Action Type
Description
Forwarding to
Forwards matched requests to the specified backend target group. You can select one or more target groups and control the traffic distribution ratio by setting the weight for each target group.
Redirecting to
Redirects requests to a specified protocol, domain name, port, path, query, and status code.
Returning a fixed response
Returns a fixed-response status code and response body from ALB directly to the client, instead of forwarding them to the backend.
The response status code must be within the range of 200–299 or 400–599.
The response body type, supporting text/plain, text/css, text/html, application/javascript, and application/json. It only supports ASCII characters and has a maximum size of 1 KB.
Rewriting
Rewrites the domain name, path, and other elements of a request to specified values within ALB before the request is forwarded to the backend, while the URL in the client browser's address bar remains unchanged.
Writing a header
Writes the specified HTTP header fields (key-value pairs) into the request.
A key can contain 1–40 characters, including letters, digits, underscores, and hyphens.
A value can be user-specified, referenced, or system-defined and can contain up to 128 characters, excluding double quotation marks. It cannot start or end with a space.
Deleting a header
Deletes the HTTP header field with the specified name from the request. It can contain 1–40 characters, including letters, digits, underscores, and hyphens.

Editing a Forwarding Rule

1. Go to the target listener details page and select the Forwarding Rules tab.
2. Locate the target forwarding rule and click Edit in the Operation column.
3. In the Edit dialog box, modify information such as Forwarding Conditions and Forwarding Actions or Priority. After the modification is completed, click OK to complete the editing operation.
Attention:
Editing forwarding rules may affect the forwarding paths of existing service traffic. It is recommended that you perform this operation during off-peak hours and conduct sufficient evaluation and testing before making changes.
The default forwarding rule only allows modifications to its forwarding action (for example, changing the target group). Modifications to its forwarding conditions and priority are not allowed.

Deleting Forwarding Rules

1. Go to the target listener details page and select the Forwarding Rules tab.
2. Select one or more forwarding rules to be deleted and click Delete above the list.
3. In the displayed Confirm dialog box, confirm that the information is correct, and click OK to complete the deletion.
Attention:
After a forwarding rule is deleted, requests that originally matched the rule are matched again and forwarded based on the remaining rules or the default rule. You need to make sure that this operation does not affect online services before proceeding.
The default forwarding rule cannot be deleted.


Help and Support

Was this page helpful?

Help us improve! Rate your documentation experience in 5 mins.

Feedback