All Products
Search
Document Center

Server Load Balancer:CreateRules

Last Updated:Oct 10, 2024

Creates forwarding rules for an HTTP or HTTPS listener.

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

Request parameters

ParameterTypeRequiredDescriptionExample
RegionIdstringYes

The ID of the region where the Server Load Balancer (SLB) instance is deployed.

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

cn-hangzhou
LoadBalancerIdstringYes

The ID of the SLB instance.

lb-bp1ca0zt07t934w******
ListenerPortintegerYes

The frontend listener port that is used by the SLB instance.

Valid values: 1 to 65535.

443
ListenerProtocolstringNo

The frontend protocol that is used by the SLB instance.

Note This parameter is required if the same port is used by listeners that use different protocols.
https
RuleListstringYes

The forwarding rules that you want to create. You can create at most 10 forwarding rules in each call. Each forwarding rule contains the following parameters:

  • RuleName: Required. The value must be of the STRING type. 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 (_). Forwarding rule names must be unique within the same listener.
  • Domain: Optional. The value must be a string. The domain name that is associated with the forwarding rule. You must specify this parameter or the URL parameter.
  • Url: Optional. The value must be 1 to 80 characters in length, and can contain letters, digits, hyphens (-), forward slashes (/), periods (.), percent signs (%), question marks (?), number signs (#), and ampersands (&). The value must be a string. The URL cannot be only a forward slash (/). However, it must start with a forward slash (/). You must specify this parameter or the Domain parameter.
  • VServerGroupId: Required. The value must be a string. The ID of the vServer group to be specified in the forwarding rule.
Note You must specify at least one between the Domain and URL parameters. You can also specify both. The combination of Domain and Url must be unique within the same listener.
[{"RuleName":"Rule2","Domain":"test.com","VServerGroupId":"rsp-bp114ni******"}]

Response parameters

ParameterTypeDescriptionExample
object
RequestIdstring

The request ID.

9DEC9C28-AB05-4DDF-9A78-6B08EC9CE18C
Rulesarray<object>

The forwarding rules.

Ruleobject
RuleNamestring

The name of the forwarding rule.

Rule2
RuleIdstring

The forwarding rule ID.

rule-bp12jzy0*****

Examples

Sample success responses

JSONformat

{
  "RequestId": "9DEC9C28-AB05-4DDF-9A78-6B08EC9CE18C",
  "Rules": {
    "Rule": [
      {
        "RuleName": "Rule2",
        "RuleId": "rule-bp12jzy0*****"
      }
    ]
  }
}

Error codes

HTTP status codeError codeError messageDescription
400InvalidParameterThe specified VServerGroupId does not belong to the LoadBalancerId of the rule.-
400InvalidParameterValue.RegionNotSupportThe region does not support the parameter value, %s.-
400TooManyListenersMore than 1 listener is found, please be more specified.-
400DomainExistrule with same domain and url already exists in specified vipThe specified domain name and URL already exists in another listener rule.
400OperationFailed.ListenerStatusNotSupportThe status of the listener does not support this operation. Please try again later.-
400OperationFailed.ActionNotSupportThe loadbalancer does not support such action.-
400MissingParameter.RuleNameThe parameter RuleName is required.-

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