Creates forwarding rules for HTTP or HTTPS listeners.

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 CreateRules

The operation that you want to perform.

Set the value to CreateRules.

ListenerPort Integer Yes 443

The frontend port that is used by the Server Load Balancer (SLB) instance.

Valid values: 1 to 65535.

LoadBalancerId String Yes lb-bp1ca0zt07t934w******

The ID of the SLB instance.

RegionId String Yes cn-hangzhou

The ID of the region where the SLB instance is created.

You can call the DescribeRegions operation to query region IDs.

RuleList String Yes [{"RuleName":"Rule2","Domain":"test.com","VServerGroupId":"rsp-bp114ni******"}]

The forwarding rules to be created. A maximum of 10 forwarding rules can be specified 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 only letters, digits, hyphens (-), forward slashes (/), periods (.),and underscores (_). Forwarding rule names must be unique within each listener.
  • Domain: Optional. The value must be of the STRING type. The domain name to be associated with the forwarding rule. You must specify at least this parameter or Url.
  • Url: Optional. The URL to be specified in the forwarding rule. 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 must not be a single forward slash (/). However, it must start with a forward slash (/). You must specify at least the URL or Domain.
  • VServerGroupId: Required. The value must be of the STRING type. The ID of the vServer group to be specified in the forwarding rule.
Note You must specify at least Domain or Url. You can also specify both. The combination of Domain and Url must be unique within a listener.
ListenerProtocol String No https

The frontend protocol that is used by the SLB instance.

Note This parameter is required when listeners that use different protocols listen on the same port.

Response parameters

Parameter Type Example Description
Rules Array of Rule

The list of forwarding rules.

Rule
RuleId String rule-bp12jzy0*****

The ID of the forwarding rule.

RuleName String Rule2

The name of the forwarding rule.

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

The ID of the request.

Examples

Sample requests

http(s)://[Endpoint]/?Action=CreateRules
&ListenerPort=443
&LoadBalancerId=lb-bp1ca0zt07t934w******
&RegionId=cn-hangzhou
&RuleList=[{"RuleName":"Rule2","Domain":"test.com","VServerGroupId":"rsp-bp114ni******"}]
&<Common request parameters>

Sample success responses

XML format

<CreateRulesResponse>
	  <RequestId>D63E42FB-F963-4EE5-9B32-05602BF351F3</RequestId>
	  <Rules>
		    <Rule>
			      <RuleId>rule-bp12jzy******</RuleId>
			      <RuleName>Rule3</RuleName>
		    </Rule>
	  </Rules>
</CreateRulesResponse>

JSON format

{
    "RequestId": "D63E42FB-F963-4EE5-9B32-05602BF351F3", 
    "Rules": {
        "Rule": [
            {
                "RuleId": "rule-bp12jzy******", 
                "RuleName": "Rule3"
            }
        ]
    }
}

Error codes

HttpCode Error code Error message Description
400 DomainExist rule with same domain and url already exists in specified vip The error message returned because a forwarding rule with the same domain name and URL is already created for the listener.
400 OperationFailed.ListenerStatusNotSupport The status of the listener does not support this operation. Please try again later. The error message returned because the listener is in a state that does not support the operation. Try again later.

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