Creates forwarding rules for a listener. If your business needs to distribute and process traffic based on request attributes (such as domain names and paths) or data contained in requests (such as HTTP headers and cookies), you can customize forwarding rules for a listener. The listener performs different forwarding actions on access requests based on the forwarding rules.
Operation description
Before you invoke this operation to create forwarding rules, we recommend that you understand the principles and matching rules of forwarding rules. For more information, see Forwarding rules.
Take note of the following items when you invoke this operation:
-
CreateForwardingRules is an asynchronous operation. After you send a request, the system returns a forwarding rule ID but the forwarding rule is not yet created. The creation task continues to run in the background. You can invoke ListForwardingRules to query the status of the forwarding rule:
-
If the forwarding rule is in the configuring state, the forwarding rule is being created. In this state, you can only execute query operations.
-
If the forwarding rule is in the active state, the forwarding rule is created.
-
-
CreateForwardingRules does not support concurrent creation of forwarding rules within the same Alibaba Cloud Global Accelerator (GA) instance.
Try it now
Test
RAM authorization
|
Action |
Access level |
Resource type |
Condition key |
Dependent action |
|
ga:CreateForwardingRules |
create |
*Listener
*Accelerator
|
None | None |
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| RegionId |
string |
Yes |
The region ID of the Alibaba Cloud Global Accelerator (GA) instance. Set the value to ap-southeast-1. |
cn-hangzhou |
| ClientToken |
string |
No |
The client token that is used to ensure the idempotence of the request. You can use the client to generate the token, but you must make sure that the token is unique among different requests. The token can contain only ASCII characters. Note
If you do not specify this parameter, the system automatically uses the RequestId value as the ClientToken value. The RequestId value is different for each API request. |
02fb3da4**** |
| AcceleratorId |
string |
Yes |
The instance ID of the Alibaba Cloud Global Accelerator (GA). |
ga-bp17frjjh0udz4q**** |
| ListenerId |
string |
Yes |
The instance ID of the listener. |
lsr-bp1s0vzbi5bxlx5**** |
| ForwardingRules |
array<object> |
Yes |
The configurations of the forwarding rule. |
test |
|
array<object> |
No |
The configurations of the forwarding rule. |
||
| Priority |
integer |
No |
The priority of the forwarding rule. Valid values: 1 to 10000. A smaller value indicates a higher priority. |
1 |
| RuleConditions |
array<object> |
Yes |
The list of forwarding conditions. |
|
|
array<object> |
No |
The list of forwarding conditions. |
||
| RuleConditionType |
string |
No |
The type of the forwarding condition. Valid values:
|
Host |
| RuleConditionValue |
string |
No |
The value that corresponds to the forwarding condition type. Pass in different JSON string values based on the value of RuleConditionType.
|
["www.example.com", "www.aliyun.com"] |
| PathConfig |
object |
No |
The path configuration. Note
This parameter is not recommended. Use RuleConditionType and RuleConditionValue to configure forwarding conditions. |
|
| Values |
array |
No |
The path configuration. A path must be 1 to 128 characters long and must start with a forward slash (/). It can contain letters, digits, dollar signs ($), hyphens (-), underscores (_), periods (.), plus signs (+), forward slashes (/), ampersands (&), tildes (~), at signs (@), colons (:), and apostrophes ('). You can use asterisks (*) and question marks (?) as wildcards. Note
This parameter is deprecated. We recommend that you use RuleConditionType and RuleConditionValue to configure rule conditions. |
|
|
string |
No |
The path configuration. A path must be 1 to 128 characters long and must start with a forward slash (/). It can contain letters, digits, dollar signs ($), hyphens (-), underscores (_), periods (.), plus signs (+), forward slashes (/), ampersands (&), tildes (~), at signs (@), colons (:), and apostrophes ('). You can use asterisks (*) and question marks (?) as wildcards. Note
This parameter is deprecated. We recommend that you use RuleConditionType and RuleConditionValue to configure rule conditions. |
/test |
|
| HostConfig |
object |
No |
The domain name configuration. Note
This parameter is not recommended. Use RuleConditionType and RuleConditionValue to configure forwarding conditions. |
|
| Values |
array |
No |
The domain name configuration. Note
This parameter is deprecated. We recommend that you use RuleConditionType and RuleConditionValue to configure rule conditions. |
|
|
string |
No |
The domain name. A domain name must be 3 to 128 characters long and can contain letters, digits, hyphens (-), and periods (.). You can use asterisks (*) and question marks (?) as wildcards. Note
This parameter is deprecated. We recommend that you use RuleConditionType and RuleConditionValue to configure rule conditions. |
example.com |
|
| RuleActions |
array<object> |
Yes |
The forwarding actions. |
|
|
array<object> |
No |
The forwarding actions. |
||
| Order |
integer |
Yes |
The forwarding priority. Note
This parameter is not used. You do not need to configure it. |
20 |
| RuleActionType |
string |
Yes |
The type of the forwarding action. Valid values:
|
ForwardGroup |
| RuleActionValue |
string |
No |
The value that corresponds to the forwarding action type. Pass in different JSON string values based on the value of RuleActionType. A forwarding rule can contain at most one forwarding action of the ForwardGroup, Redirect, or FixResponse type. Forwarding actions of the Rewrite, AddHeader, and RemoveHeader types must be placed before the forwarding action of the ForwardGroup type.
|
[{"type":"endpointgroup","value":"epg-bp1l49ltx6iengvf2ks5z****"}] |
| ForwardGroupConfig |
object |
No |
The forwarding configuration. Note
This parameter is not recommended. Use RuleActionType and RuleActionValue to configure forwarding actions. |
|
| ServerGroupTuples |
array<object> |
Yes |
The endpoint group configuration. Note
This parameter is deprecated. We recommend that you use RuleActionType and RuleActionValue to configure rule actions. |
|
|
object |
Yes |
The endpoint group configuration. Note
This parameter is deprecated. We recommend that you use RuleActionType and RuleActionValue to configure rule actions. |
||
| EndpointGroupId |
string |
Yes |
The ID of the endpoint group. Note
This parameter is deprecated. We recommend that you use RuleActionType and RuleActionValue to configure rule actions. |
epg-bp1nktp3qgbcq9ih6**** |
| ForwardingRuleName |
string |
No |
Policy Name of the forwarding rule. Policy Name must be 2 to 128 characters in length and can contain letters, digits, periods (.), underscores (_), and hyphens (-). Policy Name must start with a letter or Chinese character. |
test |
| RuleDirection |
string |
No |
The direction in which the rule takes effect. You do not need to configure this parameter. The default value is request, which indicates that the rule takes effect on requests. |
request |
Response elements
|
Element |
Type |
Description |
Example |
|
object |
The response parameters. |
||
| RequestId |
string |
The request ID. |
64ADAB1E-0B7F-4FD8-A404-3BECC0E9CCFF |
| ForwardingRules |
array<object> |
The information about the forwarding rule. |
|
|
object |
The information about the forwarding rule. |
||
| ForwardingRuleId |
string |
The ID of the forwarding rule. |
frule-bp1dii16gu9qdvb34**** |
Examples
Success response
JSON format
{
"RequestId": "64ADAB1E-0B7F-4FD8-A404-3BECC0E9CCFF",
"ForwardingRules": [
{
"ForwardingRuleId": "frule-bp1dii16gu9qdvb34****"
}
]
}
Error codes
|
HTTP status code |
Error code |
Error message |
Description |
|---|---|---|---|
| 400 | NotExist.Listener | The listener does not exist. | The listener does not exist. |
| 400 | NotActive.Listener | The state of the listener is not active. | The listener is unstable. |
| 400 | NotExist.Accelerator | The accelerated instance does not exist. | The GA instance does not exist. |
| 400 | StateError.Accelerator | The state of the accelerated instance is invalid. | The status of the GA instance is invalid. |
| 400 | NotExist.BusinessRegion | The business region does not exist. | The business region does not exist. |
| 400 | NotExist.BasicBandwidthPackage | You must specify the basic bandwidth package. | You must specify the basic bandwidth package. |
| 400 | QuotaExceeded.EndPoint | The maximum number of endpoints is exceeded. | The maximum number of endpoints is exceeded. |
| 400 | Exist.EndpointGroup | The endpoint group already exists. | The endpoint group already exists. |
| 400 | NoPermission.VpcEndpoint | You are not authorized to perform the operation. | The user does not have permissions to create service linked roles. Contact the Alibaba Cloud account owner or the permission administrator to grant the current user AliyunGlobalAccelerationFullAccess or create custom permission policies for service linked role. The following content describes the detailed information about custom permission policies: ServiceName: vpcendpoint.ga.aliyuncs.com. Service linked role name: AliyunServiceRoleForGaVpc. Endpoint Permission: ram:CreateServiceLinkedRole. |
| 400 | QuotaExceeded.ForwardingRule | The number of forwarding rule exceeds the limit. | The number of forwarding rule exceeds the limit. |
| 400 | SystemBusy | System busy, please try again later. | |
| 400 | RepeatPathAndHost.ForwardingRule | The path and host %s are duplicated. | The path and host are duplicated. |
| 400 | QuotaExceeded.RuleConditionConfig | The number of paths and hosts exceeds the limit. | The number of paths and hosts exceeds the limit. |
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.