You need to enable JavaScript to run this app.
导航
DescribeRules
最近更新时间:2025.08.05 17:18:20首次发布时间:2022.05.20 22:34:48
复制全文
我的收藏
有用
有用
无用
无用

请求说明

API 名称:DescribeRules
API 描述:获取指定监听器转发规则列表。

使用限制

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

调试

URI 参数

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

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

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

请求参数

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

参数类型是否必选参数说明示例值
ListenerId
String
监听器 ID。
lsn-2fea4ayvu2g3k5oxruuz****

返回参数

参数类型参数说明示例值
RequestId
String
请求 ID。
20210811152539010225146063030****
RulesArray符合条件的转发规则的详细信息。详见 Rules(基础版)Rules(标准版)-

Rules(基础版)

参数

类型

参数说明

RuleIdString转发规则 ID。
DomainString转发条件中的域名。
UrlString转发条件中的路径。

RuleAction

String

转发动作:

  • 空值:转发至。

  • Redirect:重定向。

ServerGroupIdString转发规则关联的后端服务器组 ID。

TrafficLimitEnabled

String

QPS 限速功能的开启状态:

  • on:开启。

  • off:关闭。

TrafficLimitQPSIntegerQPS,表示每秒请求数。
DescriptionString转发规则的描述。

RewriteEnabled

String

“重写”功能的开启状态:

  • on:开启。

  • off:关闭。

RedirectConfigStruct重定向配置。具体可参见 RedirectConfig

RewriteConfig

Struct

重写配置信息。具体可参见 RewriteConfig

ForwardGroupConfig

Struct

服务器组配置,具体可参见ForwardGroupConfig

RedirectConfig

参数类型参数说明

RedirectDomain

String

请求被重定向到的域名。
重定向到的域名设置为空时,系统返回的值为${host}。该变量表示重定向到的域名与请求的域名相同。

RedirectUri

String

请求被重定向到的路径。
重定向到的路径设置为空时,系统返回的值为${request_uri}。该变量表示重定向到的路径与请求的路径相同。

RedirectPort

Integer

请求被重定向到的端口。
重定向到的端口设置为空,系统返回的值为${port}。该变量表示重定向到的端口与请求的端口相同。

RedirectHttpCodeInteger状态码,用于表示重定向的响应。
RedirectProtocolString重定向使用的协议。

RewriteConfig

参数类型参数说明
RewritePathString重写后的路径。

ForwardGroupConfig

参数类型参数说明
ServerGroupTuplesArray请求被转发到的后端服务器组的列表。具体可参见 ServerGroupTuples

StickySessionEnabled

String

组间会话保持功能的开启状态:

  • on:开启。

  • off:关闭。

StickySessionTimeoutInteger组间会话保持的超时时间。单位:秒。

ServerGroupTuples

参数

类型

参数说明

ServerGroupIdString请求被转发到的后端服务器组的 ID。
WeightInteger服务器组的权重。

Rules(标准版)

参数

类型

参数说明

RuleIdString转发规则 ID。
DescriptionString转发规则的描述。
PriorityInteger转发规则的优先级。
RuleConditionsArray转发条件。具体可参见 RuleConditions
RuleActionsArray转发动作。具体可参见 RuleActions

RuleConditions

参数类型参数说明

Type

String

转发条件的类型:

  • Host:域名。

  • Path:路径。

  • Header:HTTP 标头。

HostConfigStruct域名配置,具体可参见 HostConfig
PathConfigStruct路径配置,具体可参见 PathConfig

HeaderConfig

Struct

HTTP 标头配置,具体可参见 HeaderConfig

MethodConfigStruct请求方法,具体可参见 MethodConfig
QueryStringConfigStruct查询字符串,具体可参见QueryStringConfig

HostConfig

参数类型参数说明
ValuesArray域名。

PathConfig

参数类型参数说明
ValuesArray路径。

HeaderConfig

参数

类型

参数说明

KeyStringHTTP 标头的键。
ValuesArrayHTTP 标头的值。

MethodConfig

参数

类型

参数说明

Values

Array

请求方法。

QueryStringConfig

参数

类型

参数说明

Rules.N.RuleConditions.N.QueryStringConfig.Values.NArray查询字符串的配置。

Rules.N.RuleConditions.N.QueryStringConfig.Values.N.Key

String

查询字符串的键。

Rules.N.RuleConditions.N.QueryStringConfig.Values.N.ValueString查询字符串的值。

RuleActions

参数

类型

参数说明

Type

String

转发动作的类型:

  • ForwardGroup:转发至。ALB 将请求转发至您指定的后端服务器组。

  • Redirect:重定向至。ALB 对请求进行重定向。

  • Rewrite:重写。ALB 改写请求路径,向后端服务器请求新路径下的内容。

  • TrafficLimit: 限速。当请求数量超过配置的 QPS 时,ALB 会拒绝超出限制的请求。

  • FixedResponse:返回固定响应。由您自定义响应状态码和响应内容。

ForwardGroupConfigStruct“转发至”转发动作的配置,具体可参见ForwardGroupConfig
RedirectConfigStruct“重定向至”转发动作的配置,具体可参见RedirectConfig
RewriteConfigStruct“重写”转发动作的配置,具体可参见RewriteConfig
TrafficLimitConfigStruct“限速”转发动作的配置,具体可参见TrafficLimitConfig
FixedResponseConfigStruct“返回固定响应”转发动作的配置,具体可参见 FixedResponseConfig

ForwardGroupConfig

参数

类型

参数说明

ServerGroupTuples

Array

转发至服务器组配置,具体可参见ServerGroupTuples

ServerGroupStickySessionStruct转发至会话保持配置,具体可参见ServerGroupStickySession

ServerGroupTuples

参数

类型

参数说明

ServerGroupId

String

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

Weight

Integer

后端服务器组的权重。

ServerGroupStickySession

参数

类型

参数说明

Enabled

String

是否已开启组间会话保持:

  • on:已开启。

  • off:未开启。

Timeout

Integer

组间会话保持的超时时间。单位:秒。

RedirectConfig

参数

类型

参数说明

Host

String

请求被重定向到的域名。

HttpCodeInteger状态码,用于表示重定向的响应。
PathString请求被重定向到的路径。
PortInteger请求被重定向到的端口。

Protocol

String

重定向使用的协议:

  • HTTP

  • HTTPS

RewriteConfig

参数

类型

参数说明

PathString重写后的路径。

TrafficLimitConfig

参数

类型

参数说明

QPS

Integer

限速 QPS。QPS 表示每秒请求数。

FixedResponseConfig

参数

类型

参数说明

Content

String

返回的固定内容。

ContentTypeString返回的固定内容的格式。
HttpCodeString返回的 HTTP 响应码。

请求示例

GET /?Action=DescribeRules&ListenerId=lsn-1g0puwcxu****8ibuxxw2pmf7&Version=2020-04-01 HTTP/1.1
Host: alb.cn-beijing.volcengineapi.com
Region: cn-beijing
ServiceName: alb

返回示例

基础版

{
  "ResponseMetadata": {
    "RequestId": "20250415141007030DD9CCED8E1561****",
    "Action": "DescribeRules",
    "Version": "2020-04-01",
    "Service": "alb",
    "Region": "cn-beijing"
  },
  "Result": {
    "RequestId": "20250415141007030DD9CCED8E1561****",
    "Rules": [
      {
        "RuleId": "rule-1vymuiwz3k2rk3766qags****",
        "Domain": "-",
        "Url": "/",
        "Description": "",
        "TrafficLimitEnabled": "off",
        "TrafficLimitQPS": 0,
        "RuleAction": "",
        "ServerGroupId": "rsp-3vu05crn1qrcw6096ps6****",
        "RewriteEnabled": "off",
        "RedirectConfig": null,
        "RewriteConfig": null,
        "ForwardGroupConfig": null
      }
    ]
  }
}

标准版

{
    "ResponseMetadata": {
        "RequestId": "20250313182653****2514214204001104",
        "Action": "DescribeRules",
        "Version": "2020-04-01",
        "Service": "alb",
        "Region": "cn-beijing"
    },
    "Result": {
        "RequestId": "20250313182653****2514214204001104",
        "Rules": [
            {
                "RuleId": "rule-2wx8do94l2hhc7ootqnpt****",
                "Description": "desc",
                "Priority": 1,
                "Direction": "request",
                "RuleConditions": [
                    {
                        "Type": "Host",
                        "HostConfig": {
                            "Values": [
                                "domain.com",
                                "abc.cn"
                            ]
                        },
                        "PathConfig": {},
                        "HeaderConfig": {}
                    },
                    {
                        "Type": "Path",
                        "HostConfig": {},
                        "PathConfig": {
                            "Values": [
                                "/"
                            ]
                        },
                        "HeaderConfig": {}
                    }
                ],
                "RuleActions": [
                    {
                        "Type": "TrafficLimit",
                        "ForwardGroupConfig": {},
                        "RedirectConfig": {},
                        "RewriteConfig": {},
                        "TrafficLimitConfig": {
                            "QPS": 899
                        }
                    },
                    {
                        "Type": "Rewrite",
                        "ForwardGroupConfig": {},
                        "RedirectConfig": {},
                        "RewriteConfig": {
                            "Path": "/rewrite"
                        },
                        "TrafficLimitConfig": {}
                    },
                    {
                        "Type": "ForwardGroup",
                        "ForwardGroupConfig": {
                            "ServerGroupStickySession": {
                                "Enabled": "on",
                                "Timeout": 8888
                            },
                            "ServerGroupTuples": [
                                {
                                    "ServerGroupId": "rsp-1ijdvi6fty8sg74adhfom****",
                                    "Weight": 100
                                },
                                {
                                    "ServerGroupId": "rsp-2wx88juyt4utc7ootqny****",
                                    "Weight": 100
                                }
                            ]
                        },
                        "RedirectConfig": {},
                        "RewriteConfig": {},
                        "TrafficLimitConfig": {}
                    }
                ]
            },
            {
                "RuleId": "rule-1ijdvra0wkidc74adhf2t****",
                "Description": "",
                "Direction": "request",
                "RuleActions": [
                    {
                        "Type": "ForwardGroup",
                        "ForwardGroupConfig": {
                            "ServerGroupTuples": [
                                {
                                    "ServerGroupId": "rsp-1ijdvi6fty8sg74adhfo****",
                                    "Weight": 100
                                }
                            ]
                        }
                    }
                ]
            }
        ]
    }
}

错误码

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

HTTP Code错误码错误信息错误描述
404InvalidListener.NotFoundThe specified Listener does not exist.指定的监听器不存在。