ListRules

Updated at:

Queries 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 pagination token that is used in the next request to retrieve a new page of results. Valid values:

  • You do not need to specify this parameter for the first request or if no next query exists.

  • If a next query exists, set the value to the NextToken value returned in the previous API call.

FFmyTO70tTpLG6I3FmYAXGKPd****

MaxResults

integer

No

The maximum number of data records to read in this request.

Valid values: 1 to 100.

Default value: 20, which indicates that no value is specified.

Note

This parameter is optional.

20

RuleIds

array

No

The list of forwarding rules. You can query up to 20 forwarding rules at a time.

string

No

The forwarding rule ID.

rule-sada******

ListenerIds

array

No

The list of listener IDs. You can query up to 20 listeners at a time.

string

No

The listener ID.

lsn-i35udpz3pxsmnf****

LoadBalancerIds

array

No

The list of load balancing instance IDs. You can query up to 20 instances at a time.

string

No

The load balancing instance ID.

alb-x30o38azsuj0sx****

Direction

string

No

The direction of the forwarding rule. Valid values:

  • Request (default): request type. Performs condition matching and corresponding processing on packets sent from the client to ALB.

  • Response: response type. Performs condition matching and corresponding processing on packets returned from backend server groups to ALB.

Note

ALB Basic Edition instances do not support the Response type.

Request

Tag

array<object>

No

The tags.

object

No

The tag structure.

Key

string

No

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

env

Value

string

No

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

product

Response elements

Element

Type

Description

Example

object

The forwarding rule.

MaxResults

integer

The maximum number of records returned for this request.

50

NextToken

string

Indicates whether a next query exists. Valid values:

  • If NextToken is empty, no next query exists.

  • If NextToken is returned, the value indicates 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.

array<object>

The forwarding rule structure.

ListenerId

string

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

lsn-i35udpz3pxsmnf****

LoadBalancerId

string

The instance ID of the load balancing instance to which the forwarding rule belongs.

alb-x30o38azsuj0sx****

Priority

integer

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

Note

Rule priorities must be unique within the same listener.

1

RuleActions

array<object>

The list of forwarding rule actions.

array<object>

The forwarding rule action structure.

FixedResponseConfig

object

The fixed response configuration.

Content

string

The fixed content to return. The content can be up to 1 KB in size and can contain only ASCII characters.

dssacav

ContentType

string

The format of the fixed content to return.

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

text/plain

HttpCode

string

The HTTP response code to return. Only numeric strings in the format of HTTP_2xx, HTTP_4xx, and HTTP_5xx are supported, where x is any digit.

HTTP_2xx

ForwardGroupConfig

object

The forward group configuration.

ServerGroupTuples

array<object>

The list of destination server groups to which requests are forwarded.

object

The list of destination server groups to which requests are forwarded.

ServerGroupId

string

The ID of the destination server group to which requests are forwarded.

sgp-atstuj3rtoptyui****

Weight

integer

The weight. Valid values: 0 to 100.

2

ServerGroupStickySession

object

The session persistence configuration across server groups.

Enabled

boolean

Specifies whether to enable session persistence across server groups when multiple server groups are specified.

true

Timeout

integer

The timeout period for session persistence when Enabled is set to true. Unit: seconds. Valid values: 1 to 86400.

100

InsertHeaderConfig

object

The insert header field configuration.

Key

string

The name of the header field to insert. The name must be 1 to 40 characters in length and can contain lowercase and uppercase letters a to z, digits, underscores (_), and hyphens (-). The header field name cannot be used more than once in InsertHeader.

Note

You cannot use Cookie or Host as the header field name.

key

Value

string

The content of the header field to insert.

  • If ValueType is set to SystemDefined, the following values are supported:
    • ClientSrcPort: the client port.

    • ClientSrcIp: the client IP address.

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

    • SLBId: the load balancing instance ID.

    • SLBPort: the load balancing instance listener port.

  • If ValueType is set to UserDefined: you can specify a custom header field content. The content must be 1 to 128 characters in length and can contain wildcards such as asterisks (*) and question marks (?), as well as printable characters with ASCII values in the range of ch >= 32 && ch < 127. The content cannot start or end with a space.

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

ClientSrcPort

ValueType

string

The content type of the header field. Valid values:

  • UserDefined: user-defined.

  • ReferenceHeader: references a field from the client request header.

  • SystemDefined: system-defined.

SystemDefined

Order

integer

The order in which the forwarding rule action is executed. Valid values: 1 to 50000. Actions are executed in ascending order of value. The value cannot be empty or duplicated.

1

RedirectConfig

object

The redirect configuration.

Host

string

The host address to redirect to. Valid values:

  • ${host} (default): this value cannot be concatenated with other characters.

  • Other values. The character set and format restrictions are as follows:
    • The hostname must be 3 to 128 characters in length and can contain lowercase letters a to z, digits, hyphens (-), periods (.), asterisks (*), and question marks (?).

    • The hostname must contain at least one period (.) and cannot start or end with a period (.).

    • The rightmost domain label can contain only letters and wildcards, and cannot contain digits or hyphens (-).

    • Hyphens (-) cannot appear at the beginning or end of other domain labels.

    • Asterisks (*) and question marks (?) can appear at any position within a domain label.

www.example.com

HttpCode

string

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

301

Path

string

The path to redirect to. Valid values:

  • ${path} (default): you can reference ${host}, ${protocol}, and ${port}, which consist of ${host}, ${protocol}, and ${port}. Each variable can appear at most once. These variables can be used together or concatenated with strings from the following valid character set.

  • Other values. The character set and format restrictions are as follows:
    • The path must be 1 to 128 characters in length.

    • The path must start with a forward slash (/) and can contain letters, digits, and the special characters $-_.+/&~@:. The characters "%#;!()[]^," are not supported. Asterisks (*) and question marks (?) are supported as wildcards.

/test

Port

string

The port to redirect to. Valid values:

  • ${port} (default): this value cannot be used with other characters.

  • Other values: 1 to 63335.

10

Protocol

string

The protocol to redirect to. Valid values:

  • ${protocol} (default): this value cannot be concatenated with other characters.

  • HTTP or HTTPS.

Note

HTTPS listeners support only redirects to HTTPS.

HTTP

Query

string

The query string to redirect to. The query string must be 1 to 128 characters in length and can contain lowercase letters and visible characters. The characters #[]{}\|<>& are not supported.

quert

RemoveHeaderConfig

object

The remove HTTP header configuration.

Key

string

The name of the header field to remove. The name must be 1 to 40 characters in length and can contain lowercase and uppercase letters a to z, digits, underscores (_), and hyphens (-). The header field name cannot be used more than once in RemoveHeader.

  • Request direction (Direction is set to Request): the header name cannot be set to the following fields (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, authority.

  • Response direction (Direction is set to Response): the header name cannot be set to the following fields (case-insensitive): connection, upgrade, content-length, transfer-encoding.

key

RewriteConfig

object

The rewrite configuration.

Host

string

The host address to redirect to. Valid values:

  • ${host} (default): this value cannot be concatenated with other characters.

  • Other values. The character set and format restrictions are as follows:
    • The hostname must be 3 to 128 characters in length and can contain lowercase letters a to z, digits, hyphens (-), periods (.), asterisks (*), and question marks (?).

    • The hostname must contain at least one period (.) and cannot start or end with a period (.).

    • The rightmost domain label can contain only letters and wildcards, and cannot contain digits or hyphens (-).

    • Hyphens (-) cannot appear at the beginning or end of other domain labels.

    • Asterisks (*) and question marks (?) can appear at any position within a domain label.

www.example.com

Path

string

The destination path for the internal redirect. The path must be 1 to 128 characters in length, start with a forward slash (/), and can contain letters, digits, asterisks (*), question marks (?), and $-_.+/&~@:. The characters "%#;!()[]^," are not supported.

/tsdf

Query

string

The query string for the internal redirect. The query string must be 1 to 128 characters in length and can contain lowercase letters and visible characters. The characters #[]{}\|<>& are not supported.

quedsa

TrafficMirrorConfig

object

The traffic mirror configuration.

TargetType

string

The destination of traffic mirroring, which can be a server group.

ForwardGroupMirror

MirrorGroupConfig

object

The configuration for mirroring traffic to a server group.

ServerGroupTuples

array<object>

The configuration for mirroring traffic to a server group.

object

The target server group for traffic mirroring.

ServerGroupId

string

The server group ID.

sgp-00mkgijak0w4qgz9****

Weight

integer

The weight. Valid values: 0 to 100.

2

TrafficLimitConfig

object

The traffic throttling configuration.

QPS

integer

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

4

PerIpQps

integer

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

Note

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

80

Type

string

The action type. Valid values:

  • ForwardGroup: forwards requests to multiple virtual server groups.

  • Redirect: redirects requests.

  • FixedResponse: returns a fixed response.

  • Rewrite: rewrites requests.

  • InsertHeader: inserts a header field.

  • RemoveHeaderConfig: deletes a header field.

  • 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 origin. You can set this parameter to * or specify one or more values. The 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).

  • Each value can include a port or omit the port. Valid port values: 1 to 65535.

http://test.com

AllowMethods

array

The HTTP methods allowed for cross-origin access.

string

The HTTP method allowed for cross-origin access. Valid values:

  • GET.

  • POST.

  • PUT.

  • DELETE.

  • HEAD.

  • OPTIONS.

  • PATCH.

GET

AllowHeaders

array

The allowed cross-origin headers.

string

The allowed cross-origin headers. You can set this parameter to * or specify one or more values. Separate multiple values with commas (,). Each value can contain only uppercase and lowercase letters, digits, and underscores (_) and hyphens (-) that are not at the beginning or end. The maximum length of each value is 32 characters.

test_123

ExposeHeaders

array

The headers that can be exposed.

string

The allowed cross-origin headers. You can set this parameter to * or specify one or more values. Separate multiple values with commas (,). Each value can contain only uppercase and lowercase letters, digits, and underscores (_) and hyphens (-) that are not at the beginning or end. The maximum length of each value is 32 characters.

test_123

AllowCredentials

string

Specifies whether credentials are allowed. Valid values:

  • on: Credentials are allowed.

  • off: Credentials are not allowed.

on

MaxAge

integer

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

Valid values: -1 to 172800.

1000

RuleConditions

array<object>

The list of forwarding rule conditions.

array<object>

The forwarding rule condition structure.

CookieConfig

object

The cookie configuration.

Values

array<object>

The cookie values.

object

The cookie values.

Key

string

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

test

Value

string

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

test

HeaderConfig

object

The header field configuration.

Key

string

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

Port

Values

array

The header field values.

string

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

5006

HostConfig

object

The hostname configuration.

Values

array

The hostnames.

string

The hostname. Naming rules:

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

  • The domain name must contain at least one period (.). The period (.) cannot appear at the beginning or end.

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

  • Hyphens (-) cannot appear at the beginning or end of other domain labels. Asterisks (*) and question marks (?) can appear at any position in a domain label.

www.example.com

MethodConfig

object

The request method configuration.

Values

array

The request methods.

string

The request method.

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

PUT

PathConfig

object

The forwarding path configuration.

Values

array

The forwarding paths.

string

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

/test

QueryStringConfig

object

The query string configuration.

Values

array<object>

The query strings.

object

The query strings.

Key

string

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

test

Value

string

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

test

SourceIpConfig

object

The source IP-based service traffic matching configuration.

Values

array

The source IP addresses to match.

string

One or more IP addresses or CIDR blocks.

A maximum of 5 source IP addresses can be added to a forwarding rule.

192.168.XX.XX/32

ResponseStatusCodeConfig

object

The response status code configuration.

Values

array

The list of response status codes.

string

The response status code.

200

ResponseHeaderConfig

object

The response HTTP header configuration.

Key

string

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

key

Values

array

The list of response HTTP header values.

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: host.

  • Path: path.

  • Header: HTTP header field.

  • QueryString: query character string.

  • Method: request method.

  • Cookie: cookie.

  • SourceIp: 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 and can contain letters, digits, periods (.), underscores (_), and hyphens (-). The name must start with a letter.

rule-instance-test

RuleStatus

string

The status of the forwarding rule. Valid values:

  • Provisioning: being created.

  • Configuring: being modified.

  • Available: running.

Available

Direction

string

The direction of the forwarding rule. Valid values:

  • Request (default): request-based. Condition matching and corresponding processing are performed on requests sent from clients to ALB.

  • Response: response-based. Condition matching and corresponding processing are performed on responses returned from backend server groups to ALB.

Note

ALB Basic Edition instances do not support the Response type.

Request

Tags

array<object>

The tags.

object

The tag structure.

Key

string

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

env

Value

string

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

product

TotalCount

integer

The total number of data records returned for the current request.

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.