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 FFmyTO70tTpLG6I3FmYAXGKPd****

The token that is used for the next query. Valid values:

  • If NextToken is empty, it indicates that no next query is to be sent.
  • If a value of NextToken is returned, the value is the token that is used for the next query.
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 is unique.
RuleActions Array of Action

The actions of the forwarding rule.

FixedResponseConfig Object

The configuration of the custom response.

Content String dssacav

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

ContentType String text/plain

The content type.

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

HttpCode String HTTP_2xx

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

ForwardGroupConfig Object

The configuration of the server group.

ServerGroupTuples Array of ServerGroupTuple

The list of server groups to which requests are forwarded.

ServerGroupId String sg-atstuj3rtoptyui****

The server group to which requests are forwarded.

Weight Integer 2

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

InsertHeaderConfig Object

The configuration of the header to be inserted.

Key String key

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

Note Cookie and Host are not supported.
Value String ClientSrcPort

The value of the header to be inserted.

  • If ValueType is set to SystemDefined, the system returns one of the following header values:
    • 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 listening port.
  • If ValueType is set to UserDefined, a custom header value is returned. The header value is 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. Asterisks (*) and question marks (?) can be used as wildcards. The header value does not start or end with a space character.
  • If ValueType is set to ReferenceHeader, the value of a request header is referenced. The header value is 1 to 128 characters in length, and can contain lowercase letters, digits, underscores (_), and hyphens (-).
ValueType String SystemDefined

The type of the header. Valid values:

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

RedirectConfig Object

The configuration of the redirect action.

Host String www.example.com

The hostname to which requests are redirected. Valid values:

  • ${host} (default): If ${host} is returned, no other character is appended.
  • Limits on the 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 wildcards.
    • The hostname contains at least one period (.) but does not start or end with a period (.).
    • The rightmost domain label can contain only letters and wildcard characters. It does not contain digits or hyphens (-).
    • The domain labels do not start or end with hyphens (-).
    • An asterisk (*) and question mark (?) can appear anywhere in a domain label as a wildcard.
HttpCode String 301

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

Path String /test

The path to which requests are redirected. Valid values:

  • Default value: ${path}. You can also combine the variable with ${host}, ${protocol}, and ${port}. Then, the path is the combination of ${host}, ${protocol}, and ${port}. Each variable cannot be specified more than once. You can specify one or more of the preceding variables in each request. You can also combine them with the following characters.
  • Limits on the value:
    • The value is 1 to 128 characters in length.
    • It starts with a forward slash (/) and can contain letters, digits, and the following special characters: $ - _ .+ / & ~ @ :. It does not contain the following special characters: " % # ; ! ( ) [ ]^ , ". Asterisks (*) and question marks (?) can be used as wildcards.
    • The value is case-sensitive.
Port String 10

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.
Protocol String HTTP

The redirect protocol. Valid values:

  • ${protocol} (default): If ${protocol} is returned, no other character is appended.
  • Valid values: HTTP and HTTPS.
Note HTTPS listeners do not support HTTPS to HTTP redirection.
Query String quert

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

RewriteConfig Object

The configuration of the rewrite action.

Host String www.example.com

The hostname to which requests are forwarded. Valid values:

  • ${host} (default): If ${host} is returned, no other character is appended.
  • Limits on the 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 wildcards.
    • The hostname contains at least one period (.) but does not start or end with a period (.).
    • The rightmost domain label can contain only letters and wildcard characters. It does not contain digits or hyphens (-).
    • The domain labels do not start or end with hyphens (-).
    • An asterisk (*) and question mark (?) can appear anywhere in a domain label as a wildcard.
Path String /tsdf

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: " % # ; ! ( ) [ ] ^ , ". This value is case-sensitive.

Query String quedsa

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: # [ ] { } \ | < > &.

TrafficMirrorConfig Object

The configuration of the action to mirror traffic.

MirrorGroupConfig Object

The server group to which network traffic is mirrored.

ServerGroupTuples Array of ServerGroupTuple

The list of server groups to which network traffic is mirrored.

ServerGroupId String srg-00mkgijak0w4qgz9****

The ID of the server group.

Weight Integer 2

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

TrafficLimitConfig Object

The configuration of the action to throttle traffic.

QPS Integer 4

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

Type String ForwardGroup

The type of the action. Valid values:

  • ForwardGroup: forwards a request 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 network traffic.

A forwarding rule contains one last action and the actions that you want to perform before the last action:

  • FinalType: the last action to be performed in a forwarding rule. Each forwarding rule can contain only one FinalType action. The FinalType action can be a ForwardGroup, Redirect, or FixedResponse action.
  • ExtType: the action 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 match conditions of the forwarding rule.

CookieConfig Object

The configuration of the cookie.

Values Array of Value

The key-value pairs of cookies.

Key String test

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 (?). However, uppercase letters, space characters, and the following special characters are not supported: # [ ] { } \ | < > &.

Value String test

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 (?). However, uppercase letters, space characters, and the following special characters are not supported: # [ ] { } \ | < > &.

HeaderConfig Object

The configuration of the header.

Key String Port

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

Values Array of String 5006

The value of the header. The value is 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. For example, lowercase letters, asterisks (*), and question marks (?). However, uppercase letters are not supported. The value does not start or end with a space character.

HostConfig Object

The configuration of the host.

Values Array of String www.example.com

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 do not start or end with hyphens (-). Asterisks (*) and question marks (?) can appear 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.

Values Array of String /test

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: " % # ; ! ( ) [ ] ^ , ". This value is case-sensitive.

QueryStringConfig Object

The configuration of the query string.

Values Array of Value

The list of query strings.

Key String test

The key of the query string. The key is 1 to 100 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: # [ ] { } \ | < > &.

Value String test

The value of the query string. The value is 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: # [ ] { } \ | < > &.

SourceIpConfig Object

The source IP address based on which user traffic is matched.

Values Array of String 192.168.XX.XX/32

The IP addresses or CIDR blocks.

A forwarding rule contains at most five IP addresses or CIDR blocks.

Type String Host

The type of the forwarding rule. Valid values:

  • Host: Requests are distributed based on hosts.
  • Path: Requests are distributed based on paths.
  • Header: Requests are distributed based on HTTP headers.
  • QueryString: Requests are distributed based on query strings.
  • Method: Requests are distributed based on request methods.
  • Cookie: Requests are distributed based on cookies.
  • SourceIp: Requests are distributed based on source IP addresses.
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 starts with a letter.

RuleStatus String Available

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.
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>FFmyTO70tTpLG6I3FmYAXGKPd****</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>HTTP_2xx</HttpCode>
            </FixedResponseConfig>
            <ForwardGroupConfig>
                <ServerGroupTuples>
                    <ServerGroupId>sg-atstuj3rtoptyui****</ServerGroupId>
                    <Weight>2</Weight>
                </ServerGroupTuples>
            </ForwardGroupConfig>
            <InsertHeaderConfig>
                <Key>key</Key>
                <Value>ClientSrcPort</Value>
                <ValueType>SystemDefined</ValueType>
            </InsertHeaderConfig>
            <Order>1</Order>
            <RedirectConfig>
                <Host>www.example.com</Host>
                <HttpCode>301</HttpCode>
                <Path>/test</Path>
                <Port>10</Port>
                <Protocol>HTTP</Protocol>
                <Query>quert</Query>
            </RedirectConfig>
            <RewriteConfig>
                <Host>www.example.com</Host>
                <Path>/tsdf</Path>
                <Query>quedsa</Query>
            </RewriteConfig>
            <TrafficMirrorConfig>
                <MirrorGroupConfig>
                    <ServerGroupTuples>
                        <ServerGroupId>srg-00mkgijak0w4qgz9****</ServerGroupId>
                        <Weight>2</Weight>
                    </ServerGroupTuples>
                </MirrorGroupConfig>
            </TrafficMirrorConfig>
            <TrafficLimitConfig>
                <QPS>4</QPS>
            </TrafficLimitConfig>
            <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.example.com</Values>
            </HostConfig>
            <MethodConfig>
                <Values>PUT</Values>
            </MethodConfig>
            <PathConfig>
                <Values>/test</Values>
            </PathConfig>
            <QueryStringConfig>
                <Values>
                    <Key>test</Key>
                    <Value>test</Value>
                </Values>
            </QueryStringConfig>
            <SourceIpConfig>
                <Values>192.168.XX.XX/32</Values>
            </SourceIpConfig>
            <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" : "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"
      },
      "RewriteConfig" : {
        "Host" : "www.example.com",
        "Path" : "/tsdf",
        "Query" : "quedsa"
      },
      "TrafficMirrorConfig" : {
        "MirrorGroupConfig" : {
          "ServerGroupTuples" : [ {
            "ServerGroupId" : "srg-00mkgijak0w4qgz9****",
            "Weight" : 2
          } ]
        }
      },
      "TrafficLimitConfig" : {
        "QPS" : 4
      },
      "Type" : "ForwardGroup"
    } ],
    "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" ]
      },
      "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.