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 starting point of the current query. If you do not specify this parameter, 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. If you do not specify this parameter, the default value is used.

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

The IDs of the forwarding rules. You can specify at most 20 IDs in each request.

ListenerIds Array of String No lsn-i35udpz3pxsmnf****

The IDs of the listeners. You can specify at most 20 IDs in each request.

LoadBalancerIds Array of String No alb-x30o38azsuj0sx****

The IDs of the Application Load Balancer (ALB) instances. You can specify at most 20 IDs in each request.

Response parameters

Parameter Type Example Description
MaxResults Integer 50

The maximum number of entries returned.

NextToken String t-2343r

The end of the queried list. If this parameter is empty, it indicates that you have retrieved all forwarding rules.

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

The ID of the request.

Rules Array of Rule

The list of forwarding rules.

ListenerId String lsn-i35udpz3pxsmnf****

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

LoadBalancerId String alb-x30o38azsuj0sx****

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

Priority Integer 1

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

Note The priority of each forwarding rule within a listener must be unique.
RuleActions Array of Action

The actions of the forwarding rule.

FixedResponseConfig Object

The configuration of the fixed response action.

Content String dssacav

The content of the fixed response. The content is no greater than 1 KB in size and contains only ASCII characters.

ContentType String text/plain

The format of the content.

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

HttpCode String 200

The HTTP status code of the response. Valid values: HTTP_2xx, HTTP_4xx, and HTTP_5xx. x is a digit.

ForwardGroupConfig Object

The configurations of the server group.

ServerGroupTuples Array of ServerGroupTuple

The list of server groups to which requests are forwarded.

ServerGroupId String sg-atstuj3rtoptyui****

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

InsertHeaderConfig Object

The configuration of the header added to the request.

Key String key

The name of the header. The name is 1 to 40 characters in length, and can contain letters, digits, underscores (_), and hyphens (-). The header name specified by InsertHeaderConfig is unique.

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

The value of the header:

If the ValueType parameter is set to SystemDefined, the value of the header can be:

  • ClientSrcPort: the port of the client.
  • ClientSrcIp: the IP address of the client.
  • Protocol: the request protocol. Valid values: HTTP and HTTPS.
  • SLBId: the ID of the ALB instance.
  • SLBPort: the listening port of the ALB instance.

If the ValueType parameter is UserDefined, the following rules apply to the header: The header value is 1 to 128 characters in length, and can contain ASCII printable characters from character code 32 to 127 except uppercase letters. You can use asterisks (*) and question marks (?) as wildcards. The header value does not start or end with a space character.

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

ValueType String SystemDefined

Valid values:

  • UserDefined: a custom header.
  • ReferenceHeader: uses one of the specified headers in the request.
  • SystemDefined: a system header.
Order Integer 1

The priority of the action. Valid values: 1 to 50000. A lower value indicates a higher priority. The actions of a forwarding rule are applied in descending order of priority. This parameter is required. The priority of each action within a forwarding rule is unique.

RedirectConfig Object

The configuration of the redirect action.

Host String ww.ali.com

The host to which requests are redirected.

Limits on hostnames:

  • 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 (.).It does not start or end with a period (.).
  • The rightmost domain label can contain only letters, asterisks (*) and question marks (?). It cannot contain digits or hyphens (-).
  • Domain labels do not start or end with a hyphen (-). You can include asterisks (*) and question marks (?)anywhere in a domain label.

Default variable: ${host}. This variable cannot be specified in combination with other characters.

HttpCode String 301

Redirect types. Valid values: 301, 302, 303, 307, and 308.

Path String /test

The URL to which requests are redirected.

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

Default variable: ${path}. ${host}, ${protocol}, and ${port} are also supported. Each variable can be specified only once. You can specify one or more of the preceding variables in each request. You can also combine them with other characters.

Port String 10

The port to which requests are redirected.

Valid values: 1 to 63335.

Default variable: ${port}. This variable cannot be specified in combination with other characters.

Protocol String HTTP

The redirect protocol.

Valid values: HTTP and HTTPS.

Default variable: ${protocol}. This variable cannot be specified in combination with other characters.

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

The query string of the URL to which requests are redirected.

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

Default variable: ${query}. ${host}, ${protocol}, and ${port} are also supported. Each variable can be specified only once. You can specify one or more of the preceding variables in each request. You can also combine them with other characters.

RewriteConfig Object

The configuration of the forward action.

Host String www.al.com

The host to which requests are forwarded.

Limits on hostnames:

  • 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 (.).It does not start or end with a period (.).
  • The rightmost domain label can contain only letters, asterisks (*) and question marks (?). It cannot contain digits or hyphens (-).
  • Domain labels do not start or end with a hyphen (-). You can include asterisks (*) and question marks (?)anywhere in a domain label.

Default variable: ${host}. You cannot specify this variable in combination with other characters.

Path String /tsdf

The URL to which requests are forwarded.

The path of the URL is 1 to 128 characters in length, and start with a forward slash (/). It can contain letters, digits,and the following special characters: * ? $ - _ .+ / & ~ @ :. It does not contain the following special characters: " % # ; ! ( ) [ ]^ , ”. This value is case-sensitive.

Default variable: ${path}. You can specify this variable only once. You can specify this value in combination with other characters.

Query String quedsa

The query string of the URL to which requests are forwarded.

The query string is 1 to 128 characters in length. It can contain lowercase letters and other printable characters. It does not contain the following special characters: # [ ] { } \ | < > &.

Default variable: ${query}. You can specify this variable only once. You can specify this value in combination with other characters.

Type String ForwardGroup

The action. Valid values:

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

You can specify the last action and the actions before the last action by using the following parameters:

  • FinalType: the last action to be performed in a forwarding rule. Each forwarding rule can contain only one FinalType action. Valid values: ForwardGroup, Redirect, and FixedResponse.
  • ExtType: the action or the actions to be performed before the FinalType action. A forwarding rule can contain one or more ExtType actions. To specify this parameter, you must also specify FinalType. You can specify 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 cookie.

Key String test

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

Value String test

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

HeaderConfig Object

The configuration of the header.

Key String Port

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

Values Array of String 5006

The value of the header. The value is 1 to 128 characters in length, and can contain asterisks (*), question marks (?), and other ASCII printable characters from character code 32 to 127. The value cannot start or end with a space character.

HostConfig Object

The configuration of the host.

Values Array of String www.test.com

The hostname.

Limits on hostnames:

  • 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 (.).It does not start or end with a period (.).
  • The rightmost domain label can contain only letters, asterisks (*) and question marks (?). It cannot contain digits or hyphens (-).
  • Domain labels do not 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 URL to which requests are forwarded.

Values Array of String /test

The path.

The path of the URL is 1 to 128 characters in length, and start with a forward slash (/). It can contain letters, digits,and the following special characters: * ? $ - _ .+ / & ~ @ :. It does not contain the following special characters: " % # ; ! ( ) [ ]^ , ”. This value 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 is 1 to 100 characters in length, and can contain asterisks (*), question marks (?), and other printable characters. The key cannot contain space characters or the following special characters: # [ ] { } \ | < > &.

Value String test

The value of the query string.

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

Type String Host

The type of forwarding rule. Valid values:

  • Host: Requests are forwarded based on domain names.
  • Path: Requests are forwarded based on URLs.
  • Header: Requests are forwarded based on HTTP headers.
  • QueryString: Requests are forwarded based on query strings.
  • Method: Request are forwarded based on request methods.
  • Cookie: Request are forwarded based on cookies.
RuleId String rule-bpn0kn908w4nbw****

The ID of the forwarding rule.

RuleName String rule-instance-test

The name of the forwarding rule. The name is 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 forwarding rule is being modified.
  • Available: The forwarding rule is available.
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=["lsn-i35udpz3pxsmnf****"]
&LoadBalancerIds=["alb-x30o38azsuj0sx****"]
&<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>lsn-i35udpz3pxsmnf****</ListenerId>
        <LoadBalancerId>alb-x30o38azsuj0sx****</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" : "lsn-i35udpz3pxsmnf****",
    "LoadBalancerId" : "alb-x30o38azsuj0sx****",
    "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.