All Products
Search
Document Center

Server Load Balancer:SetRule

Last Updated:Oct 10, 2024

Modifies a forwarding rule that is associated with a vServer group.

Debugging

You can run this interface directly in OpenAPI Explorer, saving you the trouble of calculating signatures. After running successfully, OpenAPI Explorer can automatically generate SDK code samples.

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
slb:SetRuleupdate
  • loadbalancer
    acs:slb:{#regionId}:{#accountId}:loadbalancer/{#loadbalancerId}
  • slb:tag
none

Request parameters

ParameterTypeRequiredDescriptionExample
RegionIdstringYes

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

You can call the DescribeRegions operation to query the most recent region list.

cn-hangzhou
RuleIdstringYes

The ID of the forwarding rule.

rule-3ejhkt****
VServerGroupIdstringNo

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

rsp-cige6****
RuleNamestringNo

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

Note On the same listener, the forwarding rule names must be unique.
doctest
ListenerSyncstringNo

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

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

The scheduling algorithm. Valid values:

  • wrr: Backend servers with higher weights receive more requests than those with lower weights.
  • rr: Requests are distributed to backend servers in sequence.
Note This parameter is required and takes effect if the ListenerSync parameter is set to off.
wrr
StickySessionstringNo

Specifies whether to enable session persistence. Valid values:

  • on: yes
  • off: no

This parameter is required and takes effect if the ListenerSync parameter is set to off.

off
StickySessionTypestringNo

The method that is used to handle a cookie. Valid values:

  • insert: inserts a cookie.

    CLB inserts the backend server ID as a cookie 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 distribute 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 distribute this request to the recorded backend server.

Note This parameter is required and takes effect if the StickySession parameter is set to on.
insert
CookieTimeoutintegerNo

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

Note This parameter is required and takes effect if StickySession is set to on and StickySessionType is set to insert.
123
CookiestringNo

The cookie that is configured on the server.

The cookie 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 This parameter is required and takes effect if StickySession is set to on and StickySessionType is set to server.
23ffsa
HealthCheckstringNo

Specifies whether to enable the health check feature. Valid values:

  • on: yes
  • off: no
Note This parameter is required and takes effect if the ListenerSync parameter is set to off.
off
HealthCheckDomainstringNo

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

  • $_ip: the private IP address of a backend server. If you do not set this parameter or set the parameter to $_ip, the SLB instance uses the private IP address of each backend server for health checks.
  • domain: The domain name must be 1 to 80 characters in length, and can contain letters, digits, periods (.), and hyphens (-).
Note This parameter takes effect if the HealthCheck parameter is set to on.
$_ip
HealthCheckURIstringNo

The URI that is used for health checks.

Note This parameter is required and takes effect if the HealthCheck parameter is set to on.
/example
HealthyThresholdintegerNo

The number of times that an unhealthy backend server must consecutively pass health checks before it is declared healthy. In this case, the health status is changed from fail to success.

Valid values: 2 to 10.

Note This parameter is required and takes effect if the HealthCheck parameter is set to on.
4
UnhealthyThresholdintegerNo

The number of times that a healthy backend server must consecutively fail health checks before it is declared unhealthy. In this case, the health status is changed from success to fail.

Valid values: 2 to 10.

Note This parameter is required and takes effect if the HealthCheck parameter is set to on.
4
HealthCheckTimeoutintegerNo

The timeout period of a health check response. If a backend server, such as an Elastic Compute Service (ECS) instance, does not return a health check response within the specified timeout period, the server fails the health check. Unit: seconds. Valid values: 1 to 300.

Note This parameter is required and takes effect if the HealthCheck parameter is set to on.
20
HealthCheckIntervalintegerNo

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

Note This parameter is required and takes effect if the HealthCheck parameter is set to on.
20
HealthCheckConnectPortintegerNo

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

Note This parameter takes effect when the HealthCheck parameter is set to on.
80
HealthCheckHttpCodestringNo

The HTTP status code for a successful health check. Multiple HTTP status codes are separated by commas (,).

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

Note This parameter is required and takes effect if the HealthCheck parameter is set to on.
http_2xx

Response parameters

ParameterTypeDescriptionExample
object
RequestIdstring

The ID of the request.

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

Examples

Sample success responses

JSONformat

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

Error codes

HTTP status codeError codeError message
400InvalidParameterThe specified VServerGroupId does not belong to the LoadBalancerId of the rule.
400InvalidParameter.RegionNotSupportThe region does not support the parameter: %s.

For a list of error codes, visit the Service error codes.