All Products
Search
Document Center

Server Load Balancer:UpdateRulesAttribute

Last Updated:Mar 01, 2024

Updates 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:UpdateRulesAttributeWrite
  • 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 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
Rulesobject []Yes

The forwarding rules. You can specify up to 10 forwarding rules in each request.

PriorityintegerNo

The priority of the forwarding rule. Valid values: 1 to 10000. A lower value specifies a higher priority. You can specify priorities for up to 20 forwarding rules.

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

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

rule-instance-test
RuleActionsobject []No

The actions of the forwarding rule.

FixedResponseConfigobjectNo

The configuration of the action to return a custom response. You can specify the configurations of up to 20 actions to return a custom response.

ContentstringNo

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

dssacav
ContentTypestringNo

The 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 the response. Valid values: HTTP_2xx, HTTP_4xx, and HTTP_5xx. x must be a digit.

200
ForwardGroupConfigobjectNo

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

ServerGroupTuplesobject []No

The server groups 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 only one destination server group exists and you do not specify a weight, the default value 100 is used.
  • If more than one destination server group exists, you must specify weights.
30
ServerGroupStickySessionobjectNo

The configuration of session persistence for server groups.

EnabledbooleanNo

Specifies whether to enable session persistence. Valid values:

  • true
  • false (default)
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 the configurations of up to 20 actions to insert a header.

CoverEnabledbooleanNo

Specifies whether to overwrite the request header. Valid values:

  • true
  • false (default)
false
KeystringNo

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

Note You cannot use the following header keys (case-insensitive): 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.
test
ValuestringNo

The value of the header to be inserted.

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

    • ClientSrcPort: the client port.
    • ClientSrcIp: the client IP address.
    • Protocol: the request protocol (HTTP or HTTPS).
    • SLBId: the ALB instance ID.
    • SLBPort: the listener port.
  • 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 printable characters whose ASCII values are greater than or equal to 32 and lower than 127. You can use asterisks (*) and question marks (?) as wildcards. The value cannot start or end with a space character.

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

UserDefined
ValueTypestringNo

The type of the 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 specifies 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 priorities for up to 20 actions.

1
RedirectConfigobjectNo

The configuration of the redirect action. You can specify the configurations of up to 20 redirect actions.

HoststringNo

The hostname to which requests are forwarded.

Take note of the following rules when you specify a hostname:

  • 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 a hyphen (-). You can specify asterisks (∗) and question marks (?) anywhere in a domain label.
www.example.com
HttpCodestringNo

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

301
PathstringNo

The path to which requests are redirected.

  • ${path} (default): You can reference **${host}**, ${protocol} and **${port}**. Each variable can be used only once. You can specify one or more of the preceding variables in each request. You can also combine them with a custom value.

  • A custom value that meets the following requirements:

    • The custom value must be 1 to 128 characters in length. You can use asterisks (*) and question marks (?) as wildcards.
    • 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: " % # ; ! ( ) [ ] ^ , ".
/test
PortstringNo

The port to which requests are forwarded.

Valid values: 1 to 63335.

10
ProtocolstringNo

The redirect protocol.

Valid values: HTTP and HTTPS.

Note HTTPS listeners support only HTTP to HTTPS redirection.
HTTP
QuerystringNo

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

quert
RewriteConfigobjectNo

The configuration of the rewrite action. You can specify the configurations of up to 20 rewrite actions.

HoststringNo

The hostname to which requests are forwarded.

Take note of the following rules when you specify a hostname:

  • 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 a hyphen (-). 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. You can specify one or more of the preceding variables in each request. You can also combine them with a custom value.

  • A custom value that meets the following requirements:

    • The custom value must be 1 to 128 characters in length. You can use asterisks (*) and question marks (?) as wildcards.
    • 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 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 the forwarding rule. You can specify up to seven types. 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.
Host
TrafficLimitConfigobjectNo

The configuration of traffic throttling. You can add up to 20 configuration records.

QPSintegerNo

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

2
PerIpQpsintegerNo

The QPS per IP address. Valid values: 1 to 100000.

Note If you specify this parameter and QPS, the value of PerIpQps must be smaller than the value of QPS.
80
TrafficMirrorConfigobjectNo

The configuration of traffic mirroring. You can add up to 20 configuration records.

TargetTypestringNo

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

  • ForwardGroupMirror: a server group
  • SlsMirror: Log Service
ForwardGroupMirror
MirrorGroupConfigobjectNo

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

ServerGroupTuplesobject []No

The server groups to which traffic is mirrored.

ServerGroupIdstringNo

The server group ID.

srg-00mkgijak0w4qgz9****
RemoveHeaderConfigobjectNo

The action to remove an HTTP header. You can specify the configurations of up to 20 actions to remove an HTTP header.

KeystringNo

The key of the header.

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

The CORS configuration.

AllowOriginarrayNo

The allowed origins of CORS requests.

stringNo

The allowed origin of CORS requests. You can set this parameter to an asterisk (*) or one or more values. The values cannot be asterisks (*).

  • A value must start with http:// or https://, followed by a valid domain name or a first-level wildcard domain name, such as *.test.abc.example.com.
  • You can specify a port in a value. Port range: 1 to 65535.
http://example.com
AllowMethodsarrayNo

The allowed HTTP methods for CORS requests.

stringNo

The allowed HTTP method for CORS requests. Valid values:

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

The allowed headers for CORS requests.

stringNo

The allowed header for CORS requests. You can specify an asterisk (*) or one or more values. Separate multiple values with commas (,). A value can contain only letters and digits. It cannot start or end with underscores (_) or hyphens (-). It can be up to 32 characters in length.

test_123
ExposeHeadersarrayNo

The headers that can be exposed.

stringNo

The header that can be exposed. You can specify an asterisk (*) or one or more values. Separate multiple values with commas (,). A value can contain only letters and digits. It cannot start or end with underscores (_) or hyphens (-). It can be up to 32 characters in length.

test_123
AllowCredentialsstringNo

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

  • on
  • off
on
MaxAgelongNo

The maximum cache time of preflight requests in the browser. Unit: seconds.

Valid values: -1 to 172800.

1000
RuleConditionsobject []No

The match conditions of the forwarding rule.

CookieConfigobjectNo

The match conditions for cookies. You can add up to 20 match conditions.

Valuesobject []No

The cookies.

KeystringNo

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

test
ValuestringNo

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

test
HeaderConfigobjectNo

The match conditions for HTTP headers. You can specify up to 20 match conditions.

KeystringNo

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

Port
ValuesarrayNo

The values of the header.

stringNo

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

5006
HostConfigobjectNo

The match conditions for hostnames. You can specify up to 20 match 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 a hyphen (-). 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 enter a regular expression, the regular expression cannot start with an asterisk (*). The regular expression is not case-sensitive.
www.example.com
MethodConfigobjectNo

The match conditions for HTTP request methods. Valid values of N: 1 to 20.

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 up to 20 match conditions.

ValuesarrayNo

The paths.

stringNo

The path.

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

The match conditions for query strings. You can specify up to 20 match conditions.

Valuesobject []No

The key-value pairs of the query strings.

KeystringNo

They key of the query string.

The key must be 1 to 100 characters in length, and can contain printable characters such as lowercase letters, asterisks (*), and question marks (?). The key cannot contain uppercase letters, 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 printable characters such as lowercase letters, asterisks (*), and question marks (?). However, uppercase letters, space characters, and the following special characters are not supported: # [ ] { } \ | < > &.

test
ResponseHeaderConfigobjectNo

The configuration of the HTTP response header. You can specify the configurations of up to 20 HTTP response header.

KeystringNo

The key of the header.

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

The values of the header.

stringNo

The value of the header.

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

The match conditions for response status codes. This parameter is required and takes effect when Type is set to ResponseStatusCode. You can specify up to 20 match conditions.

ValuesarrayNo

The match conditions.

stringNo

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

301
TypestringNo

The type of action specified in the forwarding rule. You can specify up to 11 types of actions. 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 traffic.
  • CorsConfig: forwards requests based on CORS.

The following action types are supported:

  • FinalType: the last action to be performed in a forwarding rule. Each forwarding rule can contain only one FinalType action. You can specify a ForwardGroup, Redirect, or FixedResponse action as the FinalType action.
  • ExtType: the action or the actions to be performed before the FinalType action. A forwarding rule can contain one or more ExtType actions. To specify an ExtType action, you must specify a FinalType action. You can specify multiple InsertHeader actions or one Rewrite action.
ForwardGroup
SourceIpConfigobjectNo

The configuration of the source IP addresses based on which user traffic is matched. You can specify up to 20 configuration records.

ValuesarrayNo

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

stringNo

The IP address or CIDR block based on which user traffic is matched.

You can specify up to five source IP addresses in a forwarding rule.

192.168.0.1/32
RuleIdstringYes

The forwarding rule ID. You can specify up to 20 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.-
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 changedsee changesets
Change itemChange content
Error CodesThe Error code has changed.
    Error Codes 400 change
    delete Error Codes: 404