tencent cloud

Feedback

CreateRule

Last updated: 2023-07-13 15:25:28

1. API Description

Domain name for API request: gaap.tencentcloudapi.com.

This API (CreateRule) is used to create the forwarding rules of HTTP/HTTPS listeners.

A maximum of 20 requests can be initiated per second for this API.

We recommend you to use API Explorer
Try it
API Explorer provides a range of capabilities, including online call, signature authentication, SDK code generation, and API quick search. It enables you to view the request, response, and auto-generated examples.

2. Input Parameters

The following request parameter list only provides API request parameters and some common parameters. For the complete common parameter list, see Common Request Parameters.

Parameter Name Required Type Description
Action Yes String Common Params. The value used for this API: CreateRule.
Version Yes String Common Params. The value used for this API: 2018-05-29.
Region No String Common Params. This parameter is not required.
ListenerId Yes String Layer-7 listener ID
Domain Yes String Domain name of the forwarding rule
Path Yes String Path of the forwarding rule
RealServerType Yes String The origin server type of the forwarding rule, which supports IP and DOMAIN types.
Scheduler Yes String The strategy used by the listener to access the origin server. Values: rr (round-robin), wrr (weighted round-robin), lc (the least-connections strategy).
HealthCheck Yes Integer Whether the health check is enabled for rules. 1: enabled; 0: disabled.
CheckParams No RuleCheckParams Parameters related to origin server health check
ForwardProtocol No String Protocol types of the forwarding from acceleration connection to origin server, which supports HTTP or HTTPS.
If this field is not passed in, it indicates that the ForwardProtocol of the corresponding listener will be used.
ForwardHost No String The host to which the acceleration connection forwards. If this parameter is not specified, the default host will be used, i.e., the host with which the client initiates HTTP requests.
ServerNameIndicationSwitch No String Whether to enable SNI. Values: on (enable), off (disable). For creation of HTTP listener forwarding rules, SNI is disabled by default.
ServerNameIndication No String Server Name Indication (SNI). This field is required when ServerNameIndicationSwitch is ON.
ForcedRedirect No String Enables HTTP-to-HTTPS force redirect for a forwarding rule. Enter a hostname and path of the current forwarding rule.

3. Output Parameters

Parameter Name Type Description
RuleId String The ID of the successfully created forwarding rule
RequestId String The unique request ID, which is returned for each request. RequestId is required for locating a problem.

4. Example

Example1 Creating a listener forwarding rule

This example shows you how to create an HTTP/HTTPS listener forwarding rule.

Input Example

POST / HTTP/1.1
Host: gaap.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: CreateRule
<Common request parameters>

{
    "Domain": "www.bbb.com",
    "RealServerType": "IP",
    "HealthCheck": "1",
    "ListenerId": "listener-9jt0rtv9",
    "CheckParams": {
        "ConnectTimeout": "4",
        "Path": "%2F",
        "Method": "HEAD",
        "DelayLoop": "39",
        "StatusCode": [
            "300",
            "100",
            "400",
            "200",
            "500"
        ]
    },
    "Scheduler": "rr",
    "Path": "%2Fimage"
}

Output Example

{
    "Response": {
        "RequestId": "f3ab4984-dfe0-4c6f-aca0-32100550f6fd",
        "RuleId": "rule-qws4fmyl"
    }
}

5. Developer Resources

SDK

TencentCloud API 3.0 integrates SDKs that support various programming languages to make it easier for you to call APIs.

Command Line Interface

6. Error Code

The following only lists the error codes related to the API business logic. For other error codes, see Common Error Codes.

Error Code Description
AuthFailure CAM signature/authentication error.
AuthFailure.NotEnterpriseAuthorization Not an organizational customer.
AuthFailure.UnauthorizedOperation The sub-account is not authorized for this operation.
FailedOperation Operation failed.
FailedOperation.ActionOperateTooQuickly Too many attempts. Please try again later.
FailedOperation.GroupStatusNotInRuning Unable to operate: the connection group is not running.
FailedOperation.InstanceStatusNotInRuning Unable to operate: the connection is not running.
FailedOperation.LimitNumofRules Limit on the number of forwarding rules exceeded.
FailedOperation.ListenerHasTask The listener is in operation. Do not repeat the operation.
FailedOperation.NonStandardProxy This connection is non-standard and write operations are not allowed.
FailedOperation.NotSupportOldVersionProxy Only connections of Version 2.0 are supported.
FailedOperation.RuleAlreadyExisted Rule already exists.
FailedOperation.UserNotConfirmProtocol Protocol not activated.
InternalError Internal error.
InvalidParameter Incorrect parameter.
InvalidParameterValue Incorrect parameter value.
MissingParameter Missing parameter.
ResourceNotFound The resource does not exist.
ResourceUnavailable.AccountViolation Restricted resources found in your account. Check your inbox and email for details.
UnauthorizedOperation Unauthorized operation.
Contact Us

Contact our sales team or business advisors to help your business.

Technical Support

Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

7x24 Phone Support