All Products
Search
Document Center

Server Load Balancer:ListRules

Last Updated:Oct 10, 2025

This operation queries the forwarding rules in a specified region.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

alb:ListRules

get

*LoadBalancer

acs:alb:{#regionId}:{#accountId}:loadbalancer/{#loadbalancerId}

None None

Request parameters

Parameter

Type

Required

Description

Example

NextToken

string

No

The token that is used to retrieve the next page of results. Valid values:

  • You do not need to set this parameter for the first query.

  • For a subsequent query, set this parameter to the value of NextToken from the previous response.

FFmyTO70tTpLG6I3FmYAXGKPd****

MaxResults

integer

No

The maximum number of entries to return.

Valid values: 1 to 100.

Default value: 20.

Note

This parameter is optional.

20

RuleIds

array

No

The IDs of the forwarding rules. You can specify up to 20 forwarding rule IDs.

string

No

The forwarding rule ID.

rule-sada******

ListenerIds

array

No

The listener IDs. You can specify up to 20 listener IDs.

string

No

The listener ID.

lsn-i35udpz3pxsmnf****

LoadBalancerIds

array

No

The SLB instance IDs. You can specify up to 20 instance IDs.

string

No

The SLB instance ID.

alb-x30o38azsuj0sx****

Direction

string

No

The direction of the forwarding rule. Valid values:

  • Request (default): The forwarding rule is applied to requests. Application Load Balancer (ALB) matches conditions in the requests sent from clients and performs the specified actions.

  • Response: The forwarding rule is applied to responses. ALB matches conditions in the responses sent from backend servers and performs the specified actions.

Note

Basic ALB instances do not support the Response type.

Request

Tag

array<object>

No

The tags.

object

No

The tag.

Key

string

No

The tag key. The tag key can be up to 128 characters in length. It cannot start with `aliyun` or `acs:`, and cannot contain `http://` or `https://`.

env

Value

string

No

The tag value. The tag value can be up to 128 characters in length. It cannot start with `aliyun` or `acs:`, and cannot contain `http://` or `https://`.

product

Response elements

Element

Type

Description

Example

object

The forwarding rules.

MaxResults

integer

The maximum number of entries returned per page.

50

NextToken

string

The token that is used to retrieve the next page of results. Valid values:

  • If NextToken is empty, no more results are returned.

  • If NextToken has a value, it is the token for the next query.

FFmyTO70tTpLG6I3FmYAXGKPd****

RequestId

string

The request ID.

CEF72CEB-54B6-4AE8-B225-F876F******

Rules

array<object>

The list of forwarding rules.

object

The forwarding rule.

ListenerId

string

The ID of the listener to which the forwarding rule belongs.

lsn-i35udpz3pxsmnf****

LoadBalancerId

string

The ID of the SLB instance to which the forwarding rule belongs.

alb-x30o38azsuj0sx****

Priority

integer

The priority of the rule. A smaller value indicates a higher priority. Valid values: 1 to 10000.

Note

The priority of each rule must be unique within a listener.

1

RuleActions

array<object>

The actions of the forwarding rule.

object

The action of the forwarding rule.

FixedResponseConfig

object

The configuration of the fixed response.

Content

string

The fixed response. The response can be up to 1 KB in length and can contain only ASCII characters.

dssacav

ContentType

string

The format of the fixed response.

Valid values: text/plain, text/css, text/html, application/javascript, and application/json.

text/plain

HttpCode

string

The HTTP status code of the response. Only HTTP_2xx, HTTP_4xx, and HTTP_5xx are supported. x is a digit.

HTTP_2xx

ForwardGroupConfig

object

The configuration of the forwarding group.

ServerGroupTuples

array<object>

The destination server groups.

object

The destination server group.

ServerGroupId

string

The ID of the destination server group.

sgp-atstuj3rtoptyui****

Weight

integer

The weight. Valid values: 0 to 100.

2

ServerGroupStickySession

object

The session persistence settings for the server groups.

Enabled

boolean

Specifies whether to enable session persistence among server groups. This parameter is available when multiple server groups are specified in `ServerGroupTuples`.

true

Timeout

integer

The timeout period for session persistence. This parameter is available when `Enabled` is set to `true`.

100

InsertHeaderConfig

object

The configuration of the header to be inserted.

Key

string

The key of the header to be inserted. The key must be 1 to 40 characters in length. It can contain letters, digits, underscores (_), and hyphens (-). The header key in InsertHeader cannot be the same as the key of a header that has been inserted.

Note

You cannot set the key to Cookie or Host.

key

Value

string

The value of the header to be inserted.

  • ValueType is set to SystemDefined, you can set the value to:
    • ClientSrcPort: the client port.

    • ClientSrcIp: the client IP address.

    • Protocol: the protocol of the client request (HTTP or HTTPS).

    • SLBId: the ID of the Application Load Balancer instance.

    • SLBPort: the listening port of the Application Load Balancer instance.

  • If ValueType is set to UserDefined: you can specify a custom header value. The value must be 1 to 128 characters in length. It can contain printable characters with ASCII values from ch >= 32 && ch < 127. It can also contain wildcard characters, including asterisks (*) and question marks (?). The value cannot start or end with a space.

  • If ValueType is set to ReferenceHeader: you can reference a field in the request header. The value must be 1 to 128 characters in length. It can contain lowercase letters, digits, hyphens (-), and underscores (_).

ClientSrcPort

ValueType

string

The type of the header value. Valid values:

  • UserDefined: a user-defined value.

  • ReferenceHeader: a value that is referenced from a field in the request header.

  • SystemDefined: a system-defined value.

SystemDefined

Order

integer

The order of the action. Valid values: 1 to 50000. A smaller value indicates a higher priority. The value of this parameter cannot be the same as the value of Order for other actions of the same rule.

1

RedirectConfig

object

The configuration of the redirection.

Host

string

The destination host to which requests are redirected. Valid values:

  • ${host} (default): If you set the value to ${host}, you cannot add other characters to the value.

  • A value that meets the following requirements:
    • The host must be 3 to 128 characters in length. It can contain lowercase letters, digits, hyphens (-), periods (.), asterisks (*), and question marks (?).

    • The host must contain at least one period (.). A period (.) cannot be the first or last character.

    • The rightmost domain label can contain only letters and wildcard characters. It cannot contain digits or hyphens (-).

    • The domain labels cannot start or end with a hyphen (-).

    • You can use asterisks (*) and question marks (?) anywhere in a domain label.

www.example.com

HttpCode

string

The redirection method. Valid values: 301, 302, 303, 307, and 308.

301

Path

string

The destination path to which requests are redirected. Valid values:

  • ${path} (default): You can reference ${host}, ${protocol}, and ${port}. Each variable can be used at most once. You can use these variables together or combine them with a string.

  • A value that meets the following requirements:
    • The value must be 1 to 128 characters in length.

    • It must start with a forward slash (/). It can contain letters, digits, and the following special characters: $-_.+/&~@:. It cannot contain the following special characters: “%#;!()[]^,” . It can contain asterisks (*) and question marks (?).

/test

Port

string

The destination port to which requests are redirected. Valid values:

  • ${port} (default): If you set the value to ${port}, you cannot add other characters to the value.

  • 1 to 63335.

10

Protocol

string

The destination protocol to which requests are redirected. Valid values:

  • ${protocol} (default): If you set the value to ${protocol}, you cannot add other characters to the value.

  • HTTP or HTTPS.

Note

HTTPS listeners support only HTTPS.

HTTP

Query

string

The query string of the destination to which requests are redirected. The query string must be 1 to 128 characters in length. It can contain lowercase letters and printable characters. It cannot contain #[]{}\|<>&.

quert

RemoveHeaderConfig

object

The configuration for removing a header.

Key

string

The key of the header to be removed. The key must be 1 to 40 characters in length. It can contain letters, digits, underscores (_), and hyphens (-). The header key in RemoveHeader cannot be the same as the key of a header that has been removed.

  • If Direction is set to Request, you cannot remove the following headers (case-insensitive): slb-id, slb-ip, x-forwarded-for, x-forwarded-proto, x-forwarded-eip, x-forwarded-port, x-forwarded-client-srcport, connection, upgrade, content-length, transfer-encoding, keep-alive, te, host, cookie, remoteip, and authority.

  • If Direction is set to Response, you cannot remove the following headers (case-insensitive): connection, upgrade, content-length, and transfer-encoding.

key

RewriteConfig

object

The configuration of the rewrite.

Host

string

The destination host to which requests are redirected. Valid values:

  • ${host} (default): If you set the value to ${host}, you cannot add other characters to the value.

  • A value that meets the following requirements:
    • The host must be 3 to 128 characters in length. It can contain lowercase letters, digits, hyphens (-), periods (.), asterisks (*), and question marks (?).

    • The host must contain at least one period (.). A period (.) cannot be the first or last character.

    • The rightmost domain label can contain only letters and wildcard characters. It cannot contain digits or hyphens (-).

    • The domain labels cannot start or end with a hyphen (-).

    • You can use asterisks (*) and question marks (?) anywhere in a domain label.

www.example.com

Path

string

The destination path to which requests are redirected. The path must be 1 to 128 characters in length. It must start with a forward slash (/). It can contain letters, digits, asterisks (*), question marks (?), and the following special characters: $-_.+/&~@:. It cannot contain “%#;!()[]^,” .

/tsdf

Query

string

The query string of the destination to which requests are redirected. The query string must be 1 to 128 characters in length. It can contain lowercase letters and printable characters. It cannot contain #[]{}\|<>&.

quedsa

TrafficMirrorConfig

object

The configuration of traffic mirroring.

TargetType

string

The destination of traffic mirroring. The value can be `ForwardGroupMirror`.

ForwardGroupMirror

MirrorGroupConfig

object

The server group to which traffic is mirrored.

ServerGroupTuples

array<object>

The server groups to which traffic is mirrored.

object

ServerGroupId

string

The server group ID.

sgp-00mkgijak0w4qgz9****

Weight

integer

The weight. Valid values: 0 to 100.

2

TrafficLimitConfig

object

The configuration of throttling.

QPS

integer

The queries per second (QPS). Valid values: 1 to 100000.

4

PerIpQps

integer

The QPS of a single IP address. Valid values: 1 to 100000.

Note

If you set both QPS and PerIpQps, the value of PerIpQps must be smaller than the value of QPS.

80

Type

string

The type of the action. Valid values:

  • ForwardGroup: forwards requests to multiple vServer groups.

  • Redirect: redirects requests.

  • FixedResponse: returns a fixed response.

  • Rewrite: rewrites a request.

  • InsertHeader: inserts a header.

  • RemoveHeaderConfig: removes a header.

  • TrafficLimitConfig: throttles traffic.

  • TrafficMirrorConfig: mirrors traffic.

  • CorsConfig: enables cross-origin resource sharing (CORS).

ForwardGroup

CorsConfig

object

The CORS configuration.

AllowOrigin

array

The allowed origins.

string

The allowed origins. You can set the value to * or specify one or more values. The value cannot be *.

  • A value must start with http:// or https://, followed by a valid domain name or a level-1 wildcard domain name, such as *.test.abc.example.com.

  • You can specify a port or not. The port number must be within the range of 1 to 65535.

http://test.com

AllowMethods

array

The allowed HTTP methods for cross-origin requests.

string

The allowed HTTP methods for cross-origin requests. Valid values:

  • GET

  • POST

  • PUT

  • DELETE

  • HEAD

  • OPTIONS

  • PATCH

GET

AllowHeaders

array

The allowed headers for cross-origin requests.

string

The allowed headers for cross-origin requests. You can set the value to * or specify one or more values. Multiple values are separated by commas (,). A value can contain letters, digits, and the following special characters: underscores (_) and hyphens (-). An underscore (_) or a hyphen (-) cannot be the first or last character. The value can be up to 32 characters in length.

test_123

ExposeHeaders

array

The headers that can be exposed to the browser.

string

The headers that can be exposed to the browser. You can set the value to * or specify one or more values. Multiple values are separated by commas (,). A value can contain letters, digits, and the following special characters: underscores (_) and hyphens (-). An underscore (_) or a hyphen (-) cannot be the first or last character. The value can be up to 32 characters in length.

test_123

AllowCredentials

string

Specifies whether the browser can send credentials. Valid values:

  • on

  • off

on

MaxAge

integer

The maximum cache time of preflight requests in the browser. Unit: seconds.

Valid values: -1 to 172800.

1000

RuleConditions

array<object>

The conditions of the forwarding rule.

object

The condition of the forwarding rule.

CookieConfig

object

The configuration of the cookie.

Values

array<object>

The cookie values.

object

The cookie value.

Key

string

The key of the cookie. The key must be 1 to 100 characters in length. It can contain lowercase letters, printable characters, asterisks (*), and question marks (?). It cannot contain spaces or the following special characters: #[]{}\|<>&.

test

Value

string

The value of the cookie. The value must be 1 to 128 characters in length. It can contain lowercase letters, printable characters, asterisks (*), and question marks (?). It cannot contain spaces or the following special characters: #[]{}\|<>&.

test

HeaderConfig

object

The configuration of the header.

Key

string

The key of the header. The key must be 1 to 40 characters in length. It can contain letters, digits, hyphens (-), and underscores (_). You cannot set the key to Cookie or Host.

Port

Values

array

The header values.

string

The value of the header. The value must be 1 to 128 characters in length. It can contain printable characters with ASCII values from ch >= 32 && ch < 127, lowercase letters, asterisks (*), and question marks (?). The value cannot start or end with a space.

5006

HostConfig

object

The configuration of the host.

Values

array

The hostnames.

string

The hostname. Naming conventions:

  • The domain name must be 3 to 128 characters in length. It can contain lowercase letters, digits, hyphens (-), periods (.), asterisks (*), and question marks (?).

  • The domain name must contain at least one period (.). A period (.) cannot be the first or last character.

  • The rightmost domain label can contain only letters, asterisks (*), and question marks (?). It cannot contain digits or hyphens (-).

  • The other domain labels cannot start or end with a hyphen (-). You can use asterisks (*) and question marks (?) anywhere in a domain label.

www.example.com

MethodConfig

object

The configuration of the request method.

Values

array

The request methods.

string

The request method.

Valid values: HEAD, GET, POST, OPTIONS, PUT, PATCH, and DELETE.

PUT

PathConfig

object

The configuration of the path.

Values

array

The paths.

string

The path. The path must be 1 to 128 characters in length. It must start with a forward slash (/). It can contain letters, digits, asterisks (*), question marks (?), and the following special characters: $-_.+/&~@:. It cannot contain “%#;!()[]^,” .

/test

QueryStringConfig

object

The configuration of the query string.

Values

array<object>

The query strings.

object

The query string.

Key

string

The key of the query string. The key must be 1 to 100 characters in length. It can contain lowercase letters, printable characters, asterisks (*), and question marks (?). It cannot contain spaces or the following special characters: #[]{}\|<>&.

test

Value

string

The value of the query string. The value must be 1 to 128 characters in length. It can contain lowercase letters, printable characters, asterisks (*), and question marks (?). It cannot contain spaces or the following special characters: #[]{}\|<>&.

test

SourceIpConfig

object

The configuration of the source IP address.

Values

array

The source IP addresses to match.

string

Specify one or more IP addresses or CIDR blocks.

You can specify up to five source IP addresses for each forwarding rule.

192.168.XX.XX/32

ResponseStatusCodeConfig

object

The configuration of the response status code.

Values

array

The response status codes.

string

The response status code.

200

ResponseHeaderConfig

object

The configuration of the response HTTP header.

Key

string

The key of the response HTTP header. The key must be 1 to 40 characters in length. It can contain letters, digits, hyphens (-), and underscores (_). You cannot set the key to Cookie or Host.

key

Values

array

The values of the response HTTP header.

string

The value of the response HTTP header. The value must be 1 to 128 characters in length.

value

Type

string

The type of the forwarding rule. Valid values:

  • Host: a host.

  • Path: a path.

  • Header: an HTTP header.

  • QueryString: a query string.

  • Method: a request method.

  • Cookie: a cookie.

  • SourceIp: a source IP address.

Host

RuleId

string

The forwarding rule ID.

rule-bpn0kn908w4nbw****

RuleName

string

The name of the forwarding rule. The name must be 2 to 128 characters in length, start with a letter or a Chinese character, and can contain letters, digits, periods (.), underscores (_), and hyphens (-).

rule-instance-test

RuleStatus

string

The status of the forwarding rule. Valid values:

  • Provisioning: The rule is being created.

  • Configuring: The rule is being modified.

  • Available: The rule is running.

Available

Direction

string

The direction of the forwarding rule. Valid values:

  • Request (default): The forwarding rule is applied to requests. ALB matches conditions in the requests sent from clients and performs the specified actions.

  • Response: The forwarding rule is applied to responses. ALB matches conditions in the responses sent from backend servers and performs the specified actions.

Note

Basic ALB instances do not support the Response type.

Request

Tags

array<object>

The tags.

object

The tag.

Key

string

The tag key. The tag key can be up to 128 characters in length. It cannot start with `aliyun` or `acs:`, and cannot contain `http://` or `https://`.

env

Value

string

The tag value. The tag value can be up to 128 characters in length. It cannot start with `aliyun` or `acs:`, and cannot contain `http://` or `https://`.

product

TotalCount

integer

The total number of entries returned.

1000

Examples

Success response

JSON format

{
  "MaxResults": 50,
  "NextToken": "FFmyTO70tTpLG6I3FmYAXGKPd****",
  "RequestId": "CEF72CEB-54B6-4AE8-B225-F876F******",
  "Rules": [
    {
      "ListenerId": "lsn-i35udpz3pxsmnf****",
      "LoadBalancerId": "alb-x30o38azsuj0sx****",
      "Priority": 1,
      "RuleActions": [
        {
          "FixedResponseConfig": {
            "Content": "dssacav",
            "ContentType": "text/plain",
            "HttpCode": "HTTP_2xx"
          },
          "ForwardGroupConfig": {
            "ServerGroupTuples": [
              {
                "ServerGroupId": "sgp-atstuj3rtoptyui****",
                "Weight": 2
              }
            ],
            "ServerGroupStickySession": {
              "Enabled": true,
              "Timeout": 100
            }
          },
          "InsertHeaderConfig": {
            "Key": "key",
            "Value": "ClientSrcPort",
            "ValueType": "SystemDefined"
          },
          "Order": 1,
          "RedirectConfig": {
            "Host": "www.example.com",
            "HttpCode": "301",
            "Path": "/test",
            "Port": "10",
            "Protocol": "HTTP",
            "Query": "quert"
          },
          "RemoveHeaderConfig": {
            "Key": "key"
          },
          "RewriteConfig": {
            "Host": "www.example.com",
            "Path": "/tsdf",
            "Query": "quedsa"
          },
          "TrafficMirrorConfig": {
            "TargetType": "ForwardGroupMirror",
            "MirrorGroupConfig": {
              "ServerGroupTuples": [
                {
                  "ServerGroupId": "sgp-00mkgijak0w4qgz9****",
                  "Weight": 2
                }
              ]
            }
          },
          "TrafficLimitConfig": {
            "QPS": 4,
            "PerIpQps": 80
          },
          "Type": "ForwardGroup",
          "CorsConfig": {
            "AllowOrigin": [
              "http://test.com"
            ],
            "AllowMethods": [
              "GET"
            ],
            "AllowHeaders": [
              "test_123"
            ],
            "ExposeHeaders": [
              "test_123"
            ],
            "AllowCredentials": "on",
            "MaxAge": 1000
          }
        }
      ],
      "RuleConditions": [
        {
          "CookieConfig": {
            "Values": [
              {
                "Key": "test",
                "Value": "test"
              }
            ]
          },
          "HeaderConfig": {
            "Key": "Port",
            "Values": [
              "5006"
            ]
          },
          "HostConfig": {
            "Values": [
              "www.example.com"
            ]
          },
          "MethodConfig": {
            "Values": [
              "PUT"
            ]
          },
          "PathConfig": {
            "Values": [
              "/test"
            ]
          },
          "QueryStringConfig": {
            "Values": [
              {
                "Key": "test",
                "Value": "test"
              }
            ]
          },
          "SourceIpConfig": {
            "Values": [
              "192.168.XX.XX/32"
            ]
          },
          "ResponseStatusCodeConfig": {
            "Values": [
              "200"
            ]
          },
          "ResponseHeaderConfig": {
            "Key": "key",
            "Values": [
              "value"
            ]
          },
          "Type": "Host"
        }
      ],
      "RuleId": "rule-bpn0kn908w4nbw****",
      "RuleName": "rule-instance-test",
      "RuleStatus": "Available",
      "Direction": "Request",
      "Tags": [
        {
          "Key": "env",
          "Value": "product"
        }
      ]
    }
  ],
  "TotalCount": 1000
}

Error codes

HTTP status code

Error code

Error message

Description

403 Forbidden.LoadBalancer Authentication is failed for %s. Authentication is failed for %s.

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.