All Products
Search
Document Center

Server Load Balancer:UpdateRuleAttribute

Last Updated:Dec 18, 2025

Updates the properties of a forwarding rule, such as its conditions, actions, and name.

Operation description

  • UpdateRuleAttribute is an asynchronous operation. After you send a request, the system returns a request ID and runs the task in the background. You can call the ListRules operation to query the status of a forwarding rule.

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

    • If a forwarding rule is in the Available state, its properties have been updated.

  • The maximum number of conditions (RuleConditions) and actions (RuleActions) that you can add to a forwarding rule are as follows:

    • Conditions: 5 for Basic Edition, 10 for Standard Edition, and 10 for WAF-enabled Edition.

    • Actions: 3 for Basic Edition, 5 for Standard Edition, and 5 for WAF-enabled Edition.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

alb:UpdateRuleAttribute

update

*LoadBalancer

acs:alb:{#regionId}:{#accountId}:loadbalancer/{#loadbalancerId}

*ServerGroup

acs:alb:{#regionId}:{#accountId}:servergroup/{#ServerGroupId}

None

None

Request parameters

Parameter

Type

Required

Description

Example

RuleId

string

Yes

The forwarding rule ID.

rule-4dp5i6ea****

ClientToken

string

No

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

Generate a parameter value from your client to make sure that the value 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 RequestId of the API request as the ClientToken. The RequestId may be different for each API request.

5A2CFF0E-5718-45B5-9D4D-70B3FF3898

DryRun

boolean

No

Specifies whether to perform a dry run. Valid values:

  • true: Performs a dry run but does not update the properties of the forwarding rule. The system checks the request for required parameters, request format, and service limits. If the request fails the dry run, an error code is returned. If the request passes the dry run, the DryRunOperation error code is returned.

  • false (default): Sends the request. If the request passes the check, a 2xx HTTP status code is returned and the operation is performed.

false

RuleConditions

array<object>

No

The conditions of the forwarding rule.

array<object>

No

The conditions of the forwarding rule.

CookieConfig

object

No

The cookie configuration.

Values

array<object>

No

The cookies.

object

No

The cookie configuration.

Key

string

No

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

test

Value

string

No

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

test

HeaderConfig

object

No

The request header configuration.

Key

string

No

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

Port

Values

array

No

The request header value.

string

No

The request header value. The values of the same request header key cannot be the same within a forwarding rule condition. Naming conventions:

  • The value must be 1 to 128 characters in length.

  • It can contain printable characters with ASCII values from 32 to 126, asterisks (*), and question marks (?). It cannot contain double quotation marks (").

  • The value cannot start or end with a space. The value cannot end with a backslash (\).

5006

HostConfig

object

No

The host configuration.

Values

array

No

The list of hostnames.

string

No

The hostname. Naming conventions:

  • The hostname must be 3 to 128 characters in length and can contain lowercase letters, digits, hyphens (-), periods (.), asterisks (*), and question marks (?).

  • The hostname must contain at least one period (.). A period cannot be the first or last character.

  • The rightmost domain label can contain only letters, asterisks (*), and question marks (?). It cannot contain digits or hyphens (-).

  • A hyphen (-) cannot be the first or last character of a domain label. Asterisks (*) and question marks (?) can be used at any position of a domain label.

www.example.com

MethodConfig

object

No

The request method configuration.

Values

array

No

The list of request methods.

string

No

The request method.

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

PUT

PathConfig

object

No

The path configuration.

Values

array

No

The list of forwarding paths.

string

No

The forwarding path. Naming conventions:

  • The path must be 1 to 128 characters in length.

  • It must start with a forward slash (/). It can contain letters, digits, and the following special characters: $-_.+/&~@:. It cannot contain the following special characters: “%#;!()[]^,”\". Asterisks (*) and question marks (?) can be used as wildcard characters.

/test

QueryStringConfig

object

No

The query string configuration.

Values

array<object>

No

The list of query strings. You can add up to 20 query strings.

object

No

The structure of the query string.

Key

string

No

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

test

Value

string

No

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

test

Type

string

No

The type of the forwarding rule condition. You can add up to seven types of forwarding rule conditions. Valid values:

  • Host: a host.

  • Path: a path.

  • Header: an HTTP header.

  • QueryString: a query string.

  • Method: a request method.

  • Cookie: a cookie.

  • SourceIp: a source IP address.

  • ResponseHeader: a response HTTP header.

  • ResponseStatusCode: a response status code.

Host

ResponseStatusCodeConfig

object

No

The configuration of the HTTP status code.

Values

array

No

The list of HTTP status codes.

string

No

The HTTP status code.

301

ResponseHeaderConfig

object

No

The configuration of the header condition.

Key

string

No

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

Values

array

No

The value of the header.

string

No

The value of the header.

  • The value must be 1 to 128 characters in length.

  • It can contain printable characters with ASCII values from 32 to 126, lowercase letters, asterisks (*), and question marks (?). It cannot contain double quotation marks (").

  • The value cannot start or end with a space. The value cannot end with a backslash (\).

50006

SourceIpConfig

object

No

Matches service traffic based on the source IP address. You can add up to five source IP addresses.

Values

array

No

One or more IP addresses or CIDR blocks.

string

No

One or more IP addresses or CIDR blocks.

192.168.0.0/32

RuleActions

array<object>

No

The actions of the forwarding rule.

array<object>

No

The actions of the forwarding rule.

FixedResponseConfig

object

No

The configuration of the fixed response.

Content

string

No

The fixed response. The response can be up to 1 KB in length and can contain only ASCII characters.

dssacav

ContentType

string

No

The format of the fixed response.

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

text/plain

HttpCode

string

No

The HTTP status code. The value must be a string that consists of digits. Valid values: 2xx, 4xx, and 5xx. x is a digit.

200

ForwardGroupConfig

object

No

The configuration of the server group.

ServerGroupTuples

array<object>

No

The list of destination server groups.

object

No

The destination server group.

ServerGroupId

string

No

The ID of the destination server group.

sg--atstuj3rtoptyui****

Weight

integer

No

The weight. 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 value is 100 if you do not specify a weight.

  • If the number of destination server groups is greater than 1, you must specify a weight.

30

ServerGroupStickySession

object

No

Session persistence for the server group.

Enabled

boolean

No

Specifies whether to enable session persistence. Valid values:

  • true: enables session persistence.

  • false (default): disables session persistence.

false

Timeout

integer

No

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

2

InsertHeaderConfig

object

No

The configuration for inserting a request header.

CoverEnabled

boolean

No

Specifies whether to overwrite the value of a request header that has the same key. Valid values:

  • true: yes.

  • false (default): no.

false

Key

string

No

The key of the request header to be inserted. The key must be 1 to 40 characters in length, and can contain lowercase letters, digits, underscores (_), and hyphens (-). The key in InsertHeaderConfig cannot be the same as the key in RemoveHeaderConfig.

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, x-forwarded-host, connection, upgrade, content-length, transfer-encoding, keep-alive, te, host, cookie, remoteip, and authority. The keys are not case-sensitive.

key

Value

string

No

The value of the header to be inserted.

  • ValueType is set to SystemDefined, you can set the value to:

    • ClientSrcPort: the client port.

    • ClientSrcIp: the client IP address.

    • Protocol: the protocol of the client request (HTTP or HTTPS).

    • SLBId: the ID of the Application Load Balancer instance.

    • SLBPort: the listening port of the Application Load Balancer instance.

  • If ValueType is set to UserDefined, you can specify a custom header value. The value must be 1 to 128 characters in length, and can contain asterisks (*), question marks (?), and printable characters with ASCII values from 32 to 126. It cannot contain double quotation marks ("). The value cannot start or end with a space. The value cannot end with a backslash (\).

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

UserDefined

ValueType

string

No

The type of the header value. Valid values:

  • UserDefined: a custom header value.

  • ReferenceHeader: a header value that is referenced from a request header.

  • SystemDefined: a system-defined header value.

UserDefined

Order

integer

No

The order of the action. Valid values: 1 to 50000. A smaller value specifies a higher priority. The value must be unique and cannot be empty. You can specify up to 20 orders for the actions.

1

RedirectConfig

object

No

The redirection configuration. You can add up to 20 redirections.

Host

string

No

The destination hostname. Valid values:

  • ${host} (default): You cannot use this value with other characters.

  • Other values must meet the following requirements:

    • The hostname must be 3 to 128 characters in length and can contain lowercase letters, digits, hyphens (-), periods (.), asterisks (*), and question marks (?).

    • The hostname must contain at least one period (.). A period cannot be the first or last character.

    • The rightmost domain label can contain only letters and wildcard characters. It cannot contain digits or hyphens (-).

    • A hyphen (-) cannot be the first or last character of a domain label.

    • Asterisks (*) and question marks (?) can be used at any position of a domain label.

www.example.com

HttpCode

string

No

The redirection method. Valid values: 301, 302, 303, 307, and 308.

301

Path

string

No

The destination path. Valid values:

  • ${path} (default): You can reference ${host}, ${protocol}, and ${port}. Each variable can be referenced only once. You can use these variables together or combine them with a string that meets the following requirements.

  • Other values must meet the following requirements:

    • The path must be 1 to 128 characters in length.

    • It must start with a forward slash (/). It can contain letters, digits, and the following special characters: $-_.+/&~@:. It cannot contain the following special characters: “%#;!()[]^,”\". Asterisks (*) and question marks (?) can be used as wildcard characters.

/test

Port

string

No

The destination port. Valid values:

  • ${port} (default): You can use this value only. You cannot use this value with other characters.

  • Other values: 1 to 63335.

10

Protocol

string

No

The destination protocol. Valid values:

  • ${protocol} (default): You cannot use this value with other characters.

  • HTTP or HTTPS.

Note

HTTPS listeners support only HTTPS.

HTTP

Query

string

No

The destination query string. Valid values:

  • ${query} (default): You can reference ${host}, ${protocol}, and ${port}. Each variable can be referenced only once. You can use these variables together or combine them with a string that meets the following requirements.

  • Other values must meet the following requirements:

    • The value must be 1 to 128 characters in length.

    • It can contain printable characters but cannot contain spaces or the following special characters: #[]{}\|<>". If the value contains letters, the letters must be lowercase.

quert

RewriteConfig

object

No

The rewrite configuration.

Host

string

No

The destination hostname for the internal redirect. Valid values:

  • ${host} (default): You cannot use this value with other characters.

  • Other values must meet the following requirements:

    • The hostname must be 3 to 128 characters in length and can contain lowercase letters, digits, hyphens (-), periods (.), asterisks (*), and question marks (?).

    • The hostname must contain at least one period (.). A period cannot be the first or last character.

    • The rightmost domain label can contain only letters and wildcard characters. It cannot contain digits or hyphens (-).

    • A hyphen (-) cannot be the first or last character of a domain label. Asterisks (*) and question marks (?) can be used at any position of a domain label.

www.example.com

Path

string

No

The destination path. Valid values:

  • ${path} (default): You can reference ${host}, ${protocol}, and ${port}. Each variable can be referenced only once. You can use these variables together or combine them with a string that meets the following requirements.

  • Other values must meet the following requirements:

    • The path must be 1 to 128 characters in length.

    • It must start with a forward slash (/). It can contain letters, digits, and the following special characters: $-_.+/&~@:. It cannot contain the following special characters: “%#;!()[]^,”\". Asterisks (*) and question marks (?) can be used as wildcard characters.

/tsdf

Query

string

No

The destination query string for the internal redirect. Valid values:

  • ${query} (default): You can reference ${host}, ${protocol}, and ${port}. Each variable can be referenced only once. You can use these variables together or combine them with a string that meets the following requirements.

  • Other values must meet the following requirements:

    • The value must be 1 to 128 characters in length.

    • It can contain printable characters but cannot contain spaces or the following special characters: #[]{}\|<>". If the value contains letters, the letters must be lowercase.

quedsa

Type

string

No

The action type. You can add up to 11 action types. Valid values:

  • ForwardGroup: forwards a request to multiple vServer groups.

  • Redirect: redirects a request.

  • FixedResponse: returns a fixed response.

  • Rewrite: rewrites a request.

  • InsertHeader: inserts a header.

  • RemoveHeader: removes a header.

  • TrafficLimit: throttles traffic.

  • TrafficMirror: mirrors traffic.

  • Cors: enables cross-origin resource sharing (CORS).

Note

A forwarding rule must contain a ForwardGroup, Redirect, or FixedResponse action. If you want to use these actions with other types of actions, you must make sure that these actions are executed last.

ForwardGroup

TrafficLimitConfig

object

No

The throttling configuration.

QPS

integer

No

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

100

PerIpQps

integer

No

The QPS of a single IP address. Valid values: 1 to 1000000.

Note

If you specify both QPS and PerIpQps, the value of PerIpQps must be smaller than the value of QPS.

80

TrafficMirrorConfig

object

No

The traffic mirroring configuration.

TargetType

string

No

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

  • ForwardGroupMirror: a server group.

ForwardGroupMirror

MirrorGroupConfig

object

No

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 ID of the server group.

srg-00mkgijak0w4qgz9****

RemoveHeaderConfig

object

No

The configuration for removing a request header.

Key

string

No

The key of the request header to be removed. The key must be 1 to 40 characters in length, and can contain lowercase letters, digits, underscores (_), and hyphens (-). The key cannot be used in RemoveHeaderConfig more than once.

  • If Direction is set to Request, 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, x-forwarded-host, connection, upgrade, content-length, transfer-encoding, keep-alive, te, host, cookie, remoteip, and authority. The keys are not case-sensitive.

  • If Direction is set to Response, the following header keys are not supported: connection, upgrade, content-length, and transfer-encoding. The keys are not case-sensitive.

test

CorsConfig

object

No

The CORS configuration.

AllowOrigin

array

No

The list of allowed origins. You can specify only one * or specify one or more values.

  • A value must start with http:// or https://, followed by a valid domain name or a top-level wildcard domain name. Example: http://*.test.abc.example.com.

  • You can specify a port. The port must be an integer from 1 to 65535.

string

No

The allowed origin.

http://test.com

AllowMethods

array

No

The allowed HTTP methods for cross-origin requests.

string

No

The allowed HTTP methods for cross-origin requests. Valid values:

  • GET

  • POST

  • PUT

  • DELETE

  • HEAD

  • OPTIONS

  • PATCH

GET

AllowHeaders

array

No

The list of allowed headers for cross-origin requests.

string

No

The list of allowed headers for cross-origin requests. You can specify * or specify one or more values. Separate multiple values with commas (,). A value can contain letters, digits, underscores (_), and hyphens (-). An underscore or a hyphen cannot be the first or last character. The value can be up to 32 characters in length.

test_123

ExposeHeaders

array

No

The list of headers that can be exposed to the client.

string

No

The list of headers that can be exposed to the client. You can specify * or specify one or more values. Separate multiple values with commas (,). A value can contain letters, digits, underscores (_), and hyphens (-). An underscore or a hyphen cannot be the first or last character. The value can be up to 32 characters in length.

test_123

AllowCredentials

string

No

Specifies whether to allow credentials. Valid values:

  • on: yes.

  • off: no.

on

MaxAge

integer

No

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

Valid values: -1 to 172800.

1000

RuleName

string

No

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 (-). It must start with a letter or a Chinese character.

rule-instance-test

Priority

integer

No

The priority of the rule. Valid values: 1 to 10000. A smaller value specifies a higher priority.

Note

The priorities of rules that belong to the same listener must be unique.

10

Response elements

Element

Type

Description

Example

object

Updates the attributes of the specified forwarding rule.

JobId

string

The ID of the asynchronous task.

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

RequestId

string

The request ID.

365F5378-41F6-4AE4-92F8-7FF34B540710

Examples

Success response

JSON format

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

Error codes

HTTP status code

Error code

Error message

Description

400

IncorrectStatus.Rule

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.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.Protocol

The %s is mismatched for %s and %s.

The %s is mismatched for %s and %s.

400

Mismatch.VpcId

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

ResourceInConfiguring.Listener

The specified listener is being configured, please try again later.

400

OperationDenied.ProtocolMustSameForForwardGroupAction

The operation is not allowed because of ProtocolMustSameForForwardGroupAction.

403

Forbidden.ServerGroup

Authentication has failed for ServerGroup.

403

Forbidden.LoadBalancer

Authentication is failed for %s.

Authentication is failed for %s.

404

ResourceNotFound.Rule

The specified resource %s is not found.

The specified resource %s is not found.

404

ResourceNotFound.ServerGroup

The specified resource %s is not found.

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.