Queries forwarding rules.

Note This operation is used to query only custom forwarding rules, not the default forwarding rule.

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 ListForwardingRules

The operation that you want to perform. Set the value to ListForwardingRules.

RegionId String Yes cn-hangzhou

The ID of the region where the Global Accelerator (GA) instance is deployed. Set the value to cn-hangzhou.

ClientToken String No 02fb3da4****

The client token that is used to ensure the idempotence of the request.

You can use the client to generate the value, but you must ensure that it is unique among all requests. The ClientToken value contain only ASCII characters.

Note If you do not set this parameter, the system sets ClientToken to the value of RequestId. The value of RequestId may be different for each API request.
ListenerId String Yes lsr-bp1s0vzbi5bxlx5pw****

The ID of the listener.

AcceleratorId String Yes ga-bp17frjjh0udz4qzk****

The ID of the GA instance.

ForwardingRuleId String No frule-bp19a3t3yzr21q3****

The ID of the forwarding rule.

NextToken String No FFmyTO70tTpLG6I3FmYAXGKPd****

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

  • If this is your first query or no subsequent query is to be sent, ignore this parameter.
  • If a next query is to be sent, set the value to the value of NextToken that is returned from the last call.
MaxResults Integer Yes 20

The number of entries to return on each page. Valid values: 1 to 100. Default value: 20.

Response parameters

Parameter Type Example Description
RequestId String CFC67ED9-4AB1-431F-B6E3-A752B7B8CCD4

The ID of the request.

TotalCount Integer 1

The number of entries returned.

NextToken String FFmyTO70tTpLG6I3FmYAXGKPd****

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

  • If NextToken is not returned, it indicates that no additional results exist.
  • If NextToken is returned, the value indicates the token that is used for the next query.
MaxResults Integer 20

The number of entries returned per page.

ForwardingRules Array of ForwardingRules

The information about the forwarding rules.

Priority Integer 1000

The priority of the forwarding rule.

Valid values: 1 to 10000. A lower value indicates a higher priority.

ForwardingRuleId String frule-bp19a3t3yzr21q3****

The ID of the forwarding rule.

ForwardingRuleName String auto_named_rule

The name of the forwarding rule.

ForwardingRuleDirection String request

The direction in which the forwarding rule takes effect.

By default, request is returned, which indicates that the forwarding rule takes effect on requests.

ForwardingRuleStatus String active

The status of the forwarding rule.

  • active: The forwarding rule is normal.
  • configuring: The forwarding rule is being modified.
  • deleting: The forwarding rule is being deleted.
RuleConditions Array of RuleConditions

The forwarding conditions.

RuleConditionType String Host

The type of the forwarding condition.

  • Host: domain name
  • Path: path
  • RequestHeader: HTTP header
  • Query: query string
  • Method: HTTP method
  • Cookie: cookie
  • SourceIP: source IP address
RuleConditionValue String ["www.example.com", "www.aliyun.com"]

The value of the forwarding condition type.

Different JSON strings are returned based on the RuleConditionType parameter.

  • If RuleConditionType is set to Host, a domain name condition is returned. If multiple domain names are returned in a forwarding condition, the relationship between the domain names is OR.
  • If RuleConditionType is set to Path, a path condition is returned. If multiple forwarding conditions whose types are path are returned in a forwarding rule, the relationship between the forwarding conditions is OR. If multiple paths are returned in a forwarding condition, the relationship between the paths is OR.
  • If RuleConditionType is set to RequestHeader, an HTTP header condition that consists of key-value pairs is returned.
  • If RuleConditionType is set to Query, a query string condition that consists of key-value pairs is returned.
  • If RuleConditionType is set to Method, an HTTP method condition is returned.
  • If RuleConditionType is set to Cookie, a cookie condition that consists of key-value pairs is returned.
  • If RuleConditionType is set to SourceIP, a source IP address condition is returned. If multiple source IP addresses are returned in a forwarding condition, the relationship between the source IP addresses is OR.
PathConfig Object

The configuration of the path.

Note GA instances created after July 12, 2022 support all forwarding condition types and action types. We recommend that you query forwarding conditions by calling the RuleConditionType and RuleConditionValue operations.
Values Array of String /test

The path.

The path must be 1 to 128 characters in length and must start with a forward slash (/). The path can contain only letters, digits, and the following special characters: $ - _ . + / & ~ @ : '. Supported wildcard characters are asterisks (*) and question marks (?).

Note GA instances created after July 12, 2022 support all forwarding condition types and action types. We recommend that you query forwarding conditions by calling the RuleConditionType and RuleConditionValue operations.
HostConfig Object

The configuration of the domain name.

Note GA instances created after July 12, 2022 support all forwarding condition types and action types. We recommend that you query forwarding conditions by calling the RuleConditionType and RuleConditionValue operations.
Values Array of String www.example.com

The domain name.

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

Note GA instances created after July 12, 2022 support all forwarding condition types and action types. We recommend that you query forwarding conditions by calling the RuleConditionType and RuleConditionValue operations.
RuleActions Array of RuleActions

The forwarding action.

Order Integer 1

The forwarding priority.

Note This parameter does not take effect.
RuleActionType String ForwardGroup

The type of the forwarding action. Valid values:

  • ForwardGroup: forwards a request.
  • Redirect: redirects a request.
  • FixResponse: returns a fixed response.
  • Rewrite: rewrites a request.
  • AddHeader: adds a header to a request.
  • RemoveHeaderConfig: deletes the header of a request.
RuleActionValue String [{"type":"endpointgroup", "value":"epg-bp1enpdcrqhl78g6r****"}]

The value of the forwarding action type.

Different JSON strings are returned based on the RuleActionType parameter.

  • If RuleActionType is set to ForwardGroup, the information about a virtual endpoint group is returned. Configuration information:
    • type: the type of the resource that is returned. The value is endpointgroup.
    • value: the ID of the virtual endpoint group that is returned.
  • If RuleActionType is set to Redirect, the redirecting configuration is returned. Configuration information:
    • protocol: the protocol of requests after the requests are redirected.
    • domain: the domain name to which requests are redirected.
    • port: the port to which requests are redirected.
    • path: the path to which requests are redirected.
    • query: the query string of the requests that are redirected.
    • code: the redirecting code.
  • If RuleActionType is set to FixResponse, the information about the fixed response that you configured is returned. Configuration information:
    • code: the HTTP status code that is returned.
    • type: the type of the response content that is returned.
    • content: the response content that is returned.
  • If RuleActionType is set to AddHeader, the information about the HTTP header that is added is returned. Configuration information:
    • name: the name of the HTTP header that is returned.
    • type: the content type of the HTTP header that is returned.
    • value: the content of the HTTP header that is returned.
  • If RuleActionType is set to RemoveHeader, the information about the HTTP header that is deleted is returned.
  • If RuleActionType is set to Rewrite, the rewriting configuration is returned. Configuration information:
    • domain: the domain name to which requests are redirected.
    • path: the path to which requests are redirected.
    • query: the query string of the requests that are redirected.
ForwardGroupConfig Object

The configuration of the forwarding action.

Note GA instances created after July 12, 2022 support all forwarding condition types and action types. We recommend that you query forwarding actions by calling the RuleActionType and RuleActionValue operations.
ServerGroupTuples Array of ServerGroupTuples

The information about the endpoint group.

Note GA instances created after July 12, 2022 support all forwarding condition types and action types. We recommend that you query forwarding actions by calling the RuleActionType and RuleActionValue operations.
EndpointGroupId String epg-bp1enpdcrqhl78g6r****

The ID of the endpoint group.

Note GA instances created after July 12, 2022 support all forwarding condition types and action types. We recommend that you query forwarding actions by calling the RuleActionType and RuleActionValue operations.
ListenerId String lsr-bp1s0vzbi5bxlx5****

The ID of the listener.

Examples

Sample requests

http(s)://[Endpoint]/?Action=ListForwardingRules
&RegionId=cn-hangzhou
&ClientToken=02fb3da4****
&ListenerId=lsr-bp1s0vzbi5bxlx5pw****
&AcceleratorId=ga-bp17frjjh0udz4qzk****
&ForwardingRuleId=frule-bp19a3t3yzr21q3****
&NextToken=FFmyTO70tTpLG6I3FmYAXGKPd****
&MaxResults=20
&Common request parameters

Sample success responses

XML format

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

<ListForwardingRulesResponse>
    <RequestId>CFC67ED9-4AB1-431F-B6E3-A752B7B8CCD4</RequestId>
    <TotalCount>1</TotalCount>
    <NextToken>FFmyTO70tTpLG6I3FmYAXGKPd****</NextToken>
    <MaxResults>20</MaxResults>
    <ForwardingRules>
        <Priority>1000</Priority>
        <ForwardingRuleId>frule-bp19a3t3yzr21q3****</ForwardingRuleId>
        <ForwardingRuleName>auto_named_rule</ForwardingRuleName>
        <ForwardingRuleDirection>request</ForwardingRuleDirection>
        <ForwardingRuleStatus>active</ForwardingRuleStatus>
        <RuleConditions>
            <RuleConditionType>Host</RuleConditionType>
            <RuleConditionValue>["www.example.com", "www.aliyun.com"]</RuleConditionValue>
            <PathConfig>
                <Values>/test</Values>
            </PathConfig>
            <HostConfig>
                <Values>www.example.com</Values>
            </HostConfig>
        </RuleConditions>
        <RuleActions>
            <Order>1</Order>
            <RuleActionType>ForwardGroup</RuleActionType>
            <RuleActionValue>[{"type":"endpointgroup", "value":"epg-bp1enpdcrqhl78g6r****"}]</RuleActionValue>
            <ForwardGroupConfig>
                <ServerGroupTuples>
                    <EndpointGroupId>epg-bp1enpdcrqhl78g6r****</EndpointGroupId>
                </ServerGroupTuples>
            </ForwardGroupConfig>
        </RuleActions>
        <ListenerId>lsr-bp1s0vzbi5bxlx5****</ListenerId>
    </ForwardingRules>
</ListForwardingRulesResponse>

JSON format

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

{
  "RequestId" : "CFC67ED9-4AB1-431F-B6E3-A752B7B8CCD4",
  "TotalCount" : 1,
  "NextToken" : "FFmyTO70tTpLG6I3FmYAXGKPd****",
  "MaxResults" : 20,
  "ForwardingRules" : [ {
    "Priority" : 1000,
    "ForwardingRuleId" : "frule-bp19a3t3yzr21q3****",
    "ForwardingRuleName" : "auto_named_rule",
    "ForwardingRuleDirection" : "request",
    "ForwardingRuleStatus" : "active",
    "RuleConditions" : [ {
      "RuleConditionType" : "Host",
      "RuleConditionValue" : "[\"www.example.com\", \"www.aliyun.com\"]",
      "PathConfig" : {
        "Values" : [ "/test" ]
      },
      "HostConfig" : {
        "Values" : [ "www.example.com" ]
      }
    } ],
    "RuleActions" : [ {
      "Order" : 1,
      "RuleActionType" : "ForwardGroup",
      "RuleActionValue" : "[{\"type\":\"endpointgroup\", \"value\":\"epg-bp1enpdcrqhl78g6r****\"}]",
      "ForwardGroupConfig" : {
        "ServerGroupTuples" : [ {
          "EndpointGroupId" : "epg-bp1enpdcrqhl78g6r****"
        } ]
      }
    } ],
    "ListenerId" : "lsr-bp1s0vzbi5bxlx5****"
  } ]
}

Error codes

HttpCode Error code Error message Description
400 NotExist.Listener The listener does not exist. The error message returned because the specified listener does not exist.
400 NotActive.Listener The state of the listener is not active. The error message returned because the specified listener is unstable.
400 NotExist.Accelerator The accelerated instance does not exist. The error message returned because the GA instance does not exist.
400 StateError.Accelerator The state of the accelerated instance is invalid. The error message returned because the specified GA instance is in an invalid state.
400 NotExist.BusinessRegion The business region does not exist. The error message returned because the specified region does not exist.
400 NotExist.BasicBandwidthPackage You must specify the basic bandwidth package. The error message returned because no basic bandwidth plan is specified.
400 QuotaExceeded.EndPoint The maximum number of endpoints is exceeded. The error message returned because the number of endpoints reaches the upper limit.
400 Exist.EndpointGroup The endpoint group already exists. The error message returned because the specified endpoint group already exists.
400 NoPermission.VpcEndpoint You are not authorized to perform the operation. The error message returned because you are not authorized to create the service-linked role. Contact the owner of the Alibaba Cloud account or the administrator to attach the AliyunGlobalAccelerationFullAccess policy or a custom permission policy that grants the permissions to create the required service-linked role to your RAM user. In the custom policy, the service name must be set to vpcendpoint.ga.aliyuncs.com, the service-linked role to AliyunServiceRoleForGaVpcEndpoint, and the permissions to ram:CreateServiceLinkedRole.

For a list of error codes, see Service error codes.