Queries forwarding rules.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter Type Required Example Description
Action String Yes ListRules

The operation that you want to perform.

Set the value to ListRules.

NextToken String No FFmyTO70tTpLG6I3FmYAXGKPd****

The start position of the query. If this parameter is left empty, the query starts from the beginning.

MaxResults Integer No 20

The maximum number of entries to return.

Valid values: 1 to 100.

Default value: 20. This value indicates that this parameter is not set.

Note This parameter is optional.
RuleIds Array of String No rule-sada

The IDs of forwarding rules. You can specify at most 20 IDs.

ListenerIds Array of String No Listener-sada

The IDs of listeners. You can specify at most 20 IDs.

Response parameters

Parameter Type Example Description
MaxResults Integer 50

The maximum number of entries returned.

NextToken String t-2343r

The position where the query stopped. If the response does not contain this parameter, all data has been queried.

RequestId String CEF72CEB-54B6-4AE8-B225-F876FF7BA984

The ID of the request.

Rules Array of Rule

The forwarding rules.

ListenerId String lsr-bp1bpn0kn908w4nbw****

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

LoadBalancerId String lb-bp1b6c719dfa08ex*****

The ID of the Application Load Balancer (ALB) instance to which the forwarding rule belongs.

Priority Integer 1

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

Note The priority of each rule within the same listener must be unique.
RuleActions Array of Action

The actions of the forwarding rules.

FixedResponseConfig Object

The configuration of the fixed response.

Content String dssacav

The fixed response. The response cannot exceed 1 KB in size and can contain only ASCII characters.

ContentType String text/plain

The format of the fixed response.

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

HttpCode String 200

The HTTP status code of the response. The code must be an HTTP_2xx,HTTP_4xx or HTTP_5xx.x is a digit.

ForwardGroupConfig Object

The configurations of the destination server groups.

ServerGroupTuples Array of ServerGroupTuple

The destination server groups to which requests are forwarded.

ServerGroupId String sg-atstuj3rtoptyui****

The IDs of the destination server groups.

InsertHeaderConfig Object

The configuration of the inserted header field.

Key String key

The name of the inserted header field. The name must be 1 to 40 characters in length, and can contain letters, digits, underscores (_), and hyphens (-). You cannot use the same name in InsertHeader.

Note You cannot use Cookie or Host in the name.
Value String ClientSrcPort

The content of the inserted header field:

If the ValueType parameter is set to SystemDefined, the following values are used:

  • ClientSrcPort: the port of the client
  • ClientSrcIp: the IP address of the client
  • Protocol: the protocol used by client requests (HTTP or HTTPS)
  • SLBId: the ID of the ALB instance
  • SLBPort: the listener port of the ALB instance

If the ValueType parameter is set to UserDefined: The header value must be 1 to 128 characters in length, and can contain lowercase letters, printable characters whose ASCII value is ch >= 32 && ch < 127, and wildcards such as asterisks (*) and question marks (?). The header value cannot start or end with a space.

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

ValueType String SystemDefined

Valid values:

  • UserDefined: a custom value
  • ReferenceHeader: uses a field of the user request header.
  • SystemDefined: a system value
Order Integer 1

The order of the forwarding rule actions. Valid values:1 to 50000. The actions are performed in ascending order. You cannot leave this parameter empty. Each value must be unique.

RedirectConfig Object

The configuration of the external redirect action.

Host String ww.ali.com

The host name of the destination to which requests are directed.

The host name must meet the following rules:

  • The host name must be 3 to 128 characters in length, and can contain letters, digits, hyphens (-), periods (.), asterisks (*), and question marks (?).
  • The host name must contain at least one period (.), and 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 (-).
  • Other domain labels cannot start or end with a hyphen (-). You can include asterisks (*) and question marks (?) anywhere in a domain label.

Default value: ${host}. You cannot use this value with other characters at the same time.

HttpCode String 301

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

Path String /test

The path of the destination to which requests are directed.

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

Default value: ${path}. You can also reference ${host}, ${protocol}, and ${port}. Each variable can appear at most once. You can use the preceding variables at the same time, or use them with a valid string.

Port String 10

The port of the destination to which requests are redirected.

Valid values: 1 to 63335.

Default value: ${port}. You cannot use this value together with other characters at the same time.

Protocol String HTTP

The protocol of the requests to be redirected.

Valid values: HTTP and HTTPS.

Default value: ${protocol}. You cannot use this value together with other characters at the same time.

Note HTTPS listeners can redirect only HTTPS requests.
Query String quert

The query string of the request to be redirected.

The query string must be 1 to 128 characters in length, can contain letters and printable characters. It cannot contain the following special characters: # [ ] { } \ | < > &.

Default value: ${query}. You can also reference ${host}, ${protocol}, and ${port}. Each variable can appear at most once. You can use the preceding variables at the same time, or use them together with a valid string.

RewriteConfig Object

The redirect action within ALB.

Host String www.al.com

The host name of the destination to which requests are redirected within ALB.

Valid values:

  • The host name must be 3 to 128 characters in length, and can contain letters, digits, hyphens (-), periods (.), asterisks (*), and question marks (?).
  • The host name must contain at least one period (.), and 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 (-).
  • Other domain labels cannot start or end with a hyphen (-). You can include asterisks (*) and question marks (?) anywhere in a domain label.

Default value: ${host}. You cannot use this value with other characters at the same time.

Path String /tsdf

The path to which requests are to be redirected within ALB.

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

Default value: ${path}. This value can be used only once. You can use it with a valid string.

Query String quedsa

The query string of the request to be redirected within ALB.

The query string must be 1 to 128 characters in length, can contain letters and printable characters. It cannot contain the following special characters: # [ ] { } \ | < > &.

Default value: ${query}. This value can be used only once. You can use it with a valid string.

Type String ForwardGroup

The action. Valid values:

  • ForwardGroup: forwards requests to multiple vServer groups.
  • Redirect: redirects requests.
  • FixedResponse: returns a fixed response.
  • Rewrite: rewrites requests.
  • InsertHeader: inserts header fields to requests.

The preceding actions can be classified into two types:

  • FinalType: A forwarding rule can contain only one FinalType action, which is executed last. This type of action can contain only one ForwardGroup, Redirect or FixedResponse action.
  • ExtType: A forwarding rule can contain one or more ExtType actions, which are executed before FinalType actions and need to coexist with the FinalType actions. This type of action can contain multiple InsertHeader actions or one Rewrite action.
RuleConditions Array of Condition

The conditions of the forwarding rule.

CookieConfig Object

The configuration of the cookie.

Values Array of Value

The value of the cookie.

Key String test

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

Value String test

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

HeaderConfig Object

The configuration of the header field.

Key String Port

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

Values Array of String 5006

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

HostConfig Object

The configuration of the host.

Values Array of String www.test.com

The domain name of the host.

The domain name must meet the following rules:

  • The domain name must be 3 to 128 characters in length, and can contain letters, digits, hyphens (-), periods (.), asterisks (*), and question marks (?).
  • The domain name must contain at least one period (.), and 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 (-).
  • Other domain labels cannot start or end with a hyphen (-). You can include asterisks (*) and question marks (?) anywhere in a domain label.
MethodConfig Object

The configuration of the request method.

Values Array of String PUT

The request method.

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

PathConfig Object

The configuration of the path for the request to be forwarded.

Values Array of String /test

The path of the request to be forwarded.

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

QueryStringConfig Object

The configuration of the query string.

Values Array of Value

The query string.

Key String test

They key of the query string.

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

Value String test

The value of the query string.

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

Type String Host

The type of the forwarding rule. Valid values:

  • Host: Requests are forwarded based on the domain name.
  • Path: Requests are forwarded based on the path.
  • Header: Requests are forwarded based on the HTTP header field.
  • QueryString: Requests are forwarded based on the query string.
  • Method: Request are forwarded based on the request method.
  • Cookie: Requests are forwarded based on the cookie.
RuleId String rule-bpn0kn908w4nbw****

The ID of the forwarding rule.

RuleName String rule-instance-test

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.

RuleStatus String Available

The state of the forwarding rule. Valid values:

  • Provisioning: The forwarding rule is being created.
  • Configuring: The configuration of the forwarding rule is being modified.
  • Available: The forwarding rule is working as expected.
TotalCount Integer 1000

The total number of entries returned.

Examples

Sample requests

http(s)://[Endpoint]/?Action=ListRules
&NextToken=FFmyTO70tTpLG6I3FmYAXGKPd****
&MaxResults=20
&RuleIds=["rule-sada"]
&ListenerIds=["Listener-sada"]
&<Common request parameters>

Sample success responses

XML format

HTTP/1.1 200 OK
Content-Type:application/xml

<ListRulesResponse>
    <MaxResults>50</MaxResults>
    <NextToken>t-2343r</NextToken>
    <RequestId>CEF72CEB-54B6-4AE8-B225-F876FF7BA984</RequestId>
    <Rules>
        <ListenerId>lsr-bp1bpn0kn908w4nbw****</ListenerId>
        <LoadBalancerId>lb-bp1b6c719dfa08ex*****</LoadBalancerId>
        <Priority>1</Priority>
        <RuleActions>
            <FixedResponseConfig>
                <Content>dssacav</Content>
                <ContentType>text/plain</ContentType>
                <HttpCode>200</HttpCode>
            </FixedResponseConfig>
            <ForwardGroupConfig>
                <ServerGroupTuples>
                    <ServerGroupId>sg-atstuj3rtoptyui****</ServerGroupId>
                </ServerGroupTuples>
            </ForwardGroupConfig>
            <InsertHeaderConfig>
                <Key>key</Key>
                <Value>ClientSrcPort</Value>
                <ValueType>SystemDefined</ValueType>
            </InsertHeaderConfig>
            <Order>1</Order>
            <RedirectConfig>
                <Host>ww.ali.com</Host>
                <HttpCode>301</HttpCode>
                <Path>/test</Path>
                <Port>10</Port>
                <Protocol>HTTP</Protocol>
                <Query>quert</Query>
            </RedirectConfig>
            <RewriteConfig>
                <Host>www.al.com</Host>
                <Path>/tsdf</Path>
                <Query>quedsa</Query>
            </RewriteConfig>
            <Type>ForwardGroup</Type>
        </RuleActions>
        <RuleConditions>
            <CookieConfig>
                <Values>
                    <Key>test</Key>
                    <Value>test</Value>
                </Values>
            </CookieConfig>
            <HeaderConfig>
                <Key>Port</Key>
                <Values>5006</Values>
            </HeaderConfig>
            <HostConfig>
                <Values>www.test.com</Values>
            </HostConfig>
            <MethodConfig>
                <Values>PUT</Values>
            </MethodConfig>
            <PathConfig>
                <Values>/test</Values>
            </PathConfig>
            <QueryStringConfig>
                <Values>
                    <Key>test</Key>
                    <Value>test</Value>
                </Values>
            </QueryStringConfig>
            <Type>Host</Type>
        </RuleConditions>
        <RuleId>rule-bpn0kn908w4nbw****</RuleId>
        <RuleName>rule-instance-test</RuleName>
        <RuleStatus>Available</RuleStatus>
    </Rules>
    <TotalCount>1000</TotalCount>
</ListRulesResponse>

JSON format

HTTP/1.1 200 OK
Content-Type:application/json

{
  "MaxResults" : 50,
  "NextToken" : "t-2343r",
  "RequestId" : "CEF72CEB-54B6-4AE8-B225-F876FF7BA984",
  "Rules" : [ {
    "ListenerId" : "lsr-bp1bpn0kn908w4nbw****",
    "LoadBalancerId" : "lb-bp1b6c719dfa08ex*****",
    "Priority" : 1,
    "RuleActions" : [ {
      "FixedResponseConfig" : {
        "Content" : "dssacav",
        "ContentType" : "text/plain",
        "HttpCode" : "200"
      },
      "ForwardGroupConfig" : {
        "ServerGroupTuples" : [ {
          "ServerGroupId" : "sg-atstuj3rtoptyui****"
        } ]
      },
      "InsertHeaderConfig" : {
        "Key" : "key",
        "Value" : "ClientSrcPort",
        "ValueType" : "SystemDefined"
      },
      "Order" : 1,
      "RedirectConfig" : {
        "Host" : "ww.ali.com",
        "HttpCode" : "301",
        "Path" : "/test",
        "Port" : "10",
        "Protocol" : "HTTP",
        "Query" : "quert"
      },
      "RewriteConfig" : {
        "Host" : "www.al.com",
        "Path" : "/tsdf",
        "Query" : "quedsa"
      },
      "Type" : "ForwardGroup"
    } ],
    "RuleConditions" : [ {
      "CookieConfig" : {
        "Values" : [ {
          "Key" : "test",
          "Value" : "test"
        } ]
      },
      "HeaderConfig" : {
        "Key" : "Port",
        "Values" : [ "5006" ]
      },
      "HostConfig" : {
        "Values" : [ "www.test.com" ]
      },
      "MethodConfig" : {
        "Values" : [ "PUT" ]
      },
      "PathConfig" : {
        "Values" : [ "/test" ]
      },
      "QueryStringConfig" : {
        "Values" : [ {
          "Key" : "test",
          "Value" : "test"
        } ]
      },
      "Type" : "Host"
    } ],
    "RuleId" : "rule-bpn0kn908w4nbw****",
    "RuleName" : "rule-instance-test",
    "RuleStatus" : "Available"
  } ],
  "TotalCount" : 1000
}

Error codes

For a list of error codes, visit the API Error Center.