SetRule

Updated at:

Modifies the forwarding rule of a target vServer group.

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

slb:SetRule

update

*loadbalancer

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

  • slb:tag
  • slb:tag
  • slb:tag
None

Request parameters

Parameter

Type

Required

Description

Example

RegionId

string

Yes

The region ID of the SLB instance.

You can call the DescribeRegions operation to query the region ID.

cn-hangzhou

RuleId

string

Yes

The ID of the forwarding rule.

rule-3ejhkt****

VServerGroupId

string

No

The ID of the target vServer group for the forwarding rule.

rsp-cige6****

RuleName

string

No

The name of the forwarding rule. The name must be 1 to 40 characters in length and can contain Chinese characters, letters, digits, hyphens (-), forward slashes (/), periods (.), and underscores (_).

Note

The names of different rules within the same listener must be unique.

doctest

ListenerSync

string

No

Specifies whether to inherit the health check, session persistence, and scheduling algorithm configurations from the listener. Valid values:

  • on: Inherits the configurations of the listener.

  • off: Does not inherit the configurations of the listener. The forwarding rule uses custom health check and session persistence configurations.

off

Scheduler

string

No

The scheduling algorithm. Valid values:

  • wrr: Backend servers with higher weights receive more requests.

  • rr: Requests are distributed to backend servers in sequence.

Note

This parameter is required and takes effect only when ListenerSync is set to off.

wrr

StickySession

string

No

Specifies whether to enable session persistence. Valid values:

  • on: Enables session persistence.

  • off: Disables session persistence.

This parameter is required and takes effect only when ListenerSync is set to off.

off

StickySessionType

string

No

The method used to handle cookies. Valid values:

  • insert: Insert cookie. When a client accesses the Server Load Balancer for the first time, the Server Load Balancer inserts a cookie into the response by adding the backend server ID to the HTTP or HTTPS response message. When the client sends a subsequent request with this cookie, the Server Load Balancer forwards the request to the backend server that was recorded during the first access.

  • server: Rewrite cookie. When the Server Load Balancer detects a custom cookie, it rewrites the original cookie. When the client sends a subsequent request with the new cookie, the Server Load Balancer forwards the request to the previously recorded backend server.

Note

This parameter is required and takes effect only when StickySession is set to on.

insert

CookieTimeout

integer

No

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

Note

This parameter is required and takes effect only when StickySession is set to on and StickySessionType is set to insert.

123

Cookie

string

No

The cookie configured on the server.

The cookie must be 1 to 200 characters in length and can contain only ASCII letters and digits. It cannot contain commas (,), semicolons (;), or spaces, and cannot start with a dollar sign ($).

Note

This parameter is required and takes effect only when StickySession is set to on and StickySessionType is set to server.

23ffsa

HealthCheck

string

No

Specifies whether to enable the health check. Valid values:

  • on: Enables the health check.

  • off: Disables the health check.

Note

This parameter is required and takes effect only when ListenerSync is set to off. Otherwise, this parameter is ignored.

off

HealthCheckDomain

string

No

The domain name used for health checks. Valid values:

  • $_ip: The private IP of the backend server. If $_ip is specified or HealthCheckDomain is not specified, the Server Load Balancer uses the private IP of each backend server as the domain name for health checks.

  • domain: A custom domain name. The domain name must be 1 to 80 characters in length and can contain only letters, digits, periods (.), and hyphens (-).

Note

This parameter takes effect only when HealthCheck is set to on.

$_ip

HealthCheckURI

string

No

The URI used for health checks.

Note

This parameter is required and takes effect only when HealthCheck is set to on.

/example

HealthyThreshold

integer

No

The number of consecutive successful health checks that must occur before the health check status of a backend server is changed from Failed to Successful.

Valid values: 2 to 10.

Note

This parameter is required and takes effect only when HealthCheck is set to on.

4

UnhealthyThreshold

integer

No

The number of consecutive failed health checks that must occur before the health check status of a backend server is changed from Successful to Failed.

Valid values: 2 to 10.

Note

This parameter is required and takes effect only when HealthCheck is set to on.

4

HealthCheckTimeout

integer

No

The timeout period for receiving a response from a health check. If the backend ECS instance does not respond correctly within the specified time, the health check is considered failed. Unit: seconds. Valid values: 1 to 300.

Note

This parameter is required and takes effect only when HealthCheck is set to on.

20

HealthCheckInterval

integer

No

The interval between two consecutive health checks. Unit: seconds. Valid values: 1 to 50.

Note

This parameter is required and takes effect only when HealthCheck is set to on.

20

HealthCheckConnectPort

integer

No

The port used for health checks. Valid values: 1 to 65535.

Note

This parameter takes effect only when HealthCheck is set to on.

80

HealthCheckHttpCode

string

No

The HTTP status codes that indicate a successful health check. Separate multiple HTTP status codes with commas (,).

Valid values: http_2xx, http_3xx, http_4xx, and http_5xx.

Note

This parameter is required and takes effect only when HealthCheck is set to on.

http_2xx

DryRun

boolean

No

Specifies whether to only precheck this request. Valid values:

  • true: Sends a precheck request without performing the operation. If the precheck succeeds, the DryRunOperation error code is returned.

  • false (default): Sends a normal request and performs the operation after the precheck succeeds.

false

Response elements

Element

Type

Description

Example

object

RequestId

string

The ID of the request.

9DEC9C28-AB05-4DDF-9A78-6B08EC9CE18C

Examples

Success response

JSON format

{
  "RequestId": "9DEC9C28-AB05-4DDF-9A78-6B08EC9CE18C"
}

Error codes

HTTP status code

Error code

Error message

Description

400 InvalidParameter The specified VServerGroupId does not belong to the LoadBalancerId of the rule. The Vgw ip is empty. Specify the Vgw ip parameter.
400 InvalidParameter.RegionNotSupport The region does not support the parameter: %s. The specified parameter is not supported in the current region.
400 DryRunOperation Request validation has been passed with DryRun flag set. Request validation has been passed with DryRun flag set.

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.