All Products
Search
Document Center

Server Load Balancer:CreateRules

Last Updated:Mar 14, 2024

Creates forwarding rules for an HTTP or HTTPS listener.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer.

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:CreateRulesWRITE
  • 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 up to 10 forwarding rules in each request. 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 of the STRING type. The domain name that is associated with the forwarding rule. You must specify at least one of this parameter and Url.
  • Url: Optional. The value must be of the STRING type. The URL must be 1 to 80 characters in length and can contain only letters, digits, hyphens (-), forward slashes (/), periods (.), percent signs (%), question marks (?), number signs (#), and ampersands (&). The URL cannot be a forward slash (/). However, the URL must start with a forward slash (/). You must specify at least one of this parameter and Domain.
  • VServerGroupId: Required. The value must be of the STRING type. The ID of the vServer group that is associated with the forwarding rule.
Note You must specify at least one of Domain and Url. 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
Rulesobject []

The forwarding rules.

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.