Modifies the forwarding rule of a specified vServer group.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter Type Required Example Description
Action String Yes SetRule

The operation that you want to perform.

Set the value to SetRule.

RegionId String Yes cn-hangzhou

The ID of the region where the Classic Load Balancer (CLB) instance is created.

You can call theDescribeRegions operation to query region IDs.

RuleId String Yes rule-3ejhkt******

The ID of the forwarding rule.

VServerGroupId String Yes rsp-cige6******

The ID of the vServer group with which the forwarding rule is associated.

RuleName String No doctest

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

Note Forwarding rule names must be unique within each listener.
ListenerSync String No off

Specifies whether the forwarding rule uses the scheduling algorithm, session persistence, and health check configurations of the listener.

Valid values: on and off.

  • off: does not use the configurations of the listener. You can customize health check and session persistence configurations for the forwarding rule.
  • on: uses the configurations of the listener.
Scheduler String No wrr

This parameter is required and takes effect only when you specify off for ListenerSync.

The scheduling algorithm. Valid values:

  • wrr (default): Backend servers that have higher weights receive more requests than those that have lower weights.
  • rr: Requests are distributed to backend servers in sequence.
StickySession String No off

This parameter is required and takes effect only when you specify off for ListenerSync.

Specifies whether to enable session persistence. Valid values: on and off.

  • on: enables session persistence.
  • off: disables session persistence.
StickySessionType String No insert

Specifies whether to insert or rewrite a cookie. This parameter is required and takes effect when you specify onforStickySession.

Valid values:

  • insert: inserts a cookie.

    CLB inserts a cookie (SERVERID) into the first HTTP or HTTPS response that is sent to a client. The next request from the client will contain this cookie, and the listener will forward this request to the recorded backend server.

  • server: rewrites a cookie.

    When CLB detects a user-defined cookie, it overwrites the original cookie with the user-defined cookie. The next request from the client will contain the user-defined cookie, and the listener will forward the request to the recorded backend server.

CookieTimeout Integer No 123

The timeout period of a cookie.

Valid values: 1 to 86400. Unit: seconds.

Note Only when you set the StickySession parameter to on and the StickySessionType parameter to insert, this parameter is required and takes effect.
Cookie String No 23ffsa

The cookie to be configured on the backend server.

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

Note Only when you set the StickySession parameter to on and the StickySessionType parameter to server, this parameter is required and takes effect.
HealthCheck String No off

Specifies whether to enable health checks.

Valid values: on and off.

Note This parameter is required and takes effect only when you set ListenerSync to off.
HealthCheckDomain String No www.domain.com

The domain name that is used for health checks. Valid values:

  • $_ip: The private IP address of the backend server. If the $_ip parameter is specified or the HealthCheckDomain parameter is not specified, the CLB instance uses the private IP address of the backend server as the domain name for health checks.
  • domain: The domain name must be 1 to 80 characters in length. It can contain only letters, digits, periods (.), and hyphens (-).
Note This parameter is required and takes effect only when you set HealthCheck to on.
HealthCheckURI String No /example

The URL that is used for health checks. This parameter is required and takes effect only when you set HealthCheck to on.

HealthyThreshold Integer No 4

Specifies the number of times that an unhealthy backend server must consecutively pass health checks before it is declared healthy (from fail to success).

Valid values: 2 to 10.

Note This parameter is required and takes effect only when you set HealthCheck to on.
UnhealthyThreshold Integer No 4

Specifies the number of times that a healthy backend server must consecutively fail health checks before it is declared unhealthy (from success to fail).

Valid values: 2 to 10.

Note This parameter is required and takes effect only when you set HealthCheck to on.
HealthCheckTimeout Integer No 20

The timeout period of a health check response. If a backend Elastic Compute Service (ECS) instance does not send an expected response within the specified period of time, the ECS instance is considered unhealthy.

Valid values: 1 to 300. Unit: seconds.

Note This parameter is required and takes effect only when you set HealthCheck to on.
HealthCheckInterval Integer No 20

The interval between two consecutive health checks.

Valid values: 1 to 50. Unit: seconds.

Note This parameter is required and takes effect only when you set HealthCheck to on.
HealthCheckHttpCode String No http_2xx

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

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

Note This parameter is required and takes effect only when you set HealthCheck to on.
HealthCheckConnectPort Integer No 80

The port that is used for health checks.

Valid values: 1 to 65535.

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

Response parameters

Parameter Type Example Description
RequestId String 9DEC9C28-AB05-4DDF-9A78-6B08EC9CE18C

The ID of the request.

Examples

Sample requests

http(s)://[Endpoint]/? Action=SetRule
&RegionId=cn-hangzhou
&RuleId=rule-3ejhkt******
&<Common request parameters>

Sample success responses

XML format

<SetRuleResponse>
      <RequestId>9DEC9C28-AB05-4DDF-9A78-6B08EC9CE18C</RequestId>
</SetRuleResponse>

JSON format

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

Error codes

For a list of error codes, visit the API Error Center.