You need to enable JavaScript to run this app.
导航

CreateRules

最近更新时间2023.11.16 15:51:42

首次发布时间2021.08.31 10:37:28

调用 CreateRules 接口为指定HTTP/HTTPS监听器添加转发规则,用于将来自不同域名或不同URL的请求转发到不同的后端服务器组。

调用说明

  • 每个HTTP/HTTPS监听器中最多可添加50个转发规则,默认转发规则不计入在内。
  • 调用一次接口最多可以添加50个转发规则。

调试

请求参数

名称类型是否必填示例值
描述
ActionStringCreateRules要执行的操作,取值为CreateRules。
VersionString2020-04-01API版本信息,当前版本为:2020-04-01。
ListenerIdStringlsn-2fea4ayvu2g3k5oxruuz****监听器ID。您可以调用DescribeListeners接口获取监听器ID。

Rules.N.Domain

String

Rules.1.Domain=*.com&Rules.2.Domain=www.test.com

转发规则的域名,支持泛域名和精确域名。

  • 参数 - N:表示转发规则的序号,取值范围为1 ~ 50。
  • 多个转发规则间使用“&”分隔。
规范如下:
  • 需至少包含一个‘.’,且不允许以‘.’开头或结尾。
  • 仅允许包含字母、数字、‘.’、‘-‘、‘*’。
  • 长度限制为1 ~ 128个字符。
  • 泛域名:使用“*”代替1个或多个字符。
    • “*”必须在域名开头或结尾。
    • 同一条域名中“*”不能出现两次。
    • “*”前后不能有除了.以外的字符。
    • 合法示例:*.com、www.test.*。
    • 非法示例:*aaa.com、www.*.com
  • 精确域名:符合域名规范的精确域名,例如:www.test.com。
  • 说明

    Rules.N.DomainRules.N.Url两者至少需指定一个,且Rules.N.DomainRules.N.Url的组合在同一个监听器内必须唯一。

    Rules.N.Url

    String

    Rules.1.Url=/&Rules.2.Url=/poo

    转发规则的URL,仅支持绝对路径。

    • 参数 - N:表示转发规则的序号,取值范围为1 ~ 50。
    • 多个转发规则间使用“&”分隔。
    规范如下:
  • 必须以正斜线“/”开头。
  • 仅允许包含字母、数字、‘-’、‘_’、‘/’、‘.’、‘%’、‘?’、‘#’、‘&’、‘=’等字符。
  • 字符‘/’不能连续出现。
  • 长度限制为1 ~ 128个字符。
  • 若指定Domain,则Url不传入数值时,默认为“/”。
  • 说明

    • Rules.N.DomainRules.N.Url两者至少需指定一个,且Rules.N.DomainRules.N.Url的组合在同一个监听器内必须唯一。
    • Rules.N.Domain设置为空时,Rules.N.Url不允许只为正斜线“/”。

    Rules.N.ServerGroupId

    String

    Rules.1.ServerGroupId=rsp-bp1o94dp5i6ea****&Rules.2.ServerGroupId=rsp-2fea4bshkqv405oxruuz4****

    转发规则关联的后端服务器组的ID。您可以调用DescribeServerGroups接口获取后端服务器组ID。

    • 参数 - N:表示转发规则的序号,取值范围为1 ~ 50。
    • 多个转发规则间使用“&”分隔。

    Rules.N.Description

    String

    This is a rule.

    转发规则的描述,默认值为空字符串。

    • 参数 - N:表示转发规则的序号,取值范围为1 ~ 50。
    • 多个转发规则间使用“&”分隔。
    规范如下:
  • 必须以字母、数字或中文开头,可包含字母、数字、中文及以下特殊字符:英文逗号(,)、点号(.)、下划线(_)、空格( )、等号(=)、中划线(-)、中文逗号(,)、中文句号(。)。
  • 长度限制为0 ~ 255个字符。
  • 返回数据

    字段类型示例值
    描述
    RequestIdString2021081316135705146063000AD724****请求ID。
    RuleIdsArray["rule-2fegss1cplxxc5oxruvvq****","rule-3ciynwkb46c6rrt4jszkd****"]转发规则ID。

    请求示例

    GET /?Action=CreateRules&Version=2020-04-01&ListenerId=lsn-2fea4ayvu2g3k5oxruuz****&Rules.1.Domain=test.com&Rules.1.ServerGroupId=rsp-bp1o94dp5i6ea****&Rules.1.Url=/test HTTP/1.1
    Host: open.volcengineapi.com
    Region: cn-beijing
    Service: clb
    

    返回示例

    {
        "ResponseMetadata": {
            "RequestId": "2021081316135705146063000AD724****",
            "Action": "CreateRules",
            "Version": "2020-04-01",
            "Service": "clb",
            "Region": "cn-beijing"
        },
        "Result": {
            "RequestId": "2021081316135705146063000AD724****",
            "RuleIds": [
                "rule-2fegss1cplxxc5oxruvvq****",
                "rule-3ciynwkb46c6rrt4jszkd****"
            ]
        }
    }
    

    错误码

    此处仅展示当前API的错误码,更多错误码请参见公共错误码

    HttpCode错误码错误信息描述

    400

    MissingParameter

    The request is missing a required parameter. Ensure that you have supplied all the required parameters for the request; for example, the 'XXX'.

    该请求缺少必要参数。请确保发起请求已提供全部必要参数,比如XXX

    说明

    其中,XXX表示缺少的参数名称。

    400InvalidDescription.MalformedThe specified Description is malformed.指定的 Description 参数格式不合法。
    400InvalidRules.Domain.MalformedThe specified Rules.Domain is malformed.指定的 Rules.Domain 参数格式不合法。
    400InvalidRules.URL.MalformedThe specified Rules.URL is malformed.指定的 Rules.URL 参数格式不合法。
    400InvalidProtocol.ListenerMismatchThe specified Protocol and Listener are not matched.指定的协议与监听器不匹配。
    400InvalidListenerServerGroup.UnSupportActionThe specified Listener does not support this action.指定的监听器未绑定默认后端服务器组,不支持当前操作。
    400QuotaExceed.RuleNumberEachListenerYou've reached the limit on the number of Rule that you can associate.已达到监听器可关联的转发规则的数量的配额上限。
    400UnsupportedOperation.AccountArrearsThe request on the specified instance is denied due to the account in arrears status.因账户处于欠费状态,对于该实例的操作请求被拒绝。
    400InvalidDefaultRule.UnSupportActionThe specified Default Rule does not support this action.指定的默认转发规则不支持当前操作。
    400InvalidIncorrectOrder.MalformedThe specified index order is malformed.指定的索引顺序参数格式不合法。
    400InvalidLoadBalancer.InvalidStatusThe specified LoadBalancer is not in the correct status for the request.指定的负载均衡所处状态无法响应该请求。
    403InvalidResourceType.ServcieManagedThe specified ResourceType is managed by a service.指定的资源是服务托管资源。
    404InvalidListener.NotFoundThe specified Listener does not exist.指定的监听器不存在。
    404InvalidServerGroup.NotFoundThe specified ServerGroup does not exist.指定的后端服务器组不存在。
    404InvalidExclusiveCluster.NotFoundThe specified ExclusiveCluster does not exist.指定的独占集群不存在。
    409InvalidRule.ConflictThe specified Rule already exists.指定的转发规则已存在。
    412InvalidLoadBalancer.ExpiredThe specified LoadBalancer has expired.指定的负载均衡已过期。
    412InvalidExclusiveCluster.ExpiredThe specified ExclusiveCluster has expired.指定的独占集群已过期。
    412InvalidExclusiveCluster.UnPurchasedThe specified ExclusiveCluster is not purchased.指定的独占集群未购买。