tencent cloud

CreateForwardingRule

下载
聚焦模式
字号
最后更新时间: 2026-09-14 20:56:31

1. API Description

Domain name for API request: ga2.intl.tencentcloudapi.com.

Create a Layer 7 forwarding rule

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: CreateForwardingRule.
Version Yes String Common Params. The value used for this API: 2025-01-15.
Region No String Common Params. This parameter is not required.
GlobalAcceleratorId Yes String

Global acceleration instance ID.

ListenerId Yes String

Listener ID.

ForwardingPolicyId Yes String

Policy ID.

RuleConditions.N Yes Array of RuleCondition

Layer 7 forwarding rule conditional information.

Array length cannot exceed 1.

RuleActions.N Yes Array of RuleAction

Layer 7 forwarding rule behavior information.

The length of the array cannot exceed 1.

OriginHeaders.N No Array of OriginHeader

Origin-pull Header information.

The maximum length of the array cannot exceed 5. This field is required when RuleActions.RuleActionType is ForwardGroup.

EnableOriginSni No Boolean

Whether origin-pull sni is enabled.

Default value: False

This field is required when RuleActions.RuleActionType is ForwardGroup.

OriginSni No String

Origin sni.

Input parameter limit: length cannot exceed 80.

This field is required when EnableOriginSni is True. This field is required when RuleActions.RuleActionType is ForwardGroup.

OriginHost No String

Origin-pull host.

Input parameter limit: length not exceeding 80.

This field is required when RuleActions.RuleActionType is ForwardGroup.

ResponseHeaders.N No Array of ResponseHeaders

Origin response headers

Array length not exceeding 5. An empty array can be passed, representing configuration clearing.

HideResponseHeaders.N No Array of HideResponseHeaders

Delete origin server response headers

Array length not exceeding 5. An empty array can be passed, representing configuration clearing.

3. Output Parameters

Parameter Name Type Description
TaskId String

Asynchronous task ID.

ForwardingRuleId String

Layer 7 forwarding rule ID.

RequestId String The unique request ID, generated by the server, will be returned for every request (if the request fails to reach the server for other reasons, the request will not obtain a RequestId). RequestId is required for locating a problem.

4. Example

Example1 Create a Layer 7 Forwarding Rule

Input Example

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

{
    "GlobalAcceleratorId": "ga-80bzejka",
    "ListenerId": "lsr-nd3qmz7h",
    "ForwardingPolicyId": "dm-kzk3neks",
    "RuleConditions": [
        {
            "RuleConditionType": "Path",
            "RuleConditionValue": [
                "/a"
            ]
        }
    ],
    "RuleActions": [
        {
            "RuleActionType": "Drop"
        }
    ],
    "OriginHeaders": [
        {
            "Key": "key-key",
            "Value": "value-value"
        }
    ],
    "EnableOriginSni": true,
    "OriginSni": "testsni",
    "OriginHost": "www.bbb.com"
}

Output Example

{
    "Response": {
        "RequestId": "f7be96f3-c499-4efe-badd-0178c2921d8f",
        "TaskId": "6fa13601-49eb-4982-abee-513fbab41fc1",
        "ForwardingRuleId": "rule-kfn3oc78"
    }
}

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
InvalidParameter.InputRepeat The input parameter %(key)s in the request has duplicate values.
InvalidParameterValue.AsciiCharacters Can only be printable ASCII characters.
InvalidParameterValue.Empty Parameter %(parameter)s cannot be empty.
InvalidParameterValue.ForwardingRulePathConflict The Path of the Layer 7 forwarding rule duplicates an existing one.
InvalidParameterValue.InstanceMismatch The instance object %(value)s has a mismatched relationship.
InvalidParameterValue.InternalReservedFields
InvalidParameterValue.Malformed Parameter value %(value)s of %(parameter)s is invalid. A correct and complete value is in the form of %(template)s.
InvalidParameterValue.SpecialCharacters Parameter value %(value)s cannot contain special characters %(key)s.
InvalidParameterValue.TooLong Parameter value %(value)s length cannot be greater than %(max_size)s.
MissingParameter Parameters are missing.
UnsupportedOperation.ForwardGroupForwardingRuleUnsupportedDefaultEndpointGroup Forwarding rules cannot be configured with a default terminal node group.
UnsupportedOperation.InstanceNotRunning The instance is not in the running state. The current operation is not supported.
UnsupportedOperation.TransportLayerUnsupportedOperateForwardingPolicy Layer-4 listeners do not support creation of forwarding policies.

帮助和支持

本页内容是否解决了您的问题?

填写满意度调查问卷,共创更好文档体验。

文档反馈