创建多条转发规则。
接口说明
调用该接口创建转发规则时,请注意以下事项:
- 配置Redirect转发动作时,除了HttpCode参数外,其余参数不能都配置默认值。
- 同一个转发规则配置多个转发动作时,Rewrite转发动作必须配置ForwardGroup的动作类型。
- CreateRules接口属于异步接口,即系统返回一个实例ID,但该多条转发规则尚未创建成功,系统后台的创建任务仍在进行。您可以调用ListRules查询多条转发规则的创建状态:
- 当多条转发规则处于Provisioning状态时,表示多条转发规则正在创建中。
- 当多条转发规则处于Available状态时,表示多条转发规则创建成功。
- 一条转发规则最多支持添加的条件数(RuleConditions)和动作数(RuleActions)如下:
- 条件数:基础版5条,标准版10条,WAF增强版10条。
- 动作数:基础版3条,标准版5条,WAF增强版10条。
调试
您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI
Explorer可以自动生成SDK代码示例。
调试调试
授权信息
下表是API对应的授权信息,可以在RAM权限策略语句的Action
元素中使用,用来给RAM用户或RAM角色授予调用此API的权限。具体说明如下:
- 操作:是指具体的权限点。
- 访问级别:是指每个操作的访问级别,取值为写入(Write)、读取(Read)或列出(List)。
- 资源类型:是指操作中支持授权的资源类型。具体说明如下:
- 对于必选的资源类型,用背景高亮的方式表示。
- 对于不支持资源级授权的操作,用
全部资源
表示。
- 条件关键字:是指云产品自身定义的条件关键字。
- 关联操作:是指成功执行操作所需要的其他权限。操作者必须同时具备关联操作的权限,操作才能成功。
操作 | 访问级别 | 资源类型 | 条件关键字 | 关联操作 |
---|---|---|---|---|
alb:CreateRules | Write |
|
|
无 |
请求参数
名称 | 类型 | 必填 | 描述 | 示例值 |
---|---|---|---|---|
ListenerId | string | 是 |
应用型负载均衡实例监听ID。 |
lsr-bp1bpn0kn908w4nbw**** |
ClientToken | string | 否 |
客户端Token,用于保证请求的幂等性。 从您的客户端生成一个参数值,确保不同请求间该参数值唯一。ClientToken只支持ASCII字符。 说明 | 5A2CFF0E-5718-45B5-9D4D-70B3FF3898 |
DryRun | boolean | 否 | 是否只预检此次请求,取值:
|
false |
Rules | object [] | 是 |
转发规则列表。一次最多不能超过10条。 |
|
Priority | integer | 是 |
规则优先级,取值:1~10000。值越小表示优先级越高。最多支持添加10个规则优先级。 说明 | 10 |
RuleActions | object [] | 是 | 规则动作列表。 |
|
FixedResponseConfig | object | 否 |
固定响应内容配置。最多支持添加20个固定响应内容。 |
|
Content | string | 否 |
返回的固定内容。最大支持存储1 KB,只支持ASCII字符。 |
dssacav |
ContentType | string | 否 |
返回固定内容的格式。取值:
|
text/plain |
HttpCode | string | 否 |
返回的HTTP响应码,仅支持HTTP_2xx、HTTP_4xx、HTTP_5xx数字型字符串,x为任意数字。 |
HTTP_200 |
ForwardGroupConfig | object | 否 |
转发组对应的配置。最多支持添加20个转发组。 |
|
ServerGroupTuples | object [] | 否 |
转发到的目的服务器组列表。 |
|
ServerGroupId | string | 否 |
转发到的目的服务器组。 |
sgp-k86c1ov501id6p**** |
Weight | integer | 否 |
权重。取值越大,权重越大,表示转发的访问请求更多。取值范围:0~100。
|
100 |
ServerGroupStickySession | object | 否 |
服务器组之间会话保持。 |
|
Enabled | boolean | 否 |
是否开启会话保持。取值:
|
false |
Timeout | integer | 否 |
超时时间。单位:秒。取值范围:1~86400。 |
2 |
InsertHeaderConfig | object | 否 |
写入头字段配置。最多支持添加20个写入头字段。 |
|
Key | string | 否 |
插入的头字段名称,长度为1~40个字符,支持大小写字母a~z、数字、下划线(_)和短划线(-)。InsertHeaderConfig中的头字段名称不能重复。 说明 | key |
Value | string | 否 | 插入的头字段内容。
|
UserDefined |
ValueType | string | 否 |
头字段内容类型。取值:
|
UserDefined |
Order | integer | 是 |
转发规则动作执行的顺序,取值范围:1~50000,按值从小到大执行动作。值不能为空,不能重复。最多支持添加20个转发规则动作的顺序。 |
1 |
RedirectConfig | object | 否 |
外部重定向配置。最多支持添加20个外部重定向。 |
|
Host | string | 否 |
要跳转的主机地址。取值:
|
www.example.com |
HttpCode | string | 否 |
跳转方式。取值:301、302、303、307或308。 |
301 |
Path | string | 否 |
要跳转的路径。取值:
|
/test |
Port | string | 否 |
要跳转的端口。
|
10 |
Protocol | string | 否 |
要跳转的协议。取值:
说明 | HTTP |
Query | string | 否 | 要跳转的查询字符串。
|
quert |
RewriteConfig | object | 否 |
内部重定向。最多支持添加20个内部重定向。 |
|
Host | string | 否 |
内部跳转的目的主机地址。取值:
|
www.example.com |
Path | string | 否 |
要跳转的路径。取值:
|
/tsdf |
Query | string | 否 |
内部跳转的查询字符串。
|
quedsa |
Type | string | 是 |
动作类型。最多支持添加11个动作类型。取值:
转发规则中包括的动作类型:
|
ForwardGroup |
TrafficLimitConfig | object | 否 |
流量限速。最多支持添加20个流量限速。 |
|
QPS | integer | 否 |
每秒请求次数。取值范围:1~1000000。 |
100 |
PerIpQps | integer | 否 |
单IP每秒请求次数。 取值范围:1 ~ 1000000。 说明 | 80 |
TrafficMirrorConfig | object | 否 | 流量镜像。最多支持添加20个流量镜像。 |
|
TargetType | string | 否 |
镜像的目标类型。取值:
|
ForwardGroupMirror |
MirrorGroupConfig | object | 否 |
流量镜像至服务器组。 |
|
ServerGroupTuples | object [] | 否 |
流量镜像至服务器组。 |
|
ServerGroupId | string | 否 |
服务器组ID。 |
srg-00mkgijak0w4qgz9**** |
RemoveHeaderConfig | object | 否 |
去除HTTP头部配置。 |
|
Key | string | 否 |
去除的头字段名称,长度为1~40个字符,支持大小写字母a~z、数字、下划线(_)和短划线(-)。头字段名称不能重复用于RemoveHeader中。
|
test |
CorsConfig | object | 否 |
跨域。 |
|
AllowOrigin | array | 否 |
允许访问的来源。 |
|
string | 否 |
允许访问的来源。支持配置为
|
http://example.com | |
AllowMethods | array | 否 |
选择跨域访问时允许的HTTP方法。 |
|
string | 否 |
选择跨域访问时允许的HTTP方法。取值:
|
GET | |
AllowHeaders | array | 否 |
允许跨域的Header列表。 |
|
string | 否 |
允许跨域的Header列表。支持配置为 |
test_123 | |
ExposeHeaders | array | 否 |
允许暴露的Header列表。 |
|
string | 否 |
允许暴露的Header列表。支持配置为 |
test_123 | |
AllowCredentials | string | 否 |
是否允许携带凭证信息。取值:
|
on |
MaxAge | long | 否 |
预检请求在浏览器的最大缓存时间,单位:秒。 取值范围:-1~172800。 |
1000 |
RuleConditions | object [] | 是 |
转发规则条件列表。 |
|
CookieConfig | object | 否 |
Cookie配置。最多支持添加20个Cookie。 |
|
Values | object [] | 否 |
Cookie值。 |
|
Key | string | 否 |
Cookie键。
|
test |
Value | string | 否 |
Cookie值。
|
test |
HeaderConfig | object | 否 |
头字段配置。最多支持添加20个头字段。 |
|
Key | string | 否 |
头字段键。
|
Port |
Values | array | 否 |
头字段值。 |
|
string | 否 |
头字段值。同一个转发规则条件内头字段值不能重复。
|
5006 | |
HostConfig | object | 否 |
主机配置。最多支持添加20个主机。 |
|
Values | array | 否 |
主机名。 |
|
string | 否 |
主机名。一个转发规则条件中只能有一个主机名,并且取值不能重复。
|
www.example.com | |
MethodConfig | object | 否 |
请求方法配置。最多支持添加20个请求方法。 |
|
Values | array | 否 |
请求方法。 |
|
string | 否 |
请求方法。取值:HEAD、GET、POST、OPTIONS、PUT、PATCH、DELETE。 |
PUT | |
PathConfig | object | 否 |
转发路径配置。最多支持添加20个请转发路径。 |
|
Values | array | 否 |
转发路径。 |
|
string | 否 |
转发路径。取值范围:
|
/test | |
QueryStringConfig | object | 否 |
查询字符串条件配置。最多支持添加20个查询字符串条件。 |
|
Values | object [] | 否 |
查询字符串条件。 |
|
Key | string | 否 |
查询字符串键。
|
test |
Value | string | 否 |
查询字符串值。
|
test |
ResponseHeaderConfig | object | 否 |
标头条件配置。最多支持添加20个标头条件。 |
|
Key | string | 否 |
头字段键。
|
Port |
Values | array | 否 |
头字段值。 |
|
string | 否 |
头字段值。
|
5006 | |
ResponseStatusCodeConfig | object | 否 |
响应状态码配置。 |
|
Values | array | 否 |
响应状态码列表。 |
|
string | 否 |
响应状态码。 |
200 | |
Type | string | 是 |
转发规则类型。最多支持添加7个转发类型。取值:
|
Host |
SourceIpConfig | object | 否 |
基于源IP业务流量匹配。当Type为SourceIP时必选且有效。一条转发规则中最多支持添加5条SourceIp。 |
|
Values | array | 否 |
基于源IP业务流量匹配 |
|
string | 否 |
添加一个或多个IP地址或者IP地址段。 一条转发规则中最多支持添加5条SourceIp。 |
192.168.0.0/32 | |
RuleName | string | 是 |
转发规则名称。最多支持添加20个转发规则名称。
|
test |
Direction | string | 否 |
转发规则的方向。最多支持添加1个转发规则方向。取值:
说明 | Request |
Tag | object [] | 否 | 标签。 |
|
Key | string | 否 |
标签键。最多支持128个字符,不能以aliyun或acs:开头,不能包含http://或https://。 |
env |
Value | string | 否 |
标签值。最多支持128个字符,不能以aliyun或acs:开头,不能包含http://或https://。 |
product |
返回参数
名称 | 类型 | 描述 | 示例值 |
---|---|---|---|
object |
创建多条转发规则。 |
||
JobId | string |
异步任务ID。 |
72dcd26b-f12d-4c27-b3af-18f6aed5**** |
RequestId | string |
请求ID。 |
365F4154-92F6-4AE4-92F8-7FF34B540710 |
RuleIds | object [] |
转发规则列表。 |
|
RuleId | string |
转发规则ID。 |
rule-a3x3pg1yohq3lq**** |
Priority | integer |
转发规则优先级,取值范围:1~10000。值越小表示优先级越高。 说明 | 10 |
示例
正常返回示例
JSON
格式
{
"JobId": "72dcd26b-f12d-4c27-b3af-18f6aed5****",
"RequestId": "365F4154-92F6-4AE4-92F8-7FF34B540710",
"RuleIds": [
{
"RuleId": "rule-a3x3pg1yohq3lq****",
"Priority": 10
}
]
}
错误码
HTTP status code | 错误码 | 错误信息 | 描述 |
---|---|---|---|
400 | IncorrectStatus.Listener | The status of %s [%s] is incorrect. | 资源%s [%s]的状态无效。 |
400 | OperationDenied.IpGroupCanNotUsedForMirrorAction | The operation is not allowed because of %s. | 操作被拒绝,原因是%s。 |
400 | OperationDenied.SameGroupForForwardAndMirrorAction | The operation is not allowed because of %s. | 操作被拒绝,原因是%s。 |
400 | OperationDenied.GRPCServerGroup | The operation is not allowed because of %s. | 操作被拒绝,原因是%s。 |
400 | Conflict.Priority | There is already %s having the same configuration with %s. | %s冲突,已经存在同配置的%s。 |
400 | ResourceQuotaExceeded.LoadBalancerRulesNum | The quota of %s is exceeded for resource %s, usage %s/%s. | 配额%s已超额度限制,资源是%s,目前已使用%s,配额为%s。 |
400 | ResourceQuotaExceeded.ServerGroupAttachedNum | The quota of %s is exceeded for resource %s, usage %s/%s. | 配额%s已超额度限制,资源是%s,目前已使用%s,配额为%s。 |
400 | ResourceQuotaExceeded.LoadBalancerServersNum | The quota of %s is exceeded for resource %s, usage %s/%s. | 配额%s已超额度限制,资源是%s,目前已使用%s,配额为%s。 |
400 | ResourceQuotaExceeded.ServerAddedNum | The quota of %s is exceeded for resource %s, usage %s/%s. | 配额%s已超额度限制,资源是%s,目前已使用%s,配额为%s。 |
400 | QuotaExceeded.RuleWildcardsNum | The quota of %s is exceeded, usage %s/%s. | 配额%s已超额度限制,目前已使用%s,配额为%s。 |
400 | QuotaExceeded.RuleMatchEvaluationsNum | The quota of %s is exceeded, usage %s/%s. | 配额%s已超额度限制,目前已使用%s,配额为%s。 |
400 | QuotaExceeded.RuleActionsNum | The quota of %s is exceeded, usage %s/%s. | 配额%s已超额度限制,目前已使用%s,配额为%s。 |
400 | Mismatch.VpcId | The %s is mismatched for %s and %s. | %s在%s和%s中不匹配。 |
400 | Mismatch.Protocol | The %s is mismatched for %s and %s. | %s在%s和%s中不匹配。 |
400 | OperationDenied.RewriteMissingForwardGroup | The operation is not allowed because of RewriteMissingForwardGroup. | 操作被拒绝,原因是RewriteMissingForwardGroup。 |
404 | ResourceNotFound.Listener | The specified resource %s is not found. | 资源%s不存在。 |
404 | ResourceNotFound.ServerGroup | The specified resource %s is not found. | 资源%s不存在。 |
访问错误中心查看更多错误码。
变更历史
变更时间 | 变更内容概要 | 操作 | ||||||
---|---|---|---|---|---|---|---|---|
2023-11-09 | OpenAPI 错误码发生变更 | 看变更集 | ||||||
|
内容没看懂? 不太想学习?想快速解决? 有偿解决: 联系专家
阿里云企业补贴进行中: 马上申请
腾讯云限时活动1折起,即将结束: 马上收藏
同尘科技为腾讯云授权服务中心。
购买腾讯云产品享受折上折,更有现金返利:同意关联,立享优惠
转转请注明出处:https://www.yunxiaoer.com/168821.html