UpdateRuleAttribute

更新时间:
复制 MD 格式

Updates a forwarding rule's properties, such as its conditions, actions, and name.

Operation description

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

    • If the status is Configuring, the rule is being updated.

    • If the status is Available, the update is complete.

  • The maximum numbers of conditions (RuleConditions) and actions (RuleActions) for 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.

You can generate a token from your client. Make sure that the token is unique across 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 request as the ClientToken. The RequestId of each request is unique.

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 attributes of the forwarding rule. The system checks the required parameters, request format, 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): Sends a standard 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 forwarding conditions.

array<object>

No

The forwarding conditions.

CookieConfig

object

No

The cookie configuration.

Values

array<object>

No

The cookies.

object

No

The cookie.

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 (?). The key cannot contain spaces or 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 (?). The value cannot contain spaces or the following special characters: #[]{}\|<>&.

test

HeaderConfig

object

No

The HTTP header configuration.

Key

string

No

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

Port

Values

array

No

The value of the HTTP header.

string

No

The value of the HTTP header. Within the same forwarding condition, the values for a given header key must be unique. The value must meet the following requirements:

  • 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 or end with a backslash (\).

5006

HostConfig

object

No

The host configuration.

Values

array

No

The list of hostnames.

string

No

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, hyphens (-), periods (.), asterisks (*), and question marks (?).

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

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

  • A hyphen (-) cannot be the first or last character of a domain label. Asterisks (*) and question marks (?) can be used anywhere in 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 paths.

string

No

The path. The path 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 wildcards.

/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 query string.

Key

string

No

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

test

Value

string

No

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

test

Type

string

No

The type of the forwarding condition. You can specify up to nine types of forwarding conditions. Valid values:

  • Host: Matches requests based on the host.

  • Path: Matches requests based on the path.

  • Header: Matches requests based on the HTTP header.

  • QueryString: Matches requests based on the query string.

  • Method: Matches requests based on the request method.

  • Cookie: Matches requests based on the cookie.

  • SourceIp: Matches requests based on the source IP address.

  • ResponseHeader: Matches requests based on the response HTTP header.

  • ResponseStatusCode: Matches requests based on the response status code.

Host

ResponseStatusCodeConfig

object

No

The configuration of the response status code.

Values

array

No

The list of response status codes.

string

No

The response status code.

301

ResponseHeaderConfig

object

No

The configuration of the response 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 (_).

  • The key cannot be Cookie or Host.

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 whose ASCII values are in the range of 32-126, lowercase letters, asterisks (*), and question marks (?). It cannot contain double quotation marks (").

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

50006

SourceIpConfig

object

No

The configuration of the source IP condition. You can specify up to five source IP addresses or CIDR blocks.

Values

array

No

One or more IP addresses or CIDR blocks.

string

No

An IP address or a CIDR block.

192.168.0.0/32

RuleActions

array<object>

No

The forwarding actions.

array<object>

No

The forwarding actions.

FixedResponseConfig

object

No

The configuration of the fixed response.

Content

string

No

The content of the fixed response. The content can be up to 1 KB in size 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 response code. Valid values are 2xx, 4xx, and 5xx. x is a digit from 0 to 9.

200

ForwardGroupConfig

object

No

The server group configuration.

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 of the server group. A larger value indicates a higher weight. This means that the server group receives more requests. Valid values: 0 to 100.

  • If only one destination server group is specified, the weight is 100 by default.

  • If multiple destination server groups are specified, you must specify a weight for each server group.

30

ServerGroupStickySession

object

No

Session persistence among server groups.

Enabled

boolean

No

Specifies whether to enable session persistence. Valid values:

  • true

  • false (default)

false

Timeout

integer

No

The timeout period, in seconds. Valid values: 1 to 86400.

2

InsertHeaderConfig

object

No

The configuration for inserting an HTTP header.

CoverEnabled

boolean

No

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

  • true

  • false (default)

false

Key

string

No

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 in InsertHeaderConfig must be unique.

Note

The following header keys are not supported (case-insensitive): 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.

key

Value

string

No

The value of the header to be inserted.

  • If ValueType is set to SystemDefined, you can use one of the following values:
    • 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 listener 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. The value cannot contain double quotation marks ("), start or end with a space, or 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 execution order of forwarding rule actions. The value can range from 1 to 50000. Actions are executed in ascending order of their values. Each value must be unique and cannot be empty. You can add a maximum of 20 forwarding rule actions.

1

RedirectConfig

object

No

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

Host

string

No

The destination host. Valid values:

  • ${host} (default): This value can be used only on its own and cannot be combined 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 (.). The period cannot be the first or last character.

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

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

    • You can use asterisks (*) and question marks (?) 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 use variables such as ${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 requirements below.

  • 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 wildcards.

/test

Port

string

No

The destination port. Valid values:

  • ${port} (default): This value can be used only on its own and cannot be combined with other characters.

  • Other values: 1 to 63335.

10

Protocol

string

No

The destination protocol. Valid values:

  • ${protocol} (default): This value can be used only on its own and cannot be combined with other characters.

  • HTTP or HTTPS.

Note

HTTPS listeners support redirection only to HTTPS.

HTTP

Query

string

No

The destination query string. Valid values:

  • ${query} (default): You can use variables such as ${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 requirements below.

  • 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, they must be lowercase.

quert

RewriteConfig

object

No

The rewrite configuration.

Host

string

No

The destination host to which requests are rewritten. Valid values:

  • ${host} (default): This value can be used only on its own and cannot be combined 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 wildcards. It cannot contain digits or hyphens (-).

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

www.example.com

Path

string

No

The destination path. Valid values:

  • ${path} (default): You can use variables such as ${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 requirements below.

  • 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 wildcards.

/tsdf

Query

string

No

The destination query string for the rewrite. Valid values:

  • ${query} (default): You can use variables such as ${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 requirements below.

  • 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, they must be lowercase.

quedsa

Type

string

No

The action type. You can specify up to nine action types. Valid values:

  • ForwardGroup: Forwards a request to multiple server groups.

  • Redirect: Redirects a request.

  • FixedResponse: Returns a fixed response.

  • Rewrite: Rewrites a request.

  • InsertHeader: Inserts an HTTP header.

  • RemoveHeader: Removes an HTTP header.

  • TrafficLimit: Enables traffic throttling.

  • TrafficMirror: Enables traffic mirroring.

  • Cors: Enables Cross-Origin Resource Sharing (CORS).

Note

A forwarding rule must contain a ForwardGroup, Redirect, or FixedResponse action. When used with other action types, one of these actions must be performed last.

ForwardGroup

TrafficLimitConfig

object

No

The traffic throttling configuration.

QPS

integer

No

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

100

PerIpQps

integer

No

The number of queries per second (QPS) allowed per IP address. Valid values: 1 to 1,000,000.

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 an HTTP header.

Key

string

No

The key of the header to be removed. The key must be 1 to 40 characters in length, and can contain letters, digits, underscores (_), and hyphens (-). The key must be unique within a RemoveHeader action.

  • If Direction is set to Request, the following header keys are not supported (case-insensitive): 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.

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

test

CorsConfig

object

No

The Cross-Origin Resource Sharing (CORS) configuration.

AllowOrigin

array

No

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

  • A value must

  • A single value can be specified with or without a port. The port range is 1-65535.

string

No

Allowed access sources.

http://test.com

AllowMethods

array

No

Select the HTTP methods to allow for cross-origin access.

string

No

Select the HTTP methods allowed for cross-origin resource sharing (CORS). The valid values are:

  • GET.

  • POST.

  • PUT.

  • DELETE.

  • HEAD.

  • OPTIONS.

  • PATCH.

GET

AllowHeaders

array

No

The list of headers allowed for cross-origin resource sharing (CORS).

string

No

The list of headers that are allowed for cross-origin requests. You can set this parameter to the wildcard character (*) or one or more values. If you specify multiple values, separate them with commas (,). A single value can contain only uppercase and lowercase letters, digits, underscores (_), and hyphens (-). Underscores and hyphens cannot be the first or last character. The maximum length of a value is 32 characters.

test_123

ExposeHeaders

array

No

The list of headers that can be exposed.

string

No

The list of headers that are allowed to be exposed. You can set this to * or one or more values. Separate multiple values with a comma (,). A single value can contain only uppercase and lowercase letters, numbers, underscores (_), and hyphens (-). Underscores and hyphens cannot be the first or last character. The maximum length is 32 characters.

test_123

AllowCredentials

string

No

Specifies whether to include credentials. Valid values:

  • on: Yes.

  • off: No.

on

MaxAge

integer

No

The maximum cache duration for a preflight request in the browser, in seconds.

Valid values: -1 to 172800.

1000

RuleName

string

No

The name of the forwarding rule. The name must be 2 to 128 characters long and start with a letter, a Chinese character, or a number. It can contain numbers, periods (.), underscores (_), hyphens (-), and spaces.

rule-instance-test

Priority

integer

No

The priority of the rule ranges from 1 to 10000. A smaller value indicates a higher priority.

Note

Rule priorities must be unique within the same listener.

10

Response elements

Element

Type

Description

Example

object

Updates the attributes of a specified forwarding rule for an Application Load Balancer (ALB).

JobId

string

The asynchronous task ID.

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.