All Products
Search
Document Center

Server Load Balancer:UpdateRulesAttribute

Last Updated:Sep 23, 2024

Modifies the attributes of forwarding rules.

Operation description

UpdateRulesAttribute 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 task.

  • If a forwarding rule is in the Configuring state, the forwarding rule is being updated.

  • If a forwarding rule is in the Available state, the forwarding rule is updated.

  • You can set RuleConditions and RuleActions to add conditions and actions to a forwarding rule. Take note of the following limits on the maximum number of conditions and the maximum number of actions in each forwarding rule:

    • Limits on conditions: 5 for a basic Application Load Balancer (ALB) instance, 10 for a standard ALB instance, and 10 for a WAF-enabled ALB instance.
    • Limits on actions: 3 for a basic ALB instance, 5 for a standard ALB instance, and 5 for a WAF-enabled ALB instance.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer.

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.
OperationAccess levelResource typeCondition keyAssociated operation
alb:UpdateRulesAttributeupdate
  • LoadBalancer
    acs:alb:{#regionId}:{#accountId}:loadbalancer/{#LoadBalancerId}
    none
none

Request parameters

ParameterTypeRequiredDescriptionExample
ClientTokenstringNo

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 client 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.
123e4567-e89b-12d3-a456-426655440000
Rulesarray<object>Yes

The forwarding rules. You can specify at most 10 forwarding rules in each call.

objectYes

The forwarding rule.

PriorityintegerNo

The priority of the forwarding rule. Valid values: 1 to 10000. A smaller value specifies a higher priority. You can specify at most 20 rule priorities.

Note The priority of each forwarding rule within a listener must be unique.
10
RuleNamestringNo

The name of the forwarding rule. The name must be 2 to 128 letters in length, and can contain letters, digits, periods (.), underscores (_), and hyphens (-). The name must start with a letter. You can specify at most 20 rule names.

rule-instance-test
RuleActionsarray<object>No

The action of the forwarding rule.

objectYes

The action of the forwarding rule.

FixedResponseConfigobjectNo

The configuration of the action to return a custom response. You can specify at most 20 custom responses.

ContentstringNo

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

dssacav
ContentTypestringNo

The content format of the response.

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

text/plain
HttpCodestringNo

The HTTP status code in responses. Valid values: 2xx, 4xx, 5xx. The value must be a numeric string. x must be a digit.

200
ForwardGroupConfigobjectNo

The configuration of the action to forward requests to server groups. You can specify at most 20 actions.

ServerGroupTuplesarray<object>No

The server groups to which requests are forwarded.

objectNo

The server group to which requests are forwarded.

ServerGroupIdstringNo

The server group to which requests are forwarded.

sg-atstuj3rtoptyui****
WeightintegerNo

The weight of the server group. A larger value specifies a higher weight. A server group with a higher weight receives more requests. Valid values: 0 to 100.

  • If the number of destination server groups is 1, the default weight of the server group is 100, unless you specify a weight.
  • If the number of destination server groups is larger than 1, you must specify a weight.
30
ServerGroupStickySessionobjectNo

The configuration of session persistence for server groups.

EnabledbooleanNo

Specifies whether to enable session persistence. Valid values:

  • true: enables session persistence.
  • false (default): disables session persistence.
false
TimeoutintegerNo

The timeout period of sessions. Unit: seconds Valid values: 1 to 86400.

2
InsertHeaderConfigobjectNo

The configuration of the action to insert a header. You can specify at most 20 actions.

CoverEnabledbooleanNo

Specifies whether to overwrite the header in the request. Valid values:

  • true: overwrites the request header.
  • false (default): does not overwrite the request header.
false
KeystringNo

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

Note The following header keys are not supported: slb-id, slb-ip, x-forwarded-for, x-forwarded-proto, x-forwarded-eip, x-forwarded-port, x-forwarded-client-srcport, connection, upgrade, content-length, transfer-encoding, keep-alive, te, host, cookie, remoteip, and authority. Header keys are not case-sensitive.
test
ValuestringNo

The value of the header.

  • If ValueType is set to SystemDefined, you can set the Value parameter to one of the following values:

    • ClientSrcPort: the client port.
    • ClientSrcIp: the IP address of the client.
    • Protocol: the request protocol (HTTP or HTTPS).
    • SLBId: the ID of the ALB instance.
    • SLBPort: the listener port of the ALB instance.
  • If ValueType is set to UserDefined, you can specify a custom header value. The header value must be 1 to 128 characters in length, and can contain wildcard characters, such as asterisks (*) and question marks (?), and printable characters whose ASCII values are larger than or equal to 32 and smaller than 127. The header value cannot start or end with a space character.

  • If ValueType is set to ReferenceHeader, you can reference a value from request headers. The value must be 1 to 128 characters in length, and can contain lowercase letters, digits, hyphens (-), and underscores (_).

UserDefined
ValueTypestringNo

The type of header. Valid values:

  • UserDefined: a user-defined header.
  • ReferenceHeader: a header that is referenced from a request header.
  • SystemDefined: a system-defined header.
UserDefined
OrderintegerYes

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 cannot be left empty. The priority of each action within a forwarding rule must be unique. You can specify at most 20 forwarding rule priorities.

1
RedirectConfigobjectNo

The configuration of the redirect action. You can specify at most 20 redirect actions.

HoststringNo

The hostname to which requests are redirected.

The hostname must meet the following requirements:

  • The hostname must be 3 to 128 characters in length, and can contain lowercase letters, digits, and the following special characters: - . * = ~ _ + \ ^ ! $ & | ( ) [ ] ?.
  • The hostname must contain at least one period (.) but cannot start or end with a period (.).
  • The rightmost domain label can contain only letters, asterisks (), and question marks (?), and cannot contain digits or hyphens (-). The leftmost domain label can contain asterisks ().
  • The domain labels cannot start or end with hyphens (-). You can specify asterisks (∗) and question marks (?) anywhere in a domain label.
www.example.com
HttpCodestringNo

The HTTP status code that indicates the redirect type. Valid values: 301, 302, 303, 307, and 308.

301
PathstringNo

The path of the destination to which requests are forwarded. Valid values:

  • ${path} (default): You can reference **${host}**, ${protocol} and **${port}**. Each variable can be used only once. The preceding variables can be used at the same time or combined with a custom value.

  • A custom value. You must ensure that the custom value meets the following requirements:

    • The path must be 1 to 128 characters in length. You can use asterisks (*) and question marks (?) as wildcard characters.
    • The path can contain letters, digits, and the following special characters: $ - _ . + / & ~ @ : ' * ?. It must start with a forward slash (/) and cannot contain the following characters: " % # ; ! ( ) [ ] ^ , ".
/test
PortstringNo

The port to which requests are forwarded.

Valid values: 1 to 63335.

10
ProtocolstringNo

The protocol of the destination to which requests are forwarded. Valid values:

Valid values for HTTP listeners: HTTP and HTTPS.

Valid values for HTTPS listeners: HTTPS.

HTTP
QuerystringNo

The query string to which requests are redirected.

The query string must be 1 to 128 characters in length, and can contain printable characters, excluding uppercase letters and the following special characters: # [ ] { } \ | < > &.

quert
RewriteConfigobjectNo

The configuration of the rewrite action. You can specify at most 20 actions.

HoststringNo

The hostname of the destination to which requests are forwarded.

The hostname must meet the following requirements:

  • The hostname must be 3 to 128 characters in length, and can contain lowercase letters, digits, and the following special characters: - . * = ~ _ + \ ^ ! $ & | ( ) [ ] ?.
  • The hostname must contain at least one period (.) but cannot start or end with a period (.).
  • The rightmost domain label can contain only letters, asterisks (), and question marks (?), and cannot contain digits or hyphens (-). The leftmost domain label can contain asterisks ().
  • The domain labels cannot start or end with hyphens (-). You can specify asterisks (∗) and question marks (?) anywhere in a domain label.
www.example.com
PathstringNo

The path to which requests are forwarded.

  • ${path} (default): You can reference **${host}**, ${protocol} and **${port}**. Each variable can be used only once. The preceding variables can be used at the same time or combined with a custom value.

  • A custom value. You must ensure that the custom value meets the following requirements:

    • The path must be 1 to 128 characters in length. You can use asterisks (*) and question marks (?) as wildcard characters.
    • The custom value can contain letters, digits, and the following special characters: $ - _ . + / & ~ @ : ' * ?. The custom value must start with a forward slash (/) and cannot contain the following characters: " % # ; ! ( ) [ ] ^ , ".
/tsdf
QuerystringNo

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

The query string must be 1 to 128 characters in length, and can contain printable characters, excluding uppercase letters and the following special characters: # [ ] { } \ | < > &.

quedsa
TypestringYes

The type of action. You can specify at most 11 types of action. Valid values:

  • ForwardGroup: forwards a request to multiple vServer groups.
  • Redirect: redirects requests.
  • FixedResponse: returns a fixed response.
  • Rewrite: rewrites requests.
  • InsertHeader: inserts a header.
  • RemoveHeaderConfig: deletes a header.
  • TrafficLimit: throttles traffic.
  • TrafficMirror: mirrors network traffic.
  • Cors: enables cross-origin resource sharing (CORS).

The preceding actions can be classified into two types:

  • FinalType: Each forwarding rule can contain only one FinalType action, which is performed at the end. You can specify only one of ForwardGroup, Redirect, and FixedResponse.
  • ExtType: Each forwarding rule can contain one or more ExtType actions, which are performed before the FinalType action. If you want to specify an ExtType action, you must also specify a FinalType action. You can specify multiple InsertHeader actions or one Rewrite action.
Host
TrafficLimitConfigobjectNo

The configuration of traffic throttling. You can specify at most 20 throttling actions.

QPSintegerNo

The number of queries per second (QPS). Valid values: 1 to 1000000.

2
PerIpQpsintegerNo

The number of requests per IP address. Valid values: 1 to 1000000.

Note If both the QPS and PerIpQps properties are specified, make sure that the value of the QPS property is smaller than the value of the PerIpQps property.
80
TrafficMirrorConfigobjectNo

The configuration of traffic mirroring. You can specify at most 20 traffic mirroring configurations.

TargetTypestringNo

The type of target to which network traffic is mirrored. Valid values:

  • ForwardGroupMirror: a server group
ForwardGroupMirror
MirrorGroupConfigobjectNo

The configuration of the server group to which traffic is mirrored.

ServerGroupTuplesarray<object>No

The server group to which traffic is mirrored.

objectNo

The server group to which traffic is mirrored.

ServerGroupIdstringNo

The server group ID.

srg-00mkgijak0w4qgz9****
RemoveHeaderConfigobjectNo

The configuration of the HTTP header to be removed. You can remove at most 20 HTTP headers.

KeystringNo

The key of the response header.

  • The header key must be 1 to 40 characters in length.
  • The header key can contain lowercase letters, digits, hyphens (-), and underscores (_).
  • Cookie and Host are not supported.
Port
CorsConfigobjectNo

The CORS configuration.

AllowOriginarrayNo

The trusted origins. You can specify one or more values, or only an asterisk (*).

  • The value must start with http:// or https://, and be followed by a valid domain name, including top-level wildcard domain names. Example: http://*.test.abc.example.com.
  • You can specify ports for a single value. Valid values: 1 to 65535.
stringNo

The trusted origin of CORS requests.

http://example.com
AllowMethodsarrayNo

The trusted HTTP methods of CORS requests.

stringNo

The trusted HTTP method of CORS requests. Valid values:

  • GET
  • POST
  • PUT
  • DELETE
  • HEAD
  • OPTIONS
  • PATCH
GET
AllowHeadersarrayNo

The trusted headers of CORS requests.

stringNo

The trusted request header for a cross-origin request. One or more values are supported. Asterisks (*) can be used as wildcard characters. Separate multiple values with commas (,). Each value can be up to 32 characters in length, and can contain only letters and digits. It cannot start or end with an underscore (_) or a hyphen (-).

test_123
ExposeHeadersarrayNo

The headers that can be exposed.

stringNo

The header that can be exposed. One or more values are supported. Asterisks (*) can be used as wildcard characters. Separate multiple values with commas (,). Each value can be up to 32 characters in length, and can contain only letters and digits. It cannot start or end with an underscore (_) or a hyphen (-).

test_123
AllowCredentialsstringNo

Specifies whether to allow credentials to be carried in CORS requests. Valid values:

  • on: allows credentials to be carried in CORS requests.
  • off: does not allow credentials to be carried in CORS requests.
on
MaxAgelongNo

The maximum cache time of dry runs in the browser. Unit: seconds.

Valid values: -1 to 172800.

1000
RuleConditionsarray<object>No

The match conditions of the forwarding rule.

objectYes

The match conditions of the forwarding rule.

CookieConfigobjectNo

The configuration of the cookie. You can specify at most 20 conditions.

Valuesarray<object>No

The key-value pairs of cookies.

objectNo

The key-value pairs of cookies.

KeystringNo

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

test
ValuestringNo

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

test
HeaderConfigobjectNo

The configuration of the HTTP header. You can specify at most 20 HTTP headers.

KeystringNo

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

Port
ValuesarrayNo

The HTTP header values.

stringNo

The value of the response header. The header value must be 1 to 128 characters in length. The header value can contain printable characters whose ASCII values are larger than or equal to 32 and smaller than 127, lowercase letters, asterisks (*), and question marks (?). The header value cannot start or end with a space character.

5006
HostConfigobjectNo

The match conditions for hostnames. You can specify at most 20 conditions.

ValuesarrayNo

The hostnames.

stringNo

The hostname.

The hostname must meet the following requirements:

  • The hostname must be 3 to 128 characters in length, and can contain lowercase letters, digits, and the following special characters: - . * = ~ _ + \ ^ ! $ & | ( ) [ ] ?.
  • The hostname must contain at least one period (.) but cannot start or end with a period (.).
  • The rightmost domain label can contain only letters, asterisks (), and question marks (?), and cannot contain digits or hyphens (-). The leftmost domain label can contain asterisks ().
  • The domain labels cannot start or end with hyphens (-). You can specify asterisks (∗) and question marks (?) anywhere in a domain label.
  • If you specify an exact hostname or a wildcard hostname, the hostname cannot start with a tilde (~).
  • If you specify a regular expression, the regular expression cannot start with an asterisk (*). The regular expression is not case-sensitive.
www.example.com
MethodConfigobjectNo

The configuration of the HTTP request method. You can configure at most 20 HTTP request methods.

ValuesarrayNo

The HTTP request methods.

stringNo

The request method.

Valid values: HEAD, GET, POST, OPTIONS, PUT, PATCH, and DELETE.

PUT
PathConfigobjectNo

The match conditions for query strings. You can specify at most 20 conditions.

ValuesarrayNo

The paths to which requests are forwarded.

stringNo

The path to which requests are forwarded.

  • The path must be 1 to 128 characters in length. You can use asterisks (*) and question marks (?) as wildcard characters.
  • If you do not use a regular expression to specify a URL, the URL must start with a forward slash (/) and can contain letters, digits, and the following special characters: $ - _ . + / & ~ @ : ' *. It cannot contain the following special characters: “ % # ; ! ( ) [ ] ^ , ".
  • If you use a regular expression to specify a URL, the URL must start with a title (~), It can contain letters, digits, and the following special characters: . - _ / = ? ~ ^ * $ : ( ) [ ] + |.
/test
QueryStringConfigobjectNo

The match conditions for query strings. You can specify at most 20 conditions.

Valuesarray<object>No

The key-value pairs of query strings.

objectNo

The key-value pairs of query strings.

KeystringNo

The key of the query string.

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

test
ValuestringNo

The value of the query string.

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

test
ResponseHeaderConfigobjectNo

The HTTP response headers. You can specify at most 20 HTTP response headers.

KeystringNo

The key of the response header.

  • The header key must be 1 to 40 characters in length.
  • The header key can contain lowercase letters, digits, hyphens (-), and underscores (_).
  • Cookie and Host are not supported.
test
ValuesarrayNo

The value of the response header.

stringNo

The value of the response header.

  • The header value must be 1 to 128 characters in length.
  • The header value can contain printable characters whose ASCII values are larger than or equal to 32 and smaller than 127, lowercase letters, asterisks (*), and question marks (?).
  • The header value cannot start or end with a space character.
5006
ResponseStatusCodeConfigobjectNo

The match conditions for response status codes. This parameter is required and valid when Type is set to ResponseStatusCode. You can specify at most 20 conditions.

ValuesarrayNo

The match conditions.

stringNo

The status code in responses. Valid values: 100 to 599.

301
TypestringNo

The condition type of the forwarding rule is invalid.

You can specify at most seven condition types for inbound forwarding rules. Valid values:

  • Host: Requests are forwarded based on hosts.
  • Path: Requests are forwarded based on paths.
  • Header: Requests are forwarded based on HTTP headers.
  • QueryString: Requests are forwarded based on query strings.
  • Method: Requests are forwarded based on request methods.
  • Cookie: Requests are forwarded based on cookies.
  • SourceIp: Requests are forwarded based on source IP addresses.

You can specify at most two condition types for outbound forwarding rules. Valid values:

  • ResponseHeader: Responses are forwarded based on HTTP response headers.
  • ResponseStatusCode: Response are forwarded based on response status codes.
ForwardGroup
SourceIpConfigobjectNo

Traffic matching based on source IP addresses. You can specify at most 20 match conditions based on IP addresses.

ValuesarrayNo

Traffic matching based on source IP addresses.

stringNo

You can specify one or more IP addresses, including CIDR blocks.

Each forwarding rule supports at most five source IP addresses, including CIDR blocks.

192.168.0.1/32
RuleIdstringYes

The IDs of the forwarding rules. You can specify at most 20 rule IDs.

rule-cxjh7vazn2jpnl****
DryRunbooleanNo

Specifies whether to perform only a dry run, without performing the actual request. Valid values:

  • true: performs only a dry run. The system checks the request for potential issues, including missing parameter values, incorrect request syntax, and service limits. If the request fails the dry run, an error message is returned. If the request passes the dry run, the DryRunOperation error code is returned.
  • false (default): performs a dry run and performs the actual request. If the request passes the dry run, a 2xx HTTP status code is returned and the operation is performed.
false

Response parameters

ParameterTypeDescriptionExample
object

Schema of Response

RequestIdstring

The request ID.

365F4154-92F6-4AE4-92F8-7FF34B540710
JobIdstring

The asynchronous task ID.

72dcd26b-f12d-4c27-b3af-18f6aed5****

Examples

Sample success responses

JSONformat

{
  "RequestId": "365F4154-92F6-4AE4-92F8-7FF34B540710",
  "JobId": "72dcd26b-f12d-4c27-b3af-18f6aed5****"
}

Error codes

HTTP status codeError codeError messageDescription
400OperationDenied.IpGroupCanNotUsedForMirrorActionThe operation is not allowed because of %s.The operation is not allowed because of %s.
400IncorrectStatus.RuleThe status of %s [%s] is incorrect.The status of %s [%s] is incorrect.
400OperationDenied.SameGroupForForwardAndMirrorActionThe operation is not allowed because of %s.The operation is not allowed because of %s.
400OperationDenied.GRPCServerGroupThe operation is not allowed because of %s.The operation is not allowed because of %s.
400Conflict.PriorityThere is already %s having the same configuration with %s.There is already %s having the same configuration with %s.
400ResourceQuotaExceeded.ServerGroupAttachedNumThe quota of %s is exceeded for resource %s, usage %s/%s.The quota of %s is exceeded for resource %s, usage %s/%s.
400ResourceQuotaExceeded.LoadBalancerServersNumThe quota of %s is exceeded for resource %s, usage %s/%s.The quota of %s is exceeded for resource %s. Usage: %s/%s.
400ResourceQuotaExceeded.ServerAddedNumThe quota of %s is exceeded for resource %s, usage %s/%s.The quota of %s is exceeded for resource %s. Usage: %s/%s.
400QuotaExceeded.RuleWildcardsNumThe quota of %s is exceeded, usage %s/%s.The quota of %s is exceeded, usage %s/%s.
400QuotaExceeded.RuleMatchEvaluationsNumThe quota of %s is exceeded, usage %s/%s.The quota of %s is exceeded. Usage: %s/%s.
400QuotaExceeded.RuleActionsNumThe quota of %s is exceeded, usage %s/%s.The quota of %s is exceeded. Usage: %s/%s.
400Mismatch.ProtocolThe %s is mismatched for %s and %s.The %s is mismatched for %s and %s.
400Mismatch.VpcIdThe %s is mismatched for %s and %s.The %s is mismatched for %s and %s.
400OperationDenied.ServiceManagedResourceThe operation is not allowed because the current resource of %s is managed resource.-
400OperationDenied.ListenerIdInconsistentThe operation is not allowed because of ListenerIdInconsistent.-
400IllegalParam.PriorityThe param of Priority is illegal.-
400OperationDenied.MirrorActionSupportHttpGroupOnlyThe operation is not allowed because of MirrorActionSupportHttpGroupOnly.-
400OperationDenied.ProtocolMustSameForForwardGroupActionThe operation is not allowed because of ProtocolMustSameForForwardGroupAction.-
404ResourceNotFound.RuleThe specified resource %s is not found.The specified resource %s is not found.
404ResourceNotFound.ServerGroupThe specified resource %s is not found.The specified resource %s is not found.

For a list of error codes, visit the Service error codes.

Change history

Change timeSummary of changesOperation
2024-01-18The Error code has changedView Change Details