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

ModifyRules

最近更新时间2024.02.29 14:48:19

首次发布时间2022.05.20 22:34:54

API 说明

API 名称:ModifyRules。
API 域名:open.volcengineapi.com 。
API 描述:修改指定监听器转发规则。

使用限制

节流限制:每秒最多提交 5 个 API 请求。

快速调试

URI 参数

在使用该部分 API 提交请求时必须包含以下 URI 参数。

除了 URI 参数,该 API 请求还需要包含签名参数。关于更多签名参数的信息,参见公共请求参数

名称类型是否必选格式说明
Action
string
[a-zA-Z]+
API 名称,如 ModifyRules。
VersionstringYYYY-MM-DDAPI 版本信息。该参数的取值是 2020-04-01 。
X-Expiresint900表示签名的有效时间,单位是秒,默认值是900。

请求正文

在使用该 API 提交请求时,请求正文中可以包含的参数如下。

参数类型是否必选参数说明示例值
ListenerId
String
监听器ID。
lsn-2fea4ayvu2g3k5oxruuz****
RulesArray配置转发规则相关信息。详见 Rules-

Rules

参数类型是否必选参数说明示例值
Rules.N.RuleId
List of Struct

转发规则的ID。

  • - N:表示转发规则的序号,取值1 ~ 20。
  • 多个转发规则间使用“&”分隔。
Rules.1.RuleId=rule-****&Rules.2.RuleId=rule- ****
Rules.N.RuleAction
List of Struct

转发规则动作。

  • 为空:默认转发至服务器组。
  • Redirect:重定向。
  • 每次调用该接口时,无论是否修改Action,该参数必传,否则将赋值为默认值(空),即,默认修改为转发至服务器组。
Rules.1.RuleAction=ForwardGroup&Rules.2.RuleAction=Redirect
Rules.N.ServerGroupId
List of Struct

转发到后端服务器组的ID。

  • - N:表示转发规则的序号,取值1 ~ 20。
  • 多个转发规则间使用“&”分隔。
  • 当转发规则动作为空,即转发至服务器组,该参数为必填项。
Rules.1.ServerGroupId=rsp-bp1o94dp5i6ea ****&Rules.2.ServerGroupId=rsp-2fea4bshkqv405oxruuz4 ****
Rules.N.Description
List of Struct

转发规则的描述。

  • 不能以http://或https://开头。
  • 必须以字母或中文开头,可包含数字、英文逗号(,)、点号(.)、下划线(_)、空格( )、等号(=)、短横线(-)、中文逗号(,)、中文句号(。)。
  • 长度限制为1 ~ 255个字符。
  • - N:表示转发规则的序号,取值1 ~ 20。
  • 多个转发规则间使用“&”分隔。

-

Rules.N.TrafficLimitEnabled

String

转发规则 QPS 限速开关:

  • on:开启。

  • off:关闭。

转发规则更改 QPS 限速的相关配置时,注意事项如下:

  • 不填本字段时,表示不修改限速相关信息。

  • 配置本字段后,ALB 会清空之前配置的限速值 Rules.N.TrafficLimitQPS。

  • 若本次变更是限速开关由开启 on 变为关闭 off 状态,ALB 会清空之前您配置的限速值 Rules.N.TrafficLimitQPS。

  • 若本次变更是限速开关由关闭 off 变为开启 on 状态,那么您需要同时填写Rules.N.TrafficLimitQPS,配置具体限速值。

on

Rules.N.TrafficLimitQPSInteger当 Rules.N.TrafficLimitEnabled 为 on 时,配置本字段时参数才有效。表示每秒请求数。取值范围:100~150000。100

Rules.N.RewriteEnabled

String

  • 转发规则重写配置开关,仅当RuleAction 为空(即,转发至服务器组)时,允许配置该参数且生效。支持取值如下:

    • on:开启。

    • off:关闭。

  • 转发规则更改重写的相关配置时,注意事项如下:

    • 转发规则更改重写的功能仅支持白名单用户使用,如需体验请提交申请。

    • 不填本字段时,表示不修改重写相关信息。

    • 配置本字段后,ALB 会清空之前配置的重写路径 Rules.N.RewriteConfig.RewritePath。

    • 若本次变更是重写配置开关由开启 on 变为关闭 off 状态,ALB 会清空之前您配置的重写路径 Rules.N.RewriteConfig.RewritePath。

    • 若本次变更是重写配置开关由关闭 off 变为开启 on 状态,那么您需要至少在重写配置中填写一项才可生效 ,如Rules.N.RewriteConfig.RewritePath。

on

Rules.N.RedirectConfigArray转发规则重定向配置,详见RedirectConfig-
Rules.N.RewriteConfigArray转发规则重写配置,详见 RewriteConfig-

RedirectConfig

参数类型是否必选参数说明示例值
Rules.N.RedirectConfig.RedirectDomain
List of Struct
  • 重定向域名,仅支持精确域名。
    • 参数 N:表示域名的序号,取值范围 1~20。
    • 多个域名间使用“&”分隔。
    • 具体规范如下:
      • 需至少包含一个‘.’,且不允许以‘.’开头或结尾。
      • 仅允许包含字母、数字、‘.’、‘-‘。
      • 长度限制为1 ~ 128个字符。
      • 精确域名:符合域名规范的精确域名,例如:www.test.com。
  • 当转发规则动作为 Redirect,即重定向时,若该参数不指定,会被赋值为默认值(空),最终效果为与请求域名保持一致。
Rules.1.RedirectConfig.RedirectDomain=*.com&Rules.2.RedirectConfig.RedirectDomain=www.test.com
Rules.N.RedirectConfig.RedirectUri
List of Struct

  • 重定向 URI。
    • 参数 N:表示域名的序号,取值范围 1~20。
      • 多个域名间使用“&”分隔。
  • 具体规范如下:
    • 必须以正斜线“/”开头。
    • 仅允许包含字母、数字、‘-’、‘_’、‘/’、‘.’、‘%’、‘?’、‘#’、‘&’、‘=’等字符。
    • 长度限制为1 ~ 128个字符。
  • 当转发规则动作为 Redirect,即重定向时,若该参数不指定,会被赋值为默认值(空),最终效果为与请求URI保持一致。
Rules.1.RedirectConfig.RedirectUri=/&Rules.2.RedirectConfig.RedirectUri=/poo
Rules.N.RedirectConfig.RedirectPort
List of Struct

  • 重定向端口,取值:1 - 65535。
    • 参数 N:表示域名的序号,取值范围 1~20。
    • 多个域名间使用“&”分隔。
  • 当转发规则动作为Redirect,即重定向时,若该参数不指定,否则将赋值为默认值(空),最终效果为与请求端口保持一致。
Rules.1.RedirectConfig.RedirectPort=80&Rules.2.RedirectConfig.RedirectPort=443
Rules.N.RedirectConfig.RedirectHttpCode
List of Struct

  • 重定向状态码,支持301(默认),302,307,308。
    • 参数 N:表示域名的序号,取值范围 1~20。
    • 多个域名间使用“&”分隔。
  • 每次调用该接口时,若RuleAction指定为Redirect,无论是否修改重定向状态码,该参数必传,否则将赋值为默认值(301),最终效果为接口返回错误。
Rules.1.RedirectConfig.RedirectHttpCode=301&Rules.2.RedirectConfig.RedirectHttpCode=302
Rules.N.RedirectConfig.RedirectProtocol
List of Struct

  • 重定向使用的协议,支持HTTP,HTTPS(默认)。
    • 参数 N:表示域名的序号,取值范围 1~20。
    • 多个域名间使用“&”分隔。
  • 每次调用该接口时,若RuleAction指定为Redirect,无论是否修改重定向协议,该参数必传,否则将赋值为默认值(HTTPS),最终效果为与接口返回错误。
Rules.1.RedirectConfig.RedirectProtocol=HTTP&Rules.2.RedirectConfig.RedirectProtocol=HTTPS

RewriteConfig

参数类型是否必选参数说明示例值

Rules.N.RewriteConfig.RewritePath

String

  • 重写路径。

    • 参数 N:表示域名的序号,取值范围 1~20。
      • 多个域名间使用“&”分隔。
  • 具体规范如下:

    • 必须以正斜线“/”开头。

    • 仅允许包含字母、数字、‘-’、‘_’、‘/’、‘.’、‘%’、‘?’、‘#’、‘&’等字符。

    • 长度限制为1 ~ 128个字符。

    • 支持正则表达式替换,重写路径中需要包含${1}${2}${3}中的一个或多个,且这三个变量不支持使用其余字符代替

Rules.1.RewriteConfig.RewritePath=/{1}/${2}&Rules.2.RewriteConfig.RewritePath=/poo

响应正文

参数类型参数说明示例值
RequestId
String
请求ID。
20210811152539010225146063030****

示例

请求示例

GET /?Action=ModifyRules&ListenerId=lsn-1g0puwcx****g8ibuxxw2pmf7&Rules.1.RuleId=rule-3ciy****tdjb46c6rrt4jszkd&Rules.1.ServerGroupId=rsp-3ciyn****piww6c6rrsz73tzn&Rules.N.Description=test&Version=2020-04-01 HTTP/1.1
Host: open.volcengineapi.com
Region: cn-beijing
ServiceName: alb

响应示例

{
    "ResponseMetadata": {
        "RequestId": "2021081318382****22524314705F6BEBE",
        "Action": "ModifyRules",
        "Version": "2020-04-01",
        "Service": "alb",
        "Region": "cn-beijing"
    },
    "Result": {
        "RequestId": "20210813183821****2524314705F6BEBE"
    }
}

错误码

如果响应正文包含 Error 字段,则表示 API 请求失败。此处仅展示当前 API 的错误码,更多错误码请参见公共错误码

HTTP Code错误码错误信息错误描述
400InvalidIndexOrder.MalformedThe specified index order is malformed.指定的索引顺序参数格式不合法。

400

OperationDenied.AccountArrears

The request on the specified resource is denied due to the account being in arrears status.

因账号处于欠费状态,对于该资源的操作请求被拒绝。

400

MissingParameter

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

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

400LimitExceed.RuleYou've reached the limit on the number of rules that you can operate at a time.已达到单次可操作的转发规则的数量上限。
400InvalidRules.TrafficLimitEnabled.MalformedThe specified Rules.TrafficLimitEnabled is malformed.指定的 Rules.TrafficLimitEnabled 参数格式不合法。
400InvalidRules.TrafficLimitQPS.MalformedThe specified Rules.TrafficLimitQPS is malformed.指定的 Rules.TrafficLimitQPS 参数格式不合法。
400InvalidRules.RuleId.DuplicatedThe specified Rules.RuleId is duplicated.指定的 Rules.RuleId 重复。
400InvalidRules.Description.MalformedThe specified Rules.Description is malformed.指定的 Rules.Description 参数格式不合法。

400

MissingParameter

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

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

400

InvalidVpcForServerGroup.LoadBalancerMismatch

The specified VPC of ServerGroup and LoadBalancer do not match.

指定的服务器组和 ALB 实例的 VPC 不匹配。

400InvalidServerGroup.InvalidStatusThe specified ServerGroup is not in the correct status for the request.指定的服务器组所处状态无法响应该请求。
400InvalidRules.RedirectConfig.MalformedThe specified Rules.RedirectConfig is malformed.指定的 Rules.RedirectConfig 参数格式不合法。重定向协议与监听器协议一致,域名、端口、URI 至少填写一项。
400InvalidRules.RedirectConfig.RedirectHttpCode.MalformedThe specified Rules.RedirectConfig.RedirectHttpCode is malformed.指定的 Rules.RedirectConfig.RedirectHttpCode 参数格式不合法。
400InvalidRules.RedirectConfig.RedirectProtocol.MalformedThe specified Rules.RedirectConfig.RedirectProtocol is malformed.指定的 Rules.RedirectConfig.RedirectProtocol 参数格式不合法。
400InvalidRules.RedirectConfig.RedirectDomain.MalformedThe specified Rules.RedirectConfig.RedirectDomain is malformed.指定的 Rules.RedirectConfig.RedirectDomain 参数格式不合法。
400InvalidRules.RedirectConfig.RedirectUri.MalformedThe specified Rules.RedirectConfig.RedirectUri is malformed.指定的 Rules.RedirectConfig.RedirectUri 参数格式不合法。
400InvalidRules.RedirectConfig.RedirectPort.MalformedThe specified Rules.RedirectConfig.RedirectPort is malformed.指定的 Rules.RedirectConfig.RedirectPort 参数格式不合法。
400InvalidRules.RuleAction.MalformedThe specified Rules.RuleAction is malformed.指定的 Rules.RuleAction 参数格式不合法。
400InvalidRules.RewriteEnabled.MalformedThe specified Rules.RewriteEnabled is malformed.指定的 Rules.RewriteEnabled 参数格式不合法。
400InvalidRules.RewriteConfig.RewritePath.MalformedThe specified Rules.RewriteConfig.RewritePath is malformed.指定的 Rules.RewriteConfig.RewritePath 参数格式不合法。

400

QuotaExceed.ServerPerInstance

You've reached the limit on the number of backend servers per ALB you can associate with, resource xxx, usage xx/xx.

已达到每个实例可关联的后端服务器的数量上限。资源是xxx,目前已使用xxx,配额为xxx。

400

QuotaExceed.RulePerGroup

You've reached the limit on the number of rules per server group you can associate with, resource xxx, usage xx/xx.

已达到每个服务器组可关联转发规则的数量上限。资源是xxx,目前已使用xxx,配额为xxx。

400

InvalidLoadBalancer.InvalidStatus

The related LoadBalancer is not in the correct status for the request.

关联的 ALB 实例所处状态无法响应该请求。

400

InvalidServerGroup.InvalidStatus

The specified ServerGroup is not in the correct status for the request.

指定的服务器组所处状态无法响应该请求。

400OperationDenied.RewriteEnabledInRedirectActionThe request on the specified Rule is denied due to the rewrite config is not allowed to be configured in redirect action.因重定向转发动作不支持重写功能,对于该转发规则的操作请求被拒绝。
403ForbiddenYou are not authorized to configure traffic limit for rule.您无权限对指定转发规则配置限速值。
403ForbiddenYou are not authorized to perform operations on the default rule.您无权限对默认转发规则进行操作。
403ForbiddenYou are not authorized to configure rewrite for rule.您无权限对指定转发规则配置重写。
404InvalidListener.NotFoundThe specified Listener does not exist.指定的监听器不存在。
404InvalidRule.NotFoundThe specified Rule does not exist.指定的转发规则不存在。
404InvalidServerGroup.NotFoundThe specified ServerGroup does not exist.指定的服务器组不存在。
500InternalErrorAn internal error has occurred.发生内部错误。请稍后重试或联系工程师进一步咨询。