You need to enable JavaScript to run this app.
文档中心
负载均衡

负载均衡

复制全文
下载 pdf
转发规则
CreateRules - 创建转发规则
复制全文
下载 pdf
CreateRules - 创建转发规则
调用 CreateRules 接口,为指定HTTP/HTTPS监听器添加转发规则,用于将访问不同域名或不同URL的请求转发到不同的后端服务器组。​
使用说明​
  • 每个HTTP/HTTPS监听器中最多可添加50个转发规则,默认转发规则不计入在内。​
  • 调用一次接口最多可以添加50个转发规则。​
调试​
API Explorer
您可以通过 API Explorer 在线发起调用,无需关注签名生成过程,快速获取调用结果。
​
请求参数​
下表中,a.N.b类型类型参数中的“N”表示转发规则的序号,取值范围为1 ~ 50。多个转发规则间请使用“&”分隔。​
Action String 必选 示例值:CreateRules​
要执行的操作,取值:CreateRules。​
​
Version String 必选 示例值:2020-04-01​
API的版本信息,当前版本为 2020-04-01。​
​
ListenerId String 必选 示例值:lsn-2fea4ayvu2g3k5oxruuz****​
监听器ID。​
您可以调用DescribeListeners接口,查询监听器ID。​
​
Rules.N.Domain String 可选 示例值:www.test.com​
转发规则的域名,支持泛域名和精确域名。规范如下:​
  • 需至少包含一个‘.’,且不允许以‘.’开头或结尾。​
  • 仅允许包含字母、数字、‘.’、‘-‘、‘*’。​
  • 长度限制为1 ~ 128个字符。​
  • 泛域名:使用“*”代替1个或多个字符。​
  • “*”必须在域名开头或结尾。​
  • 同一条域名中“*”不能出现两次。​
  • “*”前后不能有除了.以外的字符。​
  • 合法示例:.com、www.test.。​
  • 非法示例:aaa.com、www..com​
  • 精确域名:符合域名规范的精确域名,例如:www.test.com。​
说明​
Rules.N.Domain和 Rules.N.Url两者至少需指定一个,且Rules.N.Domain和 Rules.N.Url的组合在同一个监听器内必须唯一。​
​
Rules.N.Url String 可选 示例值:/poo​
转发规则的URL,仅支持绝对路径。规范如下:​
  • 必须以正斜线“/”开头。​
  • 仅允许包含字母、数字、-、_、/、.、%、?、#、&、=等字符。​
  • 支持正则表达式的URL:必须以“”开头,支持大小写字母、数字和特殊字符`.-_/=?~^*$:()[]+|`,只能在开头,且只能出现一次。​
  • 字符/不能连续出现。​
  • 长度限制为1 ~ 128个字符。​
  • 若指定Domain,则Url不传入数值时,默认为/。​
说明​
  • Rules.N.Domain和Rules.N.Url两者至少需指定一个,且Rules.N.Domain和 Rules.N.Url的组合在同一个监听器内必须唯一。​
  • 当Rules.N.Domain设置为空时,Rules.N.Url不允许只为正斜线“/”。​
​
Rules.N.ActionType String 可选 示例值:Forward​
转发规则的转发动作。取值如下:​
  • Forward:转发至。​
  • Redirect:重定向至。​
说明​
该参数取值为Redirect且参数Rules.N.RedirectConfig.Protocol与该转发规则所属监听器协议相同时,参数Rules.N.RedirectConfig.Host、Rules.N.RedirectConfig.Path、Rules.N.RedirectConfig.Port不能均为空。​
​
Rules.N.ServerGroupId String 可选 示例值:rsp-bp1o94dp5i6ea****​
转发规则关联的后端服务器组的ID。您可以调用DescribeServerGroups接口获取后端服务器组ID。​
说明​
参数Rules.N.ActionType取值为Forward时,该参数为必填。​
​
Rules.N.RedirectConfig.Protocol String 可选 示例值:HTTPS​
转发规则重定向的协议。取值如下:​
  • HTTP​
  • HTTPS(默认值)​
说明​
参数Rules.N.ActionType取值为Redirect时,不传入该参数或该参数不传入数值,则默认为HTTPS。​
​
Rules.N.RedirectConfig.Host String 可选 示例值:www.test.com​
转发规则重定向的域名,当前仅支持精确域名。规范如下:​
  • 需至少包含一个‘.’,且不允许以‘.’开头或结尾。​
  • 仅允许包含字母、数字、‘.’、‘-‘。​
  • 长度限制为1 ~ 128个字符。​
  • 符合域名规范的精确域名,例如:www.test.com。​
说明​
参数Rules.N.ActionType取值为Redirect时,不传入该参数或该参数不传入数值,则默认为空字符串,实际转发时与请求域名保持一致。​
​
Rules.N.RedirectConfig.Path String 可选 示例值:/abc​
转发规则重定向的路径。规范如下:​
  • 必须以正斜线“/”开头,字符‘/’不能连续出现。​
  • 仅允许包含字母、数字、‘-’、‘_’、‘/’、‘.’、‘%’、‘?’、‘#’、‘&’、‘=’等字符。​
  • 长度限制为1 ~ 128个字符。​
说明​
参数Rules.N.ActionType取值为Redirect时,不传入该参数或该参数不传入数值,则默认为空字符串,实际转发时与请求路径保持一致。​
​
Rules.N.RedirectConfig.Port String 可选 示例值:443​
转发规则重定向的端口,取值范围为 1~65535。​
说明​
参数Rules.N.ActionType取值为Redirect时,不传入该参数或该参数不传入数值,则默认为空字符串,实际转发时与请求端口保持一致。​
​
Rules.N.RedirectConfig.StatusCode String 可选 示例值:301​
转发规则重定向的状态码。取值如下:​
  • 301(默认):表示请求的资源已被永久移动到新的 URL,客户端应该使用新的 URL 进行后续请求。​
  • 302:表示请求的资源被临时移动到新的 URL,但未来可能会再次更改,客户端应该使用新的 URL 进行后续请求。​
  • 307:与 302 类似,但在重定向时要求客户端保持请求方法不变。例如,原来是 GET 请求,则重定向后仍然是 GET 请求。​
  • 308:与 301 类似,但在重定向时要求客户端保持请求方法不变。​
说明​
参数Rules.N.ActionType取值为Redirect时,不传入该参数或该参数不传入数值,则默认为301。​
​
Rules.N.Description String 可选 示例值:This is a rule.​
转发规则的描述,默认值为空字符串。规范如下:​
  • 必须以字母、数字或中文开头,可包含字母、数字、中文及以下特殊字符:英文逗号(,)、点号(.)、下划线(_)、空格( )、等号(=)、中划线(-)、中文逗号(,)、中文句号(。)。​
  • 长度限制为0 ~ 255个字符。​
​
Rules.N.Tags.N.Key String 可选 示例值:k1​
标签的标签键。​
  • 第一个N:表示转发规则的序号,取值范围为1 ~ 50。多个转发规则间请使用“&”分隔。​
  • 第二个N:表示标签键的序号,取值范围:1~50。多个标签键之间用&分隔。​
  • 不能以 volc:或sys:开头,包括任意大小写形式。​
  • 长度取值范围为1~128字符,允许输入各国语言文字、数字、空格( )、下划线(_)、点号(.)、半角冒号(:)、斜杠(/)、等号(=)、加号(+)、中划线(-)和@(@)。​
  • 若标签键开头或结尾存在空格,系统会自动为其去除。​
同一资源的标签键不允许重复。​
​
Rules.N.Tags.N.Value String 可选 示例值:v1​
标签的标签值。​
  • 第一个N:表示转发规则的序号,取值范围为1 ~ 50。多个转发规则间请使用“&”分隔。​
  • 第二个N:表示标签值的序号,取值范围:1~50。多个标签值之间用&分隔。​
  • 长度取值范围为0~256字符,不填默认为空。​
  • 允许输入各国语言文字、数字、空格( )、下划线(_)、点号(.)、半角冒号(:)、斜杠(/)、等号(=)、加号(+)、中划线(-)和@(@)。​
  • 大小写敏感。​
  • 若标签值开头或结尾存在空格,系统会自动为其去除。​
若传入该参数,则必须先传入标签键。​
​
​
​
返回参数​
RequestId String 示例值:2021081316135705146063000AD724****​
请求ID。​
​
RuleIds String[] 示例值:["rule-2fegss1cplxxc5oxruvvq****","rule-3ciynwkb46c6rrt4jszkd****"]​
转发规则ID。​
​
​
​
请求示例​
​
GET /?Action=CreateRules&Version=2020-04-01&ListenerId=lsn-2fea4ayvu2g3k5oxruuz****&Rules.1.Domain=www.test.com&Rules.1.Url=/poo&Rules.1.ActionType=Forward&Rules.1.ServerGroupId=rsp-bp1o94dp5i6ea****&Rules.1.RedirectConfig.Protocol=HTTPS&Rules.1.RedirectConfig.Host=www.test.com&Rules.1.RedirectConfig.Path=/abc&Rules.1.RedirectConfig.Port=443&Rules.1.RedirectConfig.StatusCode=301&Rules.1.Description=This is a rule.&Rules.1.Tags.1.Key=k1&Rules.1.Tags.1.Value=v1​
Host: clb.cn-beijing.volcengineapi.com​
X-Date: 20251121T094038Z​
Authorization: HMAC-SHA256 Credential=Adfks******wekfwe/20251121/cn-beijing/clb/request, SignedHeaders=host;x-date, Signature=47a7d934ff7b37c03938******cd7b8278a40a1057690c401e92246a0e41085f​
​
返回示例​
​
{​
"ResponseMetadata": {​
"RequestId": "20230604110420****100232280022D31",​
"Action": "CreateRules",​
"Version": "2020-04-01",​
"Service": "clb",​
"Region": "cn-beijing"​
},​
"Result": {​
"RequestId": "2021081316135705146063000AD724****",​
"RuleIds": [​
"rule-2fegss1cplxxc5oxruvvq****",​
"rule-3ciynwkb46c6rrt4jszkd****"​
]​
}​
}​
​
错误码​
此处仅展示当前API的错误码,更多错误码请参见公共错误码。​
​
状态码​
错误码​
错误信息​
说明​
400​
InvalidDefaultRule.UnSupportAction​
The specified Default Rule does not support this action.​
指定的默认转发规则不支持当前操作。​
400​
InvalidDescription.Malformed​
The specified Description is malformed.​
指定的 Description 参数格式不合法。​
400​
InvalidIncorrectOrder.Malformed​
The specified index order is malformed.​
指定的索引顺序参数格式不合法。​
400​
InvalidListener.NotSupportRule​
The specified Listener not support rule.​
指定的监听器不支持转发规则。​
400​
InvalidListenerServerGroup.UnSupportAction​
The specified Listener does not support this action.​
指定的监听器未绑定默认后端服务器组,不支持当前操作。​
400​
InvalidLoadBalancer.InvalidStatus​
The specified LoadBalancer is not in the correct status for the request.​
指定的负载均衡所处状态无法响应该请求。​
400​
InvalidProtocol.ListenerMismatch​
The specified Protocol and Listener are not matched.​
指定的协议与监听器不匹配。​
400​
InvalidQuotaCode.Malformed​
The specified QuotaCode is malformed.​
指定的 QuotaCode 参数格式不合法。​
400​
InvalidRuleRedirectConfig.ActionTypeMismatch​
The specified RedirectConfig not match with ActionType.​
指定的重定向配置与转发类型不一致。​
400​
InvalidRules.ActionType.Malformed​
The specified Rules.ActionType is malformed.​
指定的 Rules.ActionType 参数格式不合法。​
400​
InvalidRules.Domain.Malformed​
The specified Rules.Domain is malformed.​
指定的 Rules.Domain 参数格式不合法。​
400​
InvalidRules.RedirectConfig.Host.Malformed​
The specified Rules.RedirectConfig.Host is malformed.​
指定的 Rules.RedirectConfig.Host 参数格式不合法。​
400​
InvalidRules.RedirectConfig.Path.Malformed​
The specified Rules.RedirectConfig.Path is malformed.​
指定的 Rules.RedirectConfig.Path 参数格式不合法。​
400​
InvalidRules.RedirectConfig.Port.Malformed​
The specified Rules.RedirectConfig.Port is malformed.​
指定的 Rules.RedirectConfig.Port 参数格式不合法。​
400​
InvalidRules.RedirectConfig.Protocol.Malformed​
The specified Rules.RedirectConfig.Protocol is malformed.​
指定的 Rules.RedirectConfig.Protocol 参数格式不合法。​
400​
InvalidRules.RedirectConfig.StatusCode.Malformed​
The specified Rules.RedirectConfig.StatusCode is malformed.​
指定的 Rules.RedirectConfig.StatusCode 参数格式不合法。​
400​
InvalidRules.URL.Malformed​
The specified Rules.URL is malformed.​
指定的 Rules.URL 参数格式不合法。​
400​
InvalidServerGroup.ActionTypeMismatch​
The specified ServerGroup not match with ActionType.​
指定的后端服务器组与转发类型不一致。​
400​
InvalidServerGroup.UnSupportAction​
The specified ServerGroup does not support this action.​
指定的后端服务器组不支持当前操作。​
400​
InvalidTagKey.Malformed​
The specified TagKey is malformed.​
指定的 TagKey 参数格式不合法。​
400​
InvalidTagValue.Malformed​
The specified TagValue is malformed.​
指定的 TagValue 参数格式不合法。​
400​
LimitExceeded.ServiceManagedTag​
You've reached the limit on the number of service managed tags that you can create.​
已达到单次可创建受管资源标签键值数量的上限。​
400​
LimitExceeded.TagOperation​
You've reached the limit on the number of tags that you can operate at a time.​
已达到单次可操作的标签条目数量上限。​
400​
MissingParameter​
The request is missing a required parameter. Ensure that you have supplied all the required parameters for the request; for example, the 'Rules.RedirectConfig.Host, Rules.RedirectConfig.Path, Rules.RedirectConfig.Port'.​
该请求缺少必要参数。请确保发起请求已提供全部必要参数,比如 Rules.RedirectConfig.Host, Rules.RedirectConfig.Path, Rules.RedirectConfig.Port。​
400​
MissingParameter​
The request is missing a required parameter. Ensure that you have supplied all the required parameters for the request; for example, the 'Domain, URL'.​
该请求缺少必要参数。请确保发起请求已提供全部必要参数,比如 Domain, URL。​
400​
MissingParameter​
The request is missing a required parameter. Ensure that you have supplied all the required parameters for the request; for example, the 'ListenerId'.​
该请求缺少必要参数。请确保发起请求已提供全部必要参数,比如 ListenerId。​
400​
MissingParameter​
The request is missing a required parameter. Ensure that you have supplied all the required parameters for the request; for example, the ''.​
该请求缺少必要参数。请确保发起请求已提供全部必要参数,比如 。​
400​
QuotaExceed.RuleNumberEachListener​
You've reached the limit on the number of Rule that you can associate.​
已达到监听器可关联的转发规则的数量的配额上限。​
400​
UnsupportedOperation.AccountArrears​
The request on the specified instance is denied due to the account in arrears status.​
因账户处于欠费状态,对于该实例的操作请求被拒绝。​
403​
Forbidden​
You are not authorized to perform operations on the service managed tag.​
无权限对指定资源打上受管标签。​
403​
Forbidden​
You are not authorized to perform operations on the specified service.​
无权限对指定服务进行操作。​
403​
Forbidden​
You are not authorized to perform operations on the system tag.​
无权限对指定资源打上系统标签。​
403​
InvalidResourceType.ServcieManaged​
The specified ResourceType is managed by a service.​
指定的资源是服务托管资源。​
404​
InvalidExclusiveCluster.NotFound​
The specified ExclusiveCluster does not exist.​
指定的独占集群不存在。​
404​
InvalidListener.NotFound​
The specified Listener does not exist.​
指定的监听器不存在。​
404​
InvalidLoadBalancer.NotFound​
The specified LoadBalancer does not exist.​
指定的负载均衡不存在。​
404​
InvalidRule.NotFound​
The specified Rule does not exist.​
指定的转发规则不存在。​
404​
InvalidServerGroup.NotFound​
The specified ServerGroup does not exist.​
指定的后端服务器组不存在。​
409​
InvalidRule.Conflict​
The specified Rule already exists.​
指定的转发规则已存在。​
412​
InvalidExclusiveCluster.Expired​
The specified ExclusiveCluster has expired.​
指定的独占集群已过期。​
412​
InvalidExclusiveCluster.UnPurchased​
The specified ExclusiveCluster is not purchased.​
指定的独占集群未购买。​
412​
InvalidLoadBalancer.Expired​
The specified LoadBalancer has expired.​
指定的负载均衡已过期。​
500​
InternalError​
An internal error has occurred.​
发生内部错误。​
​
​
最近更新时间:2026.03.17 08:33:44
这个页面对您有帮助吗?
有用
有用
无用
无用