Creates multiple forwarding rules at a time.
Operation description
When you call this operation, take note of the following limits:
-
When you configure the Redirect action, do not use the default values for parameters other than HttpCode.
-
If you specify multiple actions in a forward rule, you must specify the ForwardGroup parameter along with the Rewrite parameter.
-
CreateRules is an asynchronous operation. After a request is sent, the system returns a request ID and runs the task in the background. You can call the ListRules operation to query the status of the forwarding rules.
- If the forwarding rules are in the Provisioning state, the forwarding rules are being created.
- If the forwarding rules are in the Available state, the forwarding rules are created.
-
You can set RuleConditions and RuleActions to add conditions and actions to a forwarding rule. Take note of the following limits on the number of conditions and the number of actions in each forwarding rule:
- Conditions: 5 for each basic ALB instance, 10 for each standard ALB instance, and 10 for each WAF-enabled ALB instance.
- Actions: 3 for each basic ALB instance, 5 for each standard ALB instance, and 5 for each WAF-enabled ALB instance.
Debugging
Authorization information
The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action
policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:
- Operation: the value that you can use in the Action element to specify the operation on a resource.
- Access level: the access level of each operation. The levels are read, write, and list.
- Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
- The required resource types are displayed in bold characters.
- If the permissions cannot be granted at the resource level,
All Resources
is used in the Resource type column of the operation.
- Condition Key: the condition key that is defined by the cloud service.
- Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
Operation | Access level | Resource type | Condition key | Associated operation |
---|---|---|---|---|
alb:CreateRules | create | *LoadBalancer acs:alb:{#regionId}:{#accountId}:loadbalancer/{#loadbalancerId} *ServerGroup acs:alb:{#regionId}:{#accountId}:servergroup/{#servergroupId} |
| none |
Request parameters
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
ListenerId | string | Yes | The ID of the Application Load Balancer (ALB) instance. | lsr-bp1bpn0kn908w4nbw**** |
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 request ID as the client token. The request ID may be different for each request.
| 5A2CFF0E-5718-45B5-9D4D-70B3FF3898 |
DryRun | boolean | No | Specifies whether to perform only a dry run, without performing the actual request. Valid values:
| false |
Rules | array<object> | Yes | The forwarding rules. | |
object | Yes | |||
Priority | integer | Yes | The priority of the forwarding rule. | 10 |
RuleActions | array<object> | Yes | The actions of the forwarding rule. | |
object | Yes | |||
FixedResponseConfig | object | No | The configuration of the custom response. | |
Content | string | No | The content of the custom response. | dssacav |
ContentType | string | No | The format of the content. | text/plain |
HttpCode | string | No | The HTTP status code in responses. | HTTP_200 |
ForwardGroupConfig | object | No | The configuration of the server group. | |
ServerGroupTuples | array<object> | No | The server groups to which requests are forwarded. | |
object | No | |||
ServerGroupId | string | No | The server group to which requests are forwarded. | sgp-k86c1ov501id6p**** |
Weight | integer | No | The weight of the server group. | 100 |
ServerGroupStickySession | object | No | The configuration of session persistence for the server groups. | |
Enabled | boolean | No | Specifies whether to enable session persistence. | false |
Timeout | integer | No | The timeout period of sessions. | 2 |
InsertHeaderConfig | object | No | The key of the header to be inserted. | |
Key | string | No | The key of the header. | key |
Value | string | No | The value of the header to be inserted. | UserDefined |
ValueType | string | No | The type of the header. | UserDefined |
Order | integer | Yes | The priority of the action. | 1 |
RedirectConfig | object | No | The configuration of the redirect action. | |
Host | string | No | The hostname to which requests are forwarded. | www.example.com |
HttpCode | string | No | The HTTP status code that indicates the redirect type. | 301 |
Path | string | No | The URL to which requests are redirected. | /test |
Port | string | No | The port to which requests are distributed. | 10 |
Protocol | string | No | The redirect protocol. | HTTP |
Query | string | No | The query string to which requests are redirected. | quert |
RewriteConfig | object | No | The configuration of the rewrite action. | |
Host | string | No | The hostname to which requests are rewritten. | www.example.com |
Path | string | No | The URL to which requests are redirected. | /tsdf |
Query | string | No | The query string of the URL to which requests are forwarded. | quedsa |
Type | string | Yes | The action. | ForwardGroup |
TrafficLimitConfig | object | No | The configuration of traffic throttling. | |
QPS | integer | No | The number of queries per second (QPS). Valid values: 1 to 1000000. | 100 |
PerIpQps | integer | No | The number of requests per IP address. Value values: 1 to 1000000. Note
If both the QPS and PerIpQps parameters are specified, the value of the QPS parameter is smaller than the value of the PerIpQps parameter.
| 80 |
TrafficMirrorConfig | object | No | The configuration of traffic mirroring. | |
TargetType | string | No | The type of target to which network traffic is mirrored. | ForwardGroupMirror |
MirrorGroupConfig | object | No | The configuration of the server group to which traffic is mirrored. | |
ServerGroupTuples | array<object> | No | The server group to which traffic is mirrored. | |
object | No | The server group to which traffic is mirrored. | ||
ServerGroupId | string | No | The server group ID. | srg-00mkgijak0w4qgz9**** |
RemoveHeaderConfig | object | No | The HTTP header to be removed. | |
Key | string | No | The key of the header to be removed. | test |
CorsConfig | object | No | The CORS configuration. | |
AllowOrigin | array | No | The trusted origins of CORS requests. | |
string | No | http://example.com | ||
AllowMethods | array | No | The trusted HTTP methods of CORS requests. | |
string | No | GET | ||
AllowHeaders | array | No | The trusted headers of CORS requests. | |
string | No | test_123 | ||
ExposeHeaders | array | No | The headers that can be exposed. | |
string | No | test_123 | ||
AllowCredentials | string | No | Specifies whether to allow credentials to be carried in CORS requests. | on |
MaxAge | long | No | The maximum cache time of dry run requests in the browser. | 1000 |
RuleConditions | array<object> | Yes | The match conditions of the forwarding rule. | |
object | Yes | |||
CookieConfig | object | No | The key-value pairs of the cookie. | |
Values | array<object> | No | The cookie value. | |
object | No | |||
Key | string | No | The cookie key. | test |
Value | string | No | The cookie value. | test |
HeaderConfig | object | No | The configuration of the header. | |
Key | string | No | The header key. | Port |
Values | array | No | The header values. | |
string | No | 5006 | ||
HostConfig | object | No | The configuration of the hosts. | |
Values | array | No | The hostname. | |
string | No | www.example.com | ||
MethodConfig | object | No | The configurations of the request methods. | |
Values | array | No | The request methods. | |
string | No | PUT | ||
PathConfig | object | No | The configurations of the forwarding URLs. | |
Values | array | No | The forwarding URLs. | |
string | No | /test | ||
QueryStringConfig | object | No | The configurations of the query strings. | |
Values | array<object> | No | The configurations of the query string. | |
object | No | |||
Key | string | No | They key of the query string. | test |
Value | string | No | The value of the query string. | test |
ResponseHeaderConfig | object | No | The configuration of the header. | |
Key | string | No | The key of the header. | Port |
Values | array | No | The value of the header. | |
Value | string | No | 5006 | |
ResponseStatusCodeConfig | object | No | The configurations of the response status codes. | |
Values | array | No | The response status codes. | |
Value | string | No | 200 | |
Type | string | Yes | The type of forwarding rule. | Host |
SourceIpConfig | object | No | Traffic matching based on source IP addresses. | |
Values | array | No | Traffic matching based on source IP addresses. | |
string | No | 192.168.0.0/32 | ||
RuleName | string | Yes | The name of the forwarding rule. | test |
Direction | string | No | The direction to which the forwarding rule is applied. | Request |
Tag | array<object> | No | The tags. | |
object | No | The tag. | ||
Key | string | No | The tag key. The tag key can be up to 128 characters in length. It cannot start with aliyun or acs: and cannot contain http:// or https://. | env |
Value | string | No | The tag value. The tag value can be up to 128 characters in length. It cannot start with aliyun or acs: and cannot contain http:// or https://. | product |
Response parameters
Examples
Sample success responses
JSON
format
{
"JobId": "72dcd26b-f12d-4c27-b3af-18f6aed5****",
"RequestId": "365F4154-92F6-4AE4-92F8-7FF34B540710",
"RuleIds": [
{
"RuleId": "rule-a3x3pg1yohq3lq****",
"Priority": 10
}
]
}
Error codes
HTTP status code | Error code | Error message | Description |
---|---|---|---|
400 | IncorrectStatus.Listener | The status of %s [%s] is incorrect. | - |
400 | OperationDenied.IpGroupCanNotUsedForMirrorAction | The operation is not allowed because of %s. | The operation is not allowed because of %s. |
400 | OperationDenied.SameGroupForForwardAndMirrorAction | The operation is not allowed because of %s. | The operation is not allowed because of %s. |
400 | OperationDenied.GRPCServerGroup | The operation is not allowed because of %s. | - |
400 | Conflict.Priority | There is already %s having the same configuration with %s. | - |
400 | ResourceQuotaExceeded.LoadBalancerRulesNum | The quota of %s is exceeded for resource %s, usage %s/%s. | - |
400 | ResourceQuotaExceeded.ServerGroupAttachedNum | The quota of %s is exceeded for resource %s, usage %s/%s. | - |
400 | ResourceQuotaExceeded.LoadBalancerServersNum | The quota of %s is exceeded for resource %s, usage %s/%s. | - |
400 | ResourceQuotaExceeded.ServerAddedNum | The quota of %s is exceeded for resource %s, usage %s/%s. | - |
400 | QuotaExceeded.RuleWildcardsNum | The quota of %s is exceeded, usage %s/%s. | The quota of %s is exceeded, usage %s/%s. |
400 | QuotaExceeded.RuleMatchEvaluationsNum | The quota of %s is exceeded, usage %s/%s. | - |
400 | QuotaExceeded.RuleActionsNum | The quota of %s is exceeded, usage %s/%s. | The quota of %s is exceeded. Usage: %s/%s. |
400 | Mismatch.VpcId | The %s is mismatched for %s and %s. | The %s is mismatched for %s and %s. |
400 | Mismatch.Protocol | The %s is mismatched for %s and %s. | The %s is mismatched for %s and %s. |
400 | OperationDenied.RewriteMissingForwardGroup | The operation is not allowed because of RewriteMissingForwardGroup. | The operation is not allowed because rewrite is missing the forward group. |
400 | OperationDenied.MirrorActionSupportHttpGroupOnly | The operation is not allowed because of MirrorActionSupportHttpGroupOnly. | - |
400 | OperationDenied.ProtocolMustSameForForwardGroupAction | The operation is not allowed because of ProtocolMustSameForForwardGroupAction. | - |
404 | ResourceNotFound.Listener | The specified resource %s is not found. | - |
404 | ResourceNotFound.ServerGroup | The specified resource %s is not found. | - |
For a list of error codes, visit the Service error codes.
Change history
Change time | Summary of changes | Operation |
---|---|---|
2024-12-11 | The Error code has changed | View Change Details |
2024-11-28 | The Error code has changed | View Change Details |
2024-09-23 | The Error code has changed | View Change Details |
2024-01-18 | The Error code has changed | View Change Details |
2023-11-09 | The Error code has changed | View Change Details |