All Products
Search
Document Center

Server Load Balancer:ListRules

Last Updated:Mar 01, 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

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 forwarding rules.

ListenerIdstring

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

lsn-i35udpz3pxsmnf****
LoadBalancerIdstring

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

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 is up to 1 KB in size, and can contain only ASCII characters.

dssacav
ContentTypestring

The content type.

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

text/plain
HttpCodestring

The HTTP status code in the response. Valid values: HTTP_2xx, HTTP_4xx, and HTTP_5xx. x must be 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. Valid values: 0 to 100.

2
InsertHeaderConfigobject

The configuration of the header to be inserted.

Keystring

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

Note Cookie and Host are not supported.
key
Valuestring

The value of the header.

  • If ValueType is set to SystemDefined, one of the following values is supported:

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

  • If ValueType is set to ReferenceHeader, one of the request headers is referenced. The header value must be 1 to 128 characters in length, and can contain lowercase letters, digits, underscores (_), and hyphens (-).

ClientSrcPort
ValueTypestring

The type of the header. Valid values:

  • UserDefined: a user-defined header.
  • ReferenceHeader: a header that is referenced from a request header.
  • SystemDefined: a system-defined header.
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 is not empty. The priority of each action within a forwarding rule is 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 character is appended.

  • Limits on a custom value:

    • The hostname is 3 to 128 characters in length, and can contain lowercase letters, digits, hyphens (-), and periods (.). Asterisks (*) and question marks (?) can be used as wildcard characters.
    • The hostname contains at least one period (.) but does not start or end with a period (.).
    • The rightmost domain label contains only letters and wildcard characters. It does not contain digits or hyphens (-).
    • The domain labels do not start or end with hyphens (-).
    • You can use asterisks (*) and question marks (?) anywhere in a domain label as wildcard characters.
www.example.com
HttpCodestring

The redirect type. Valid values: 301, 302, 303, 307, and 308.

301
Pathstring

The path to which requests are redirected. Valid values:

  • ${path} (default): You can reference **${host}, ${protocol}, and${port}. The path 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.

  • Limits on a custom value:

    • The value is 1 to 128 characters in length.
    • It starts with a forward slash (/) and contains letters, digits, and the following special characters: $ - _ .+ / & ~ @ :. It does not 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 character is appended.
  • Other valid values: 1 to 63335.
10
Protocolstring

The redirect protocol. Valid values:

  • ${protocol} (default): If ${protocol} is returned, no other character is appended.
  • HTTP or HTTPS.
Note HTTPS listeners support only HTTP to HTTPS redirection.
HTTP
Querystring

The query string 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 configuration of the header to be removed.

Keystring

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

  • You cannot specify the following header keys for an inbound forwarding rule: 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. The preceding keys are case-insensitive.
  • You cannot specify the following header keys for an outbound forwarding rule: connection, upgrade, content-length, and transfer-encoding. The preceding keys are case-insensitive.
RewriteConfigobject

The configuration of the rewrite action.

Hoststring

The hostname to which requests are forwarded. Valid values:

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

  • Limits on a custom value:

    • The hostname is 3 to 128 characters in length, and can contain lowercase letters, digits, hyphens (-), and periods (.). Asterisks (*) and question marks (?) can be used as wildcard characters.
    • The hostname contains at least one period (.) but does not start or end with a period (.).
    • The rightmost domain label contains only letters and wildcard characters. It does not contain digits or hyphens (-).
    • The domain labels do not start or end with hyphens (-).
    • You can use asterisks (*) and question marks (?) anywhere in a domain label as wildcard characters.
www.example.com
Pathstring

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

/tsdf
Querystring

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

quedsa
TrafficMirrorConfigobject

The configuration of the action to mirror traffic.

MirrorGroupConfigobject

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

ServerGroupTuplesobject []

The server group to which traffic is mirrored.

ServerGroupIdstring

The server group ID.

srg-00mkgijak0w4qgz9****
Weightinteger

The weight. Valid values: 0 to 100.

2
TrafficLimitConfigobject

The configuration of the action to throttle traffic.

QPSinteger

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

4
PerIpQpsinteger

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

Note If you specify this parameter and QPS, the value of PerIpQps must be smaller than the value of QPS.
80
Typestring

The action. Valid values:

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

The preceding actions can be classified into two broad types:

  • FinalType: the last action to be performed in a forwarding rule. Each forwarding rule can contain only one FinalType action. You can specify a ForwardGroup, Redirect, or FixedResponse action as the FinalType action.
  • ExtType: one or more actions to be performed before the FinalType action. A forwarding rule can contain one or more ExtType actions. To specify an ExtType action, you must 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. You can specify an asterisk (*) or one or more values. A value cannot be *.

  • Each value must start with http:// or https://, followed by a valid domain name or a first-level wildcard domain name, such as *.test.abc.example.com.
  • You can specify a port in a value. Port range: 1 to 65535.
http://test.com
AllowMethodsarray

The allowed HTTP methods for CORS requests.

string

The allowed HTTP method for CORS requests. Valid values:

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

The allowed headers for CORS requests.

string

The allowed header for CORS requests. You can specify an asterisk (*) or one or more values. Separate multiple values with commas (,). A value can contain only letters and digits. It cannot start or end with underscores (_) or hyphens (-). It can be up to 32 characters in length.

test_123
ExposeHeadersarray

The headers that can be exposed.

string

The header that can be exposed. You can specify an asterisk (*) or one or more values. Separate multiple values with commas (,). A value can contain only letters and digits. It cannot start or end with underscores (_) or hyphens (-). It can be up to 32 characters in length.

test_123
AllowCredentialsstring

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

  • on
  • off
on
MaxAgelong

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

Valid values: -1 to 172800.

1000
RuleConditionsobject []

The conditions of the forwarding rule.

CookieConfigobject

The configuration of the cookie.

Valuesobject []

The key-value pair of the cookie.

Keystring

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

test
Valuestring

The value of the cookie. The value is 1 to 128 characters in length, and can contain printable characters such as lowercase letters, asterisks (*), and question marks (?). Uppercase letters, space characters, and the following special characters are not supported: # [ ] { } \ | < > &.

test
HeaderConfigobject

The configuration of the header.

Keystring

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

Port
Valuesarray

The values of the header.

string

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

5006
HostConfigobject

The configurations of the hosts.

Valuesarray

The hostnames.

string

The hostname. Limits on the value:

  • The hostname is 3 to 128 characters in length, and can contain lowercase letters, digits, hyphens (-), periods (.), asterisks (*), and question marks (?).
  • The hostname contains at least one period (.) but does not start or end with a period (.).
  • The rightmost domain label can contain only letters, asterisks (*), and question marks (?), and does not 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 paths.

Valuesarray

The paths.

string

The path. The path is 1 to 128 characters in length and starts with a forward slash (/). The path can contain letters, digits, asterisks (*), question marks (?), and the following special characters: $ - _ . + / & ~ @ :. The path does not 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 printable characters such as lowercase letters, asterisks (*), and question marks (?). The key cannot contain uppercase letters, 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 printable characters such as lowercase letters, asterisks (*), and question marks (?). However, uppercase letters, space characters, and the following special characters are not supported: # [ ] { } \ | < > &.

test
SourceIpConfigobject

The configuration of the source IP addresses based on which user traffic is matched.

Valuesarray

The source IP addresses.

string

The IP address or CIDR block based on which user traffic is matched. You can specify multiple IP addresses or CIDR blocks.

You can specify up to five source IP addresses in a forwarding rule.

192.168.XX.XX/32
ResponseStatusCodeConfigobject

The configurations of the response status codes.

Valuesarray

The response status codes.

string

The response status code.

ResponseHeaderConfigobject

The configuration of the HTTP response header.

Keystring

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

Valuesarray

The header values.

string

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

Typestring

The type of forwarding rule. Valid values:

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

The forwarding rule ID.

rule-bpn0kn908w4nbw****
RuleNamestring

The name of the forwarding rule. 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.

rule-instance-test
RuleStatusstring

The status of the forwarding rule. Valid values:

  • Provisioning
  • Configuring
  • Available
Available
Directionstring

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

  • Request (default): The rule applies to client requests.
  • Response: The rule applies to responses from backend servers.
Note Response is not supported by basic ALB instances.
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
              }
            ]
          },
          "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": ""
          },
          "RewriteConfig": {
            "Host": "www.example.com",
            "Path": "/tsdf",
            "Query": "quedsa"
          },
          "TrafficMirrorConfig": {
            "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": [
              ""
            ]
          },
          "ResponseHeaderConfig": {
            "Key": "",
            "Values": [
              ""
            ]
          },
          "Type": "Host"
        }
      ],
      "RuleId": "rule-bpn0kn908w4nbw****",
      "RuleName": "rule-instance-test",
      "RuleStatus": "Available",
      "Direction": ""
    }
  ],
  "TotalCount": 1000
}

Error codes

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.