All Products
Search
Document Center

Server Load Balancer:ListRules

Last Updated:Jun 18, 2024

Queries the forwarding rules in a region.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer.

Authorization information

The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:

  • Operation: the value that you can use in the Action element to specify the operation on a resource.
  • Access level: the access level of each operation. The levels are read, write, and list.
  • Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
    • The required resource types are displayed in bold characters.
    • If the permissions cannot be granted at the resource level, All Resources is used in the Resource type column of the operation.
  • Condition Key: the condition key that is defined by the cloud service.
  • Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
OperationAccess levelResource typeCondition keyAssociated operation
alb:ListRulesRead
  • LoadBalancer
    acs:alb:{#regionId}:{#accountId}:loadbalancer/{#loadbalancerId}
    none
none

Request parameters

ParameterTypeRequiredDescriptionExample
NextTokenstringNo

The starting point of the current query. If you do not specify this parameter, the query starts from the beginning.

FFmyTO70tTpLG6I3FmYAXGKPd****
MaxResultsintegerNo

The maximum number of entries to return.

Valid values: 1 to 100.

Default value: 20. If you do not specify this parameter, the default value is used.

Note This parameter is optional.
20
RuleIdsarrayNo

The forwarding rules.

stringNo

The forwarding rule ID. You can specify up to 20 IDs in each request.

rule-sada
ListenerIdsarrayNo

The listener IDs.

stringNo

The listener ID. You can specify up to 20 IDs in each request.

lsn-i35udpz3pxsmnf****
LoadBalancerIdsarrayNo

The Application Load Balancer (ALB) instance IDs.

stringNo

The ALB instance ID. You can specify up to 20 IDs in each request.

alb-x30o38azsuj0sx****
DirectionstringNo

The direction to which the forwarding rule is applied. Valid values:

  • Request (default): The forwarding rule is applied to the client requests received by ALB.
  • Response: The forwarding rule is applied to the responses returned by backend servers.
Note You cannot set this parameter to Response if you use basic ALB instances.
Request
Tagobject []No

The tag.

KeystringNo

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
ValuestringNo

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 parameters

ParameterTypeDescriptionExample
object

The forwarding rules.

MaxResultsinteger

The maximum number of entries returned.

50
NextTokenstring

A pagination token. It can be used in the next request to retrieve a new page of results. Valid values:

  • If NextToken is empty, no next page exists.
  • If a value is returned for NextToken, the value is the token that determines the start point of the next query.
FFmyTO70tTpLG6I3FmYAXGKPd****
RequestIdstring

The request ID.

CEF72CEB-54B6-4AE8-B225-F876FF7BA984
Rulesobject []

The details about the forwarding rule.

ListenerIdstring

The ID of the listener that is associated with the forwarding rule.

lsn-i35udpz3pxsmnf****
LoadBalancerIdstring

The ID of the Application Load Balancer (ALB) instance that is associated with the forwarding rule.

alb-x30o38azsuj0sx****
Priorityinteger

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

Note The priority of each forwarding rule added to a listener must be unique.
1
RuleActionsobject []

The action of the forwarding rule.

FixedResponseConfigobject

The configuration of the custom response.

Contentstring

The content of the custom response. The content can be up to 1 KB in size, and can contain only ASCII characters.

dssacav
ContentTypestring

The format of the response.

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

text/plain
HttpCodestring

The HTTP status code in responses. Valid values: HTTP_2xx, HTTP_4xx, and HTTP_5xx. x is a digit.

HTTP_2xx
ForwardGroupConfigobject

The configurations of the server groups.

ServerGroupTuplesobject []

The server groups to which requests are forwarded.

ServerGroupIdstring

The server group to which requests are forwarded.

sg-atstuj3rtoptyui****
Weightinteger

The weight of the server group. Valid values: 0 to 100.

2
ServerGroupStickySessionobject

The session persistence configurations of the server group.

Enabledboolean

If the value of N in ServerGroupTuple.N is larger than 1, you can enable or disable session persistence for server groups.

Timeoutinteger

If Enabled is set to True, you can specify a session persistence timeout period.

100
InsertHeaderConfigobject

The key of the header to be inserted.

Keystring

The key of the header. The header key must be 1 to 40 characters in length, and can contain letters, digits, underscores (_), and hyphens (-). The header key specified in InsertHeader must be unique.

Note Cookie and Host are not supported.
key
Valuestring

The value of the header to be inserted.

  • If ValueType is set to SystemDefined, you can set the Value parameter to one of the following values:

    • ClientSrcPort: the client port.
    • ClientSrcIp: the IP address of the client.
    • Protocol: the request protocol (HTTP or HTTPS).
    • SLBId: the ID of the ALB instance.
    • SLBPort: the listener port.
  • If ValueType is set to UserDefined, you can specify a custom header value. The header value must be 1 to 128 characters in length, and can contain wildcard characters, such as asterisks (*) and question marks (?), and printable characters whose ASCII values are larger than or equal to 32 and smaller than 127. The header value cannot start or end with a space character.

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

ClientSrcPort
ValueTypestring

The type of the header value. Valid values:

  • UserDefined: a user-defined header value.
  • ReferenceHeader: a header value that is referenced from a request header.
  • SystemDefined: a system-defined header value.
SystemDefined
Orderinteger

The priority of the action. Valid values: 1 to 50000. A smaller value indicates a higher priority. The actions of a forwarding rule are applied in descending order of priority. This parameter cannot empty. The priority of each action within a forwarding rule must be unique.

1
RedirectConfigobject

The configuration of the redirect action.

Hoststring

The hostname to which requests are redirected. Valid values:

  • ${host} (default): If ${host} is returned, no other characters are appended.

  • A custom value. Make sure that the custom value meets the following requirements:

    • The hostname must be 3 to 128 characters in length, and can contain lowercase letters, digits, hyphens (-), periods (.), asterisks (*), and question marks (?).
    • The hostname must contain at least one period (.) but cannot start or end with a period (.).
    • 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 as wildcard characters.
www.example.com
HttpCodestring

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

301
Pathstring

The URL to which requests are redirected. Valid values:

  • ${path} (default): You can reference **${host}, ${protocol}, and${port}. The URL can consist of ${host},${protocol}**, and **${port}**. Each variable can be used only once. The preceding variables can be used at the same time or combined with a custom value.

  • A custom value. Make sure that the custom value meets the following requirements:

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

The port to which requests are redirected. Valid values:

  • ${port} (default): If ${port} is returned, no other characters are appended.
  • Other valid values: 1 to 63335.
10
Protocolstring

The redirect protocol. Valid values:

  • ${protocol} (default): If ${protocol} is returned, no other characters are appended.
  • HTTP or HTTPS
Note HTTPS listeners supports only HTTPS redirects.
HTTP
Querystring

The query string of the URL to which requests are redirected. The query string must be 1 to 128 characters in length, and can contain printable characters, excluding uppercase letters and the following special characters: # [ ] { } \ | < > &.

quert
RemoveHeaderConfigobject

The HTTP header to be removed.

Keystring

The key of the header to be removed. The header key must be 1 to 40 characters in length, and can contain letters, digits, underscores (_), and hyphens (-). The header keys specified in RemoveHeader must be unique.

  • If Direction is set to Request, the specified headers are removed from requests. The following header keys are not supported (not case-sensitive): 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, the specified headers are removed from responses. The following header keys are not supported (not case-sensitive): connection, upgrade, content-length, and transfer-encoding.
key
RewriteConfigobject

The configuration of the rewrite action.

Hoststring

The hostname to which requests are redirected. Valid values:

  • ${host} (default): If ${host} is returned, no other characters are appended.

  • A custom value. Make sure that the custom value meets the following requirements:

    • The hostname must be 3 to 128 characters in length, and can contain lowercase letters, digits, hyphens (-), periods (.), asterisks (*), and question marks (?).
    • The hostname must contain at least one period (.) but cannot start or end with a period (.).
    • 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 as wildcard characters.
www.example.com
Pathstring

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

/tsdf
Querystring

The query string of the URL to which requests are redirected. The query string must be 1 to 128 characters in length, and can contain printable characters, excluding uppercase letters and the following special characters: # [ ] { } \ | < > &.

quedsa
TrafficMirrorConfigobject

The configuration of traffic mirroring.

TargetTypestring

The destination to which traffic is mirrored. The destination can be a server group.

ForwardGroupMirror
MirrorGroupConfigobject

The configuration of the server group to which traffic is mirrored.

ServerGroupTuplesobject []

The server group to which traffic is mirrored.

ServerGroupIdstring

The ID of the server group.

srg-00mkgijak0w4qgz9****
Weightinteger

The weight of the server group. Valid values: 0 to 100.

2
TrafficLimitConfigobject

The configuration of traffic throttling.

QPSinteger

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

4
PerIpQpsinteger

The number of requests per IP address. Valid values: 1 to 100000.

Note If both the QPS and PerIpQps parameters are specified, the value of the QPS parameter is smaller than the value of the PerIpQps parameter.
80
Typestring

The action. Valid values:

  • ForwardGroup: distributes requests to multiple vServer groups.
  • Redirect: redirects requests.
  • FixedResponse: returns a custom response.
  • Rewrite: rewrites requests.
  • InsertHeader: inserts headers.
  • RemoveHeaderConfig: removes headers.
  • TrafficLimitConfig: throttles network traffic.
  • TrafficMirrorConfig: mirrors network traffic.
  • CorsConfig: forwards requests based on CORS.

The preceding actions can be classified into two broad types:

  • FinalType: Each forwarding rule can contain only one FinalType action, which is performed at the end. You can specify only one of ForwardGroup, Redirect, and FixedResponse.
  • ExtType: Each forwarding rule can contain one or more ExtType actions, which are performed before the FinalType action. If you want to specify an ExtType action, you must also specify a FinalType action. You can specify multiple InsertHeader actions or one Rewrite action.
ForwardGroup
CorsConfigobject

The CORS configuration.

AllowOriginarray

The allowed origins of CORS requests.

string

The allowed origin of CORS requests. One or more values are supported. Asterisks (*) can be used as wildcard characters. The value cannot be only an asterisk (*).

  • Each value must start with http:// or https:// and must be followed by a valid domain name or a wildcard top-level domain name, such as *.test.abc.example.com.
  • You can specify a port in each value or leave the port empty. Valid values: 1 to 65535.
http://test.com
AllowMethodsarray

The allowed HTTP methods of CORS requests.

string

The allowed HTTP method of CORS requests. Valid values:

  • GET
  • POST
  • PUT
  • DELETE
  • HEAD
  • OPTIONS
  • PATCH
GET
AllowHeadersarray

The allowed headers of CORS requests.

string

The allowed headers of CORS requests. One or more values are supported. Asterisks (*) can be used as wildcard characters. Multiple values are separated by commas (,). Each value can be up to 32 characters in length, and can contain only letters and digits. It cannot start or end with an underscore (_) or a hyphen (-).

test_123
ExposeHeadersarray

The headers that can be exposed.

string

The headers that can be exposed. One or more values are supported. Asterisks (*) can be used as wildcard characters. Multiple values are separated by commas (,). Each value can be up to 32 characters in length, and can contain only letters and digits. It cannot start or end with an underscore (_) or a hyphen (-).

test_123
AllowCredentialsstring

Indicates whether credentials can be carried in CORS requests. Valid values:

  • on
  • off
on
MaxAgelong

The maximum cache time of dry runs in the browser. Unit: seconds.

Valid values: -1 to 172800.

1000
RuleConditionsobject []

The conditions of the forwarding rule.

CookieConfigobject

The key-value pairs of the cookie.

Valuesobject []

The cookie value.

Keystring

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

test
Valuestring

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

test
HeaderConfigobject

The configuration of the header.

Keystring

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

Port
Valuesarray

The value of the header.

string

The value of the header. The header value must be 1 to 128 characters in length. It can contain printable characters whose ASCII values are larger than or equal to 32 and smaller than 127, lowercase letters, asterisks (*), and question marks (?). The value cannot start or end with a space character.

5006
HostConfigobject

The configuration of the hosts.

Valuesarray

The hostnames.

string

The hostname. The hostname must meet the following requirements:

  • The domain name must be 3 to 128 characters in length, and can contain letters, digits, hyphens (-), periods (.), asterisks (*), and question marks (?).
  • The hostname must contain at least one period (.) but cannot start or end with a period (.).
  • The rightmost domain label can contain only letters, asterisks (*), and question marks (?), and cannot contain digits or hyphens (-).
  • The domain labels cannot start or end with a hyphen (-). You can specify asterisks (∗) and question marks (?) anywhere in a domain label.
www.example.com
MethodConfigobject

The configurations of the request methods.

Valuesarray

The request methods.

string

The request method.

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

PUT
PathConfigobject

The configurations of the forwarding URLs.

Valuesarray

The URLs to which requests are forwarded.

string

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

/test
QueryStringConfigobject

The configurations of the query strings.

Valuesobject []

The query string.

Keystring

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

test
Valuestring

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

test
SourceIpConfigobject

Traffic matching based on source IP addresses.

Valuesarray

The source IP addresses.

string

You can specify one or more IP addresses, including CIDR blocks.

Each forwarding rule supports at most five source IP addresses, including CIDR blocks.

192.168.XX.XX/32
ResponseStatusCodeConfigobject

The configurations of the response status codes.

Valuesarray

The response status codes.

string

The response status code.

200
ResponseHeaderConfigobject

The HTTP header in responses.

Keystring

The key of the HTTP header. The header key must be 1 to 40 characters in length, It can contain letters, digits, hyphens (-), and underscores (_). Cookie and Host are not supported.

key
Valuesarray

The values of the HTTP header.

string

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

value
Typestring

The type of forwarding rule. Valid values:

  • Host: Responses are forwarded based on hosts.
  • Path: Responses are forwarded based on URLs.
  • Header: Responses are forwarded based on HTTP headers.
  • QueryString: Responses are forwarded based on query strings.
  • Method: Responses are forwarded based on request methods.
  • Cookie: Responses are forwarded based on cookies.
  • SourceIp: Responses are forwarded based on source IP addresses.
Host
RuleIdstring

The ID of the forwarding rule.

rule-bpn0kn908w4nbw****
RuleNamestring

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

rule-instance-test
RuleStatusstring

The status of the forwarding rule. Valid values:

  • Provisioning: The forwarding rule is being created.
  • Configuring: The forwarding rule is being modified.
  • Available: The forwarding rule is available.
Available
Directionstring

The direction to which the forwarding rule is applied. Valid values:

  • Request (default): The forwarding rule is applied to requests. The forwarding action is performed on packets that are forwarded from clients to ALB.
  • Responses: The forwarding rule is applied to responses. The forwarding action is performed on packets that are returned from backend servers to ALB.
Note Basic ALB instances support only the Response direction.
Request
Tagsobject []

The tags.

Keystring

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
Valuestring

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
TotalCountinteger

The total number of entries returned.

1000

Examples

Sample success responses

JSONformat

{
  "MaxResults": 50,
  "NextToken": "FFmyTO70tTpLG6I3FmYAXGKPd****",
  "RequestId": "CEF72CEB-54B6-4AE8-B225-F876FF7BA984",
  "Rules": [
    {
      "ListenerId": "lsn-i35udpz3pxsmnf****",
      "LoadBalancerId": "alb-x30o38azsuj0sx****",
      "Priority": 1,
      "RuleActions": [
        {
          "FixedResponseConfig": {
            "Content": "dssacav",
            "ContentType": "text/plain",
            "HttpCode": "HTTP_2xx"
          },
          "ForwardGroupConfig": {
            "ServerGroupTuples": [
              {
                "ServerGroupId": "sg-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": "srg-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 codeError codeError messageDescription
403Forbidden.LoadBalancerAuthentication is failed for %s.Authentication is failed for %s.

For a list of error codes, visit the Service error codes.

Change history

Change timeSummary of changesOperation
2024-01-29The Error code has changedsee changesets
Change itemChange content
Error CodesThe Error code has changed.
    Added Error Codes: 403
2024-01-23The internal configuration of the API is changed, but the call is not affectedsee changesets
Change itemChange content
The internal configuration of the API is changed, but the call is not affected.
2023-06-01The response structure of the API has changedsee changesets
Change itemChange content
Output ParametersThe response structure of the API has changed.
2023-06-01The response structure of the API has changedsee changesets
Change itemChange content
Output ParametersThe response structure of the API has changed.