ALB扩展版支持MCP(Model Context Protocol)协议代理能力,支持将现有的MCP服务器、REST API或函数计算快速接入,统一转换为MCP格式的工具接口供AI Agent调用,简化智能体与企业系统的集成。
ALB扩展版的MCP服务管理为白名单功能,如需使用,请联系您的商务经理申请开通。
方案架构
扩展版ALB实例接收MCP协议请求,通过转发规则路由至MCP类型服务器组。MCP类型服务器组统一代理后端的MCP服务器、REST API和函数计算服务,将响应转换为MCP格式返回。同时,MCP代理组件内置语义搜索能力,Agent可按需检索匹配的工具,无需加载全量工具列表,减少Token消耗。
-
扩展版ALB实例:提供负载均衡和流量转发能力。
-
HTTPS监听:接收客户端请求。
-
转发规则:根据请求路径匹配MCP协议请求并转发至MCP类型服务器组。
-
服务扩展:通过MCP代理组件实现MCP协议转换和语义搜索。
-
MCP类型服务器组:统一代理MCP服务器、REST API和函数计算三类后端服务。
适用范围
-
用户已获取ALB扩展版公测资格。
-
用户已在华北6(乌兰察布)地域创建一个专有网络VPC,分别在可用区A和可用区B创建一个交换机,且交换机已配置公网SNAT(用于ALB访问公网 MCP 服务)。
-
用户已准备好与自定义域名匹配的服务器证书。非阿里云购买的证书需要上传到阿里云证书服务。
操作步骤
1.创建扩展版ALB实例
-
登录ALB控制台,选择华北6(乌兰察布)地域,单击创建应用型负载均衡。
-
在购买页完成以下配置,单击立即创建。
-
地域:默认选择华北6(乌兰察布)。
-
实例网络类型:选择公网。
-
VPC和可用区:选择目标VPC,勾选乌兰察布 可用区A和乌兰察布 可用区B后选择对应交换机,并自动分配公网IP。
-
协议版本:选择IPv4。
-
功能版本(实例费):选择扩展版。
-
-
在确认订单页面确认实例配置详情,单击立即开通。
2.创建服务器组
创建空服务器组
创建服务器类型的空服务器组,在后续创建监听时将作为默认规则的转发目标。本文的MCP请求均通过转发规则精确匹配,不会命中默认规则,因此该服务器组无需添加后端服务器。
-
在服务器组控制台,单击创建服务器组。
-
服务器组类型:选择服务器类型。
-
服务器组名称:一个易于识别的名称,本文为
sgp-default。 -
VPC:选择ALB实例所在VPC。
-
-
勾选对话框底部的适用于扩展版实例,单击创建。
创建MCP类型服务器组
-
在服务器组控制台,单击创建服务器组,服务器组类型选择MCP服务类型,给其一个易于识别的名称,本文为
sgp-mcp。 -
单击创建,在服务器组创建成功对话框单击添加后端服务器。
创建服务器组后,根据后端服务的类型,参考对应的标签页添加MCP服务。
MCP服务器
本示例接入一个自建的温度转换MCP服务。
单击添加MCP服务,完成以下配置,单击确定。
-
服务名称:输入易于大模型理解的名称,本文为
temperature-converter,表示提供温度换算服务。 -
服务类型:选择MCP服务器。
-
MCP服务节点:输入MCP服务的域名访问地址,如
http://mcp-backend.example.com:8000/mcp。MCP服务节点不支持直接填写IP地址,需使用域名格式。ALB扩展版访问MCP服务节点时仅通过公网权威DNS解析,如需访问VPC内网服务,需在公网DNS上将域名解析到对应的私网IP。 -
访问方式:选择Streamable HTTP。
以下为提供温度换算功能的MCP服务器示例代码,可部署在与ALB同VPC的ECS实例中。该ECS实例需确保与ALB实例网络互通,且安全组规则允许ALB访问MCP服务端口(文中为8000)。本文以Alibaba Cloud Linux 3.2104操作系统为例。
-
登录ECS实例,安装Python 3.11和pip,然后安装MCP依赖:
# Install Python 3.11 (requires 3.10 or later) sudo yum install -y python3.11 python3.11-pip # Install MCP dependencies sudo pip3.11 install "mcp>=1.0.0" -
创建项目目录和服务端代码:
mkdir mcp-server && cd mcp-server创建服务端代码
server.py:from mcp.server.fastmcp import FastMCP server = FastMCP("temperature-converter", host="0.0.0.0") @server.tool() def celsius_to_fahrenheit(celsius: float) -> str: """ Convert temperature from Celsius to Fahrenheit. Args: celsius: Temperature in degrees Celsius Returns: Temperature in Fahrenheit (e.g., "77.0") """ fahrenheit = celsius * 9 / 5 + 32 return str(fahrenheit) @server.tool() def fahrenheit_to_celsius(fahrenheit: float) -> str: """ Convert temperature from Fahrenheit to Celsius. Args: fahrenheit: Temperature in degrees Fahrenheit Returns: Temperature in Celsius (e.g., "25.0") """ celsius = (fahrenheit - 32) * 5 / 9 return str(celsius) if __name__ == "__main__": server.run(transport="streamable-http") -
启动MCP服务器:
nohup python3.11 server.py > server.log 2>&1 &查看日志确认启动成功:
cat server.log输出类似以下信息表示启动成功:
INFO: Started server process [12345] INFO: Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit) -
验证服务是否正常运行,执行以下命令:
curl -X POST http://127.0.0.1:8000/mcp \ -H "Content-Type: application/json" \ -H "Accept: application/json, text/event-stream" \ -d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-03-26","capabilities":{},"clientInfo":{"name":"test","version":"1.0"}}}'返回包含
serverInfo字段的JSON响应,表示MCP服务器已正常运行。
REST API
本示例接入阿里云OpenAPI来查询和管理ALB资源。阿里云OpenAPI需要AccessKey认证,需先创建凭证。
-
在ALB控制台左侧导航栏选择身份管理,单击创建身份凭证,凭证类型 选择AccessKey ,填入待管理的阿里云账号的AccessKey ID和AccessKey Secret,单击创建。该AccessKey需具备对应接口的调用权限。
AccessKey凭证类型为白名单功能。如需使用,请联系商务经理申请。
-
返回MCP服务器组,单击添加MCP服务,完成以下配置后单击确定。
-
服务名称:输入易于大模型理解的名称,本文为
alb-operator,表示提供ALB管理服务。 -
服务类型:选择REST API。
-
OpenAPI 配置:访问阿里云OpenAPI门户,在左侧导航栏单击获取元数据下载OpenAPI配置文件,根据实际需求编辑仅保留所需接口后,粘贴或导入。本文以仅保留查询类接口为例,示例中endpoints指定的地域为华北6(乌兰察布),用户可根据实际情况修改。
OpenAPI配置文件示例(仅保留查询类接口)
{ "version": "1.0", "info": { "style": "RPC", "product": "Alb", "version": "2020-06-16" }, "components": { "schemas": {} }, "apis": { "DescribeRegions": { "summary": "查询ALB可用地域。", "methods": [ "get", "post" ], "schemes": [ "http", "https" ], "security": [ { "AK": [] } ], "operationType": "read", "deprecated": false, "systemTags": { "operationType": "get", "abilityTreeCode": "203", "abilityTreeNodes": [ "FEATUREslbRXTOWD" ], "tenantRelevance": "publicInformation" }, "parameters": [ { "name": "AcceptLanguage", "in": "query", "schema": { "title": "语言", "description": "支持的语言。取值:\n\n- **zh-CN**(默认):中文\n\n- **en-US**:英文\n\n- **ja**:日文", "type": "string", "required": false, "example": "zh-CN", "default": "zh-CN" } } ], "responses": { "200": { "schema": { "title": "Schema of Response", "description": "返回数据的结构。", "type": "object", "properties": { "Regions": { "title": "Region列表", "description": "地域列表。", "type": "array", "items": { "description": "地域信息结构。", "type": "object", "properties": { "LocalName": { "title": "名称", "description": "地域名称。", "type": "string", "example": "华东1(杭州)" }, "RegionEndpoint": { "title": "endpoint", "description": "地域服务的Endpoint地址。", "type": "string", "example": "alb.cn-hangzhou.aliyuncs.com" }, "RegionId": { "title": "RegionId", "description": "地域ID。", "type": "string", "example": "cn-hangzhou" } } } }, "RequestId": { "title": "Id of the request", "description": "请求ID。", "type": "string", "example": "593B0448-D13E-4C56-AC0D-FDF0FDE0E9A3" } } } } }, "responseDemo": "[{\"type\":\"json\",\"example\":\"{\\n \\\"Regions\\\": [\\n {\\n \\\"LocalName\\\": \\\"华东1(杭州)\\\",\\n \\\"RegionEndpoint\\\": \\\"alb.cn-hangzhou.aliyuncs.com\\\",\\n \\\"RegionId\\\": \\\"cn-hangzhou\\\"\\n }\\n ],\\n \\\"RequestId\\\": \\\"593B0448-D13E-4C56-AC0D-FDF0FDE0E9A3\\\"\\n}\",\"errorExample\":\"\"},{\"type\":\"xml\",\"example\":\"<DescribeRegionsResponse>\\n <Regions>\\n <LocalName>华东1(杭州)</LocalName>\\n <RegionEndpoint>alb.cn-hangzhou.aliyuncs.com</RegionEndpoint>\\n <RegionId>cn-hangzhou</RegionId>\\n </Regions>\\n <RequestId>593B0448-D13E-4C56-AC0D-FDF0FDE0E9A3</RequestId>\\n</DescribeRegionsResponse>\",\"errorExample\":\"\"}]", "title": "查询地域" }, "DescribeZones": { "summary": "查询ALB一个地域下的可用区列表", "methods": [ "get", "post" ], "schemes": [ "http", "https" ], "security": [ { "AK": [] } ], "operationType": "read", "deprecated": false, "systemTags": { "operationType": "get", "abilityTreeCode": "204", "abilityTreeNodes": [ "FEATUREslbRXTOWD" ], "tenantRelevance": "publicInformation" }, "parameters": [ { "name": "AcceptLanguage", "in": "query", "schema": { "description": "支持的语言。取值:\n\n- **zh-CN**(默认):中文\n\n- **en-US**:英文\n\n- **ja**:日文", "type": "string", "required": false, "example": "zh-CN", "default": "zh-CN" } } ], "responses": { "200": { "schema": { "title": "Schema of Response", "description": "返回数据的结构。", "type": "object", "properties": { "RequestId": { "title": "Id of the request", "description": "请求ID。", "type": "string", "example": "593B0448-D13E-4C56-AC0D-FDF0FDE0E9A3" }, "Zones": { "title": "可用区列表", "description": "可用区列表。", "type": "array", "items": { "description": "可用区信息结构。", "type": "object", "properties": { "LocalName": { "title": "可用区名称", "description": "可用区名称。", "type": "string", "example": "杭州 可用区G" }, "ZoneId": { "title": "可用区id", "description": "可用区ID。", "type": "string", "example": "cn-hangzhou-g" } } } } } } } }, "responseDemo": "[{\"type\":\"json\",\"example\":\"{\\n \\\"RequestId\\\": \\\"593B0448-D13E-4C56-AC0D-FDF0FDE0E9A3\\\",\\n \\\"Zones\\\": [\\n {\\n \\\"LocalName\\\": \\\"杭州 可用区G\\\",\\n \\\"ZoneId\\\": \\\"cn-hangzhou-g\\\"\\n }\\n ]\\n}\",\"errorExample\":\"\"},{\"type\":\"xml\",\"example\":\"<DescribeZonesResponse>\\n <RequestId>593B0448-D13E-4C56-AC0D-FDF0FDE0E9A3</RequestId>\\n <Zones>\\n <LocalName>华东 1 可用区G</LocalName>\\n <ZoneId>cn-hangzhou-g</ZoneId>\\n </Zones>\\n</DescribeZonesResponse>\",\"errorExample\":\"\"}]", "title": "查询可用区" }, "GetLoadBalancerAttribute": { "summary": "查询指定负载均衡实例的详细信息。", "methods": [ "get", "post" ], "schemes": [ "http", "https" ], "security": [ { "AK": [] } ], "operationType": "read", "deprecated": false, "systemTags": { "operationType": "get", "abilityTreeCode": "200", "abilityTreeNodes": [ "FEATUREslbM7ALO6", "FEATUREslbK3ZR0L", "FEATUREslbN5IE4S" ] }, "parameters": [ { "name": "LoadBalancerId", "in": "query", "schema": { "title": "实例标识", "description": "应用型负载均衡实例ID。", "type": "string", "required": true, "example": "alb-o9ulmq5hgn68jk****" } } ], "responses": { "200": { "schema": { "title": "Schema of Response", "description": "应用型负载均衡实例详细配置信息。", "type": "object", "properties": { "AccessLogConfig": { "title": "访问日志属性", "description": "访问日志配置。", "type": "object", "properties": { "LogProject": { "title": "访问日志投递的logProject", "description": "日志项目。", "type": "string", "example": "sls-setter" }, "LogStore": { "title": "删除保护开启时间", "description": "日志存储。\n\n", "type": "string", "example": "test" } } }, "AddressAllocatedMode": { "title": "地址分配方式", "description": "地址模式。取值 :\n\n- **Fixed**:固定IP模式,表示使用固定的IP地址。\n\n- **Dynamic**:动态IP模式,表示在每个可用区动态分配IP地址。", "type": "string", "example": "Dynamic" }, "AddressType": { "title": "地址类型", "description": "应用型负载均衡实例的网络地址类型。取值:\n\n- **Internet**:负载均衡具有公网IP地址,DNS域名被解析到公网IP,因此可以在公网环境访问。\n\n- **Intranet**:负载均衡只有私网IP地址,DNS域名被解析到私网IP,因此只能被负载均衡所在VPC的内网环境访问。\n\n", "type": "string", "example": "Intranet" }, "BandwidthPackageId": { "title": "带宽包ID", "description": "公网类型实例关联的共享带宽包ID。", "type": "string", "example": "cbwp-bp1vevu8h3ieh****" }, "CreateTime": { "title": "资源创建时间", "description": "资源创建时间,使用格林威治时间,格式为`yyyy-MM-ddTHH:mm:ssZ`。", "type": "string", "example": "2022-07-02T02:49:05Z" }, "DNSName": { "title": "DNS域名", "description": "DNS域名。", "type": "string", "example": "alb-95qnr2itwu9orb****.cn-hangzhou.alb.aliyuncs.com" }, "DeletionProtectionConfig": { "title": "负载均衡删除保护相关信息", "description": "删除保护配置。", "type": "object", "properties": { "Enabled": { "title": "删除保护状态", "description": "删除保护状态,取值:\n\n- **true**:开启状态。\n\n- **false**:关闭状态。", "type": "boolean", "example": "true" }, "EnabledTime": { "title": "删除保护开启时间", "description": "删除保护开启时间,使用格林威治时间,格式为`yyyy-MM-ddTHH:mm:ssZ`。", "type": "string", "example": "2022-08-02T02:49:05Z" } } }, "LoadBalancerBillingConfig": { "title": "计费相关属性", "description": "应用型负载均衡实例计费配置。", "type": "object", "properties": { "PayType": { "title": "实例的计费类型", "description": "计费类型。\n\n取值: **PostPay**表示按量计费。", "type": "string", "example": "PostPay", "default": "PostPay" } } }, "LoadBalancerBussinessStatus": { "title": "实例业务状态", "description": "应用型负载均衡的业务状态。取值:\n\n- **Abnormal**:异常状态。\n\n- **Normal**:正常状态。", "type": "string", "example": "Normal" }, "LoadBalancerEdition": { "title": "负载均衡的版本", "description": "应用型负载均衡的版本,不同版本有不同功能限制和计费策略。取值:\n\n- **Basic**:基础版。\n\n- **Standard**:标准版。\n\n- **StandardWithWaf**:WAF增强版。", "type": "string", "example": "Standard" }, "LoadBalancerId": { "title": "负载均衡标识", "description": "应用型负载均衡实例ID。", "type": "string", "example": "alb-o9ulmq5hgn68jk****" }, "LoadBalancerName": { "title": "实例名称", "description": "实例名称。\n\n长度为2~128个英文或中文字符,必须以字母或中文开头,可包含数字、半角句号(.)、下划线(_)和短划线(-)。", "type": "string", "example": "alb1" }, "LoadBalancerOperationLocks": { "title": "锁定原因", "description": "应用型负载均衡操作锁配置。", "type": "array", "items": { "description": "应用型负载均衡操作锁配置。", "type": "object", "properties": { "LockReason": { "title": "锁定原因", "description": "锁定的原因。在**LoadBalancerBussinessStatus**为**异常**时有效。", "type": "string", "example": "欠费" }, "LockType": { "title": "锁定类型", "description": "锁定的类型。取值 :\n\n- **SecurityLocked**:安全锁定。\n\n- **RelatedResourceLocked**:关联锁定。\n\n- **FinancialLocked**:欠费锁定。\n\n- **ResidualLocked**:残留锁定。", "type": "string", "example": "FinancialLocked" } } } }, "LoadBalancerStatus": { "title": "实例状态", "description": "应用型负载均衡实例状态。取值:\n\n- **Inactive**: 已停止,表示实例监听不会再转发流量。\n\n- **Active**: 运行中。\n\n- **Provisioning**:创建中。\n\n- **Configuring**:变配中。\n\n- **CreateFailed**:创建失败,此时不会产生费用,实例只能被删除。", "type": "string", "example": "Active" }, "ModificationProtectionConfig": { "title": "负载均衡修改保护相关信息", "description": "修改保护配置。", "type": "object", "properties": { "Reason": { "title": "设置修改保护状态的原因", "description": "开启修改保护的原因。\n\n长度为2~128个英文或中文字符,必须以大小字母或中文开头,可包含数字、半角句号(.)、下划线(_)和短划线(-)。\n\n仅在**Status**为**ConsoleProtection**时返回。", "type": "string", "example": "托管实例" }, "Status": { "title": "负载均衡修改保护状态", "description": "应用型负载均衡实例的修改保护状态。取值:\n\n- **NonProtection**:未开启修改保护。如有配置**Reason**,**Reason**会被强制置空。\n\n- **ConsoleProtection**:已开启控制台修改保护。如有配置**Reason**,**Reason**可生效。\n\n> 当取值为**ConsoleProtection**,即开启修改保护后,用户不能通过负载均衡控制台修改实例配置,但可以通过调用API修改实例配置。", "type": "string", "example": "ConsoleProtection" } } }, "RegionId": { "title": "地域", "description": "应用型负载均衡实例的地域ID。", "type": "string", "example": "cn-hangzhou" }, "RequestId": { "title": "Id of the request", "description": "请求ID。", "type": "string", "example": "365F4154-92F6-4AE4-92F8-7FF34B540710" }, "ResourceGroupId": { "title": "企业资源组ID", "description": "企业资源组ID。", "type": "string", "example": "rg-atstuj3rtop****" }, "Tags": { "title": "标签列表", "description": "标签。", "type": "array", "items": { "description": "标签。", "type": "object", "properties": { "Key": { "title": "实例的标签键", "description": "实例的标签键。\n\n最多支持128个字符,不能以`aliyun`或`acs:`开头,不能包含`http://`或`https://`。", "type": "string", "example": "FinanceDept" }, "Value": { "title": "实例的标签值", "description": "实例的标签值。\n\n最多支持128个字符,不能以`aliyun`或`acs:`开头,不能包含`http://`或`https://`。", "type": "string", "example": "FinanceJoshua" } } } }, "VpcId": { "title": "Vpc网络ID", "description": "实例的专有网络ID。", "type": "string", "example": "vpc-bp1b49rqrybk45nio****" }, "ZoneMappings": { "title": "负载均衡的可用区资源", "description": "可用区及交换机映射列表,最多返回10个可用区。若当前地域支持2个及以上可用区,至少返回2个及以上可用区。", "type": "array", "items": { "description": "可用区及交换机映射列表,最多返回10个可用区。若当前地域支持2个及以上可用区,至少返回2个及以上可用区。", "type": "object", "properties": { "LoadBalancerAddresses": { "title": "固定VIP模式下,负载均衡在此可用区中的地址列表", "description": "实例地址。", "type": "array", "items": { "description": "实例地址。", "type": "object", "properties": { "Address": { "title": "IP地址", "description": "标识IPv4类型的IP地址。\n\n**AddressIPVersion**为**IPv4**和**DualStack**均生效,公网或私网IP地址由**AddressType**决定。", "type": "string", "example": "10.1.0.61" }, "Ipv6Address": { "title": "Ipv6地址", "description": "标识IPv6类型的IP地址。\n\n仅在**AddressIPVersion**为**DualStack**时有效,公网或私网IP地址由**Ipv6AddressType**决定。", "type": "string", "example": "2408:xxxx:249:dd01:6f4:750f:xxxx:bcd9" }, "IntranetAddress": { "title": "私网地址", "description": "IPv4私网地址。", "type": "string", "example": "10.1.0.61" }, "AllocationId": { "description": "弹性公网IP标识。", "type": "string", "example": "eip-uf6wm****1zj9" }, "EipType": { "description": "公网EIP的类型。取值:\n\n- **Common**:弹性公网IP,简称EIP。\n- **Anycast**:任播弹性公网IP,简称Anycast EIP。\n\n> ALB支持绑定Anycast EIP的地域,请参见[使用限制](~~460727~~)。", "type": "string", "example": "Common" }, "IntranetAddressHcStatus": { "description": "应用型负载均衡实例私网IPv4地址探测状态。\n\n只有可用区的状态为Active时才返回。取值:\n\n- **Healthy**:健康。\n- **Unhealthy**:异常。", "type": "string", "example": "Healthy" }, "Ipv6AddressHcStatus": { "description": "应用型负载均衡实例IPv6地址探测状态。\n\n只有可用区的状态为Active时才返回。取值:\n\n- **Healthy**:健康。\n- **Unhealthy**:异常。", "type": "string", "example": "Healthy" }, "Ipv4LocalAddresses": { "description": "IPv4 Local地址列表。ALB与后端服务交互使用的地址列表。", "type": "array", "items": { "description": "IPv4 Local地址。", "type": "string", "example": "10.1.0.62" } }, "Ipv6LocalAddresses": { "description": "IPv6 Local地址列表。ALB与后端服务交互使用的地址列表。", "type": "array", "items": { "description": " IPv6 Local地址。", "type": "string", "example": "2408:xxxx:249:dd01:6f4:750f:xxxx:bcda" } } } } }, "VSwitchId": { "title": "交换机标识", "description": "可用区对应的交换机,每个可用区只能使用一台交换机和一个子网。", "type": "string", "example": "vsw-bp12mw1f8k3jgy****" }, "ZoneId": { "title": "可用区标识", "description": "应用型负载均衡实例的可用区ID。\n\n您可以通过调用[DescribeZones](~~189196~~)接口获取可用区ID对应的可用区的信息。", "type": "string", "example": "cn-hangzhou-a" }, "Status": { "description": "可用区状态。取值:\n\n- **Active**:运行中。\n- **Stopped**:已停止。\n- **Shifted**:已移除。\n- **Starting**:启动中。\n- **Stopping**:停止中。", "type": "string", "example": "Active" } } } }, "AddressIpVersion": { "title": "协议版本", "description": "协议版本。取值:\n\n- **IPv4**:IPv4类型\n- **DualStack**:双栈类型", "type": "string", "example": "DualStack" }, "Ipv6AddressType": { "title": "IPV6地址类型", "description": "应用型负载均衡IPv6的网络地址类型。取值:\n\n- **Internet**:公网。负载均衡具有公网IP地址,DNS域名被解析到公网IP,因此可以在公网环境访问。\n- **Intranet**:私网。负载均衡只有私网IP地址,DNS域名被解析到私网IP,因此只能被负载均衡所在VPC的内网环境访问。", "type": "string", "example": "Intranet" }, "SecurityGroupIds": { "description": "应用型负载均衡实例绑定的安全组ID集合。", "type": "array", "items": { "description": "应用型负载均衡实例绑定的安全组ID。", "type": "string", "example": "sg-uf63j385dzwlm6cy****" } } } } } }, "errorCodes": { "400": [ { "errorCode": "Forbidden.LoadBalancer", "errorMessage": "Authentication has failed for LoadBalancer." } ], "404": [ { "errorCode": "ResourceNotFound.LoadBalancer", "errorMessage": "The specified resource %s is not found." } ] }, "responseDemo": "[{\"type\":\"json\",\"example\":\"{\\n \\\"AccessLogConfig\\\": {\\n \\\"LogProject\\\": \\\"sls-setter\\\",\\n \\\"LogStore\\\": \\\"test\\\"\\n },\\n \\\"AddressAllocatedMode\\\": \\\"Dynamic\\\",\\n \\\"AddressType\\\": \\\"Intranet\\\",\\n \\\"BandwidthPackageId\\\": \\\"cbwp-bp1vevu8h3ieh****\\\",\\n \\\"CreateTime\\\": \\\"2022-07-02T02:49:05Z\\\",\\n \\\"DNSName\\\": \\\"alb-95qnr2itwu9orb****.cn-hangzhou.alb.aliyuncs.com\\\",\\n \\\"DeletionProtectionConfig\\\": {\\n \\\"Enabled\\\": true,\\n \\\"EnabledTime\\\": \\\"2022-08-02T02:49:05Z\\\"\\n },\\n \\\"LoadBalancerBillingConfig\\\": {\\n \\\"PayType\\\": \\\"PostPay\\\"\\n },\\n \\\"LoadBalancerBussinessStatus\\\": \\\"Normal\\\",\\n \\\"LoadBalancerEdition\\\": \\\"Standard\\\",\\n \\\"LoadBalancerId\\\": \\\"alb-o9ulmq5hgn68jk****\\\",\\n \\\"LoadBalancerName\\\": \\\"alb1\\\",\\n \\\"LoadBalancerOperationLocks\\\": [\\n {\\n \\\"LockReason\\\": \\\"欠费\\\",\\n \\\"LockType\\\": \\\"FinancialLocked\\\"\\n }\\n ],\\n \\\"LoadBalancerStatus\\\": \\\"Active\\\",\\n \\\"ModificationProtectionConfig\\\": {\\n \\\"Reason\\\": \\\"托管实例\\\",\\n \\\"Status\\\": \\\"ConsoleProtection\\\"\\n },\\n \\\"RegionId\\\": \\\"cn-hangzhou\\\",\\n \\\"RequestId\\\": \\\"365F4154-92F6-4AE4-92F8-7FF34B540710\\\",\\n \\\"ResourceGroupId\\\": \\\"rg-atstuj3rtop****\\\",\\n \\\"Tags\\\": [\\n {\\n \\\"Key\\\": \\\"FinanceDept\\\",\\n \\\"Value\\\": \\\"FinanceJoshua\\\"\\n }\\n ],\\n \\\"VpcId\\\": \\\"vpc-bp1b49rqrybk45nio****\\\",\\n \\\"ZoneMappings\\\": [\\n {\\n \\\"LoadBalancerAddresses\\\": [\\n {\\n \\\"Address\\\": \\\"10.1.0.61\\\",\\n \\\"Ipv6Address\\\": \\\"2408:xxxx:249:dd01:6f4:750f:xxxx:bcd9\\\",\\n \\\"IntranetAddress\\\": \\\"10.1.0.61\\\",\\n \\\"AllocationId\\\": \\\"eip-uf6wm****1zj9\\\",\\n \\\"EipType\\\": \\\"Common\\\",\\n \\\"IntranetAddressHcStatus\\\": \\\"Healthy\\\",\\n \\\"Ipv6AddressHcStatus\\\": \\\"Healthy\\\",\\n \\\"Ipv4LocalAddresses\\\": [\\n \\\"10.1.0.62\\\"\\n ],\\n \\\"Ipv6LocalAddresses\\\": [\\n \\\"2408:xxxx:249:dd01:6f4:750f:xxxx:bcda\\\"\\n ]\\n }\\n ],\\n \\\"VSwitchId\\\": \\\"vsw-bp12mw1f8k3jgy****\\\",\\n \\\"ZoneId\\\": \\\"cn-hangzhou-a\\\",\\n \\\"Status\\\": \\\"Active\\\"\\n }\\n ],\\n \\\"AddressIpVersion\\\": \\\"DualStack\\\",\\n \\\"Ipv6AddressType\\\": \\\"Intranet\\\",\\n \\\"SecurityGroupIds\\\": [\\n \\\"sg-uf63j385dzwlm6cy****\\\"\\n ]\\n}\",\"errorExample\":\"\"},{\"type\":\"xml\",\"example\":\"<GetLoadBalancerAttributeResponse>\\n <AccessLogConfig>\\n <LogProject>sls-setter</LogProject>\\n <LogStore>test</LogStore>\\n </AccessLogConfig>\\n <AddressAllocatedMode>Dynamic</AddressAllocatedMode>\\n <AddressType>Intranet</AddressType>\\n <BandwidthPackageId>cbwp-bp1vevu8h3ieh****</BandwidthPackageId>\\n <CreateTime>2022-07-02T02:49:05Z</CreateTime>\\n <DNSName>alb-95qnr2itwu9orb****.cn-hangzhou.alb.aliyuncs.com</DNSName>\\n <DeletionProtectionConfig>\\n <Enabled>true</Enabled>\\n <EnabledTime>2022-08-02T02:49:05Z</EnabledTime>\\n </DeletionProtectionConfig>\\n <LoadBalancerBillingConfig>\\n <PayType>PostPay</PayType>\\n </LoadBalancerBillingConfig>\\n <LoadBalancerBussinessStatus>Normal</LoadBalancerBussinessStatus>\\n <LoadBalancerEdition>Standard</LoadBalancerEdition>\\n <LoadBalancerId>alb-o9ulmq5hgn68jk****</LoadBalancerId>\\n <LoadBalancerName>alb1</LoadBalancerName>\\n <LoadBalancerOperationLocks>\\n <LockReason>欠费</LockReason>\\n <LockType>FinancialLocked</LockType>\\n </LoadBalancerOperationLocks>\\n <LoadBalancerStatus>Active</LoadBalancerStatus>\\n <ModificationProtectionConfig>\\n <Reason>托管实例</Reason>\\n <Status>ConsoleProtection</Status>\\n </ModificationProtectionConfig>\\n <RegionId>cn-hangzhou</RegionId>\\n <RequestId>365F4154-92F6-4AE4-92F8-7FF34B540710</RequestId>\\n <ResourceGroupId>rg-atstuj3rtop****</ResourceGroupId>\\n <Tags>\\n <Key>FinanceDept</Key>\\n <Value>FinanceJoshua</Value>\\n </Tags>\\n <VpcId>vpc-bp1b49rqrybk45nio****</VpcId>\\n <ZoneMappings>\\n <LoadBalancerAddresses>\\n <Address>192.168.10.1</Address>\\n <Ipv6Address>2408:XXXX:39d:eb00::/56</Ipv6Address>\\n </LoadBalancerAddresses>\\n <VSwitchId>vsw-bp12mw1f8k3jgy****</VSwitchId>\\n <ZoneId>cn-hangzhou-a</ZoneId>\\n </ZoneMappings>\\n <AddressIpVersion>DualStack</AddressIpVersion>\\n <Ipv6AddressType>Intranet</Ipv6AddressType>\\n</GetLoadBalancerAttributeResponse>\",\"errorExample\":\"\"}]", "title": "查询负载均衡实例的详细信息" }, "ListLoadBalancers": { "summary": "查询实例配置", "methods": [ "get", "post" ], "schemes": [ "http", "https" ], "security": [ { "AK": [] } ], "operationType": "read", "deprecated": false, "systemTags": { "operationType": "get", "riskType": "none", "chargeType": "free", "abilityTreeNodes": [ "FEATUREslb6TP8T4" ] }, "parameters": [ { "name": "NextToken", "in": "query", "schema": { "title": "用来标记当前开始读取的位置,置空表示从头开始。", "description": "是否拥有下一次查询的令牌(Token)。取值:\n- 第一次查询和没有下一次查询时,均无需填写。\n- 如果有下一次查询,取值为上一次API调用返回的**NextToken**值。", "type": "string", "required": false, "example": "FFmyTO70tTpLG6I3FmYAXGKPd****" } }, { "name": "MaxResults", "in": "query", "schema": { "title": "本次读取的最大数据记录数量,此参数为可选参数,取值1-100,用户传入为空时,默认为20。", "description": "分批次查询时每次显示的条目数。取值范围:**1**~**100**,默认值:**20**。\n\n", "type": "integer", "format": "int32", "required": false, "example": "20" } }, { "name": "ZoneId", "in": "query", "schema": { "title": "可用区ID", "description": "应用型负载均衡实例所在的可用区ID。\n\n您可以通过调用[DescribeZones](~~189196~~)接口获取可用区ID对应的可用区信息。", "type": "string", "required": false, "example": "cn-hangzhou-a" } }, { "name": "LoadBalancerStatus", "in": "query", "schema": { "title": "实例状态", "description": "应用型负载均衡实例状态。取值:\n\n- **Inactive**: 已停止,监听不再转发流量。\n\n- **Active**::运行中。\n\n- **Provisioning**:创建中。\n\n- **Configuring**:变配中。\n\n- **CreateFailed**:创建失败,此时不会产生费用,实例只能被删除。系统默认清理最近1天创建失败的实例。", "type": "string", "required": false, "example": "Active" } }, { "name": "LoadBalancerBussinessStatus", "in": "query", "schema": { "title": "实例业务状态", "description": "应用型负载均衡的业务状态。取值:\n\n- **Abnormal**:异常。\n\n- **Normal**:正常。", "type": "string", "required": false, "example": "Normal" } }, { "name": "LoadBalancerIds", "in": "query", "style": "flat", "schema": { "title": "实例ID列表,N最大支持20", "description": "实例ID列表。最多支持20个应用型负载均衡实例ID。", "type": "array", "items": { "description": "实例的ID。", "type": "string", "required": false, "example": "alb-o9ulmq5hgn68jk****" }, "required": false, "maxItems": 21, "minItems": 1 } }, { "name": "LoadBalancerNames", "in": "query", "style": "flat", "schema": { "title": "实例Name列表,N最大支持10", "description": "实例名称列表。最多支持10个实例名称。", "type": "array", "items": { "description": "实例名称。\n\n长度为2~128个英文或中文字符,必须以大小写英文字母或中文开头,可包含数字、半角句号(.)、下划线(_)和短划线(-)。", "type": "string", "required": false, "example": "alb-instance-test" }, "required": false, "maxItems": 11, "minItems": 1 } }, { "name": "VpcIds", "in": "query", "style": "flat", "schema": { "title": "vpcId列表", "description": "应用型负载均衡实例所属的VPC ID。最多支持10个VPC ID。", "type": "array", "items": { "description": "应用型负载均衡实例所属的VPC ID。", "type": "string", "required": false, "example": "vpc-bp1b49rqrybk45nio****" }, "required": false, "maxItems": 11, "minItems": 1 } }, { "name": "Tag", "in": "query", "style": "flat", "schema": { "title": "tag列表", "description": "实例标签。", "type": "array", "items": { "description": "实例标签结构。", "type": "object", "properties": { "Key": { "title": "实例的标签键", "description": "实例的标签键。最多支持输入20个标签键。一旦输入该值,则不允许为空字符串。\n\n最多支持64个字符,不能以`aliyun`和`acs:`开头,不能包含`http://`或者`https://`。", "type": "string", "required": false, "example": "KeyTest" }, "Value": { "title": "实例的标签值", "description": "实例的标签值。最多支持输入20个标签值。一旦输入该值,可以为空字符串。\n\n最多支持128个字符,不能以`aliyun`和`acs:`开头,不能包含`http://`或者`https://`。", "type": "string", "required": false, "example": "alueTest" } }, "required": false }, "required": false, "maxItems": 21, "minItems": 1 } }, { "name": "AddressType", "in": "query", "schema": { "title": "负载均衡的地址类型", "description": "实例地址类型。取值:\n\n- **Internet**:负载均衡具有公网IP地址,DNS域名被解析到公网IP,因此可以在公网环境访问。\n\n- **Intranet**:负载均衡只有私网IP地址,DNS域名被解析到私网IP,因此只能被负载均衡所在VPC的内网环境访问。", "type": "string", "required": false, "example": "Intranet" } }, { "name": "PayType", "in": "query", "schema": { "title": "付费类型", "description": "实例的计费类型。取值:\n\n**PostPay**(默认值):表示按量计费。", "type": "string", "required": false, "example": "PostPay" } }, { "name": "ResourceGroupId", "in": "query", "schema": { "title": "资源组ID", "description": "企业资源组ID。", "type": "string", "required": false, "example": "rg-acfmxazb4ph****" } }, { "name": "AddressIpVersion", "in": "query", "schema": { "title": "需要过滤的协议版本", "description": "协议版本。取值:\n\n- **IPv4**:IPv4类型。\n- **DualStack**:双栈类型。", "type": "string", "required": false, "example": "IPv4" } }, { "name": "Ipv6AddressType", "in": "query", "schema": { "title": "IPV6的地址网络类型", "description": "应用型负载均衡的IPv6地址类型。取值:\n\n- **Internet**:负载均衡具有公网IP地址,DNS域名被解析到公网IP,因此可以在公网环境访问。\n\n- **Intranet**:负载均衡只有私网IP地址,DNS域名被解析到私网IP,因此只能被负载均衡所在VPC的内网环境访问。", "type": "string", "required": false, "example": "Intranet" } }, { "name": "DNSName", "in": "query", "schema": { "description": "DNS域名。", "type": "string", "required": false, "example": "alb-95qnr2itwu9orb****.cn-hangzhou.alb.aliyuncs.com" } } ], "responses": { "200": { "schema": { "title": "Schema of Response", "description": "应用型负载均衡实例配置信息。", "type": "object", "properties": { "LoadBalancers": { "title": "实例列表", "description": "应用型负载均衡实例列表。", "type": "array", "items": { "description": "应用型负载均衡实例结构。", "type": "object", "properties": { "AccessLogConfig": { "title": "访问日志属性", "description": "访问日志配置结构。", "type": "object", "properties": { "LogProject": { "title": "访问日志投递的logProject", "description": "日志项目。", "type": "string", "example": "sls-setter" }, "LogStore": { "title": "删除保护开启时间", "description": "日志存储。", "type": "string", "example": "test" } } }, "AddressAllocatedMode": { "title": "地址模式", "description": "地址模式。取值 :\n\n- **Fixed**:固定IP模式,表示使用固定IP地址。\n\n- **Dynamic**:动态IP模式,表示每个可用区动态分配IP地址。", "type": "string", "example": "Fixed" }, "AddressType": { "title": "地址类型", "description": "负载均衡的地址类型。取值:\n\n- **Internet**:负载均衡具有公网IP地址,DNS域名被解析到公网IP,因此可以在公网环境访问。\n\n- **Intranet**:负载均衡只有私网IP地址,DNS域名被解析到私网IP,因此只能被负载均衡所在VPC的内网环境访问。", "type": "string", "example": "Intranet" }, "BandwidthPackageId": { "title": "带宽包ID", "description": "公网类型实例关联的共享带宽包ID。", "type": "string", "example": "cbwp-bp1vevu8h3ieh****" }, "CreateTime": { "title": "资源创建时间", "description": "资源创建时间。", "type": "string", "example": "2022-07-02T02:49:05Z" }, "DNSName": { "title": "DNS域名", "description": "DNS域名。", "type": "string", "example": "alb-95qnr2itwu9orb****.cn-hangzhou.alb.aliyuncs.com" }, "DeletionProtectionConfig": { "title": "负载均衡删除保护相关信息", "description": "删除保护配置。", "type": "object", "properties": { "Enabled": { "title": "删除保护状态", "description": "删除保护状态,取值:\n\n- **true**:开启。\n\n- **false**:关闭。", "type": "boolean", "example": "true" }, "EnabledTime": { "title": "删除保护开启时间", "description": "开启删除保护时间。", "type": "string", "example": "2022-08-02T02:49:05Z" } } }, "LoadBalancerBillingConfig": { "title": "计费相关属性", "description": "负载均衡实例计费配置。", "type": "object", "properties": { "PayType": { "title": "实例的计费类型", "description": "计费类型。取值:\n\n**PostPay**:按量计费。", "type": "string", "example": "PostPay", "default": "PostPay" } } }, "LoadBalancerBussinessStatus": { "title": "实例业务状态", "description": "负载均衡的业务状态。取值:\n\n- **Abnormal**:异常。\n\n- **Normal**:正常。", "type": "string", "example": "Normal" }, "LoadBalancerEdition": { "title": "负载均衡的版本", "description": "负载均衡的版本,不同版本有不同功能限制和计费策略。取值:\n\n- **Basic**:基础版。\n\n- **Standard**:标准版。\n\n- **StandardWithWaf**:WAF增强版。\n\n", "type": "string", "example": "Standard" }, "LoadBalancerId": { "title": "负载均衡标识", "description": "应用型负载均衡实例ID。", "type": "string", "example": "alb-o9ulmq5hgn68jk****" }, "LoadBalancerName": { "title": "实例名称", "description": "负载均衡实例名称。", "type": "string", "example": "alb-instance-test" }, "LoadBalancerOperationLocks": { "title": "锁定的原因", "description": "负载均衡操作锁配置。", "type": "array", "items": { "description": "负载均衡操作锁结构。", "type": "object", "properties": { "LockReason": { "title": "锁定的原因", "description": "锁定的原因。在**LoadBalancerBussinessStatus**为**异常**时有效。", "type": "string" }, "LockType": { "title": "锁定的类型", "description": "锁定的类型。取值 :\n\n- **SecurityLocked**:安全锁定。\n\n- **RelatedResourceLocked**:关联锁定。\n\n- **FinancialLocked**:欠费锁定。\n\n- **ResidualLocked**:残留锁定。", "type": "string", "example": "FinancialLocked" } } } }, "LoadBalancerStatus": { "title": "实例状态", "description": "应用型负载均衡实例状态。取值:\n\n- **Inactive**: 已停止,表示实例监听不会再转发流量。\n\n- **Active**: 运行中。\n\n- **Provisioning**:创建中。\n\n- **Configuring**:变配中。\n\n- **CreateFailed**:创建失败。", "type": "string", "example": "Active" }, "ModificationProtectionConfig": { "title": "负载均衡修改保护相关信息", "description": "修改保护配置。", "type": "object", "properties": { "Reason": { "title": "设置修改保护状态的原因", "description": "开启修改保护的原因。\n\n长度为2~128个英文或中文字符,必须以大小写英文字母或中文开头,可包含数字、半角句号(.)、下划线(_)和短划线(-)。\n\n仅在**Status**为**ConsoleProtection**时返回。", "type": "string", "example": "Managed Instance" }, "Status": { "title": "负载均衡修改保护状态", "description": "应用型负载均衡实例的修改保护状态。取值:\n\n- **NonProtection**:未开启修改保护。如有配置**Reason**,**Reason**会被强制置空。\n\n- **ConsoleProtection**:已开启控制台修改保护。如有配置**Reason**,**Reason**可生效。\n\n> 当取值为**ConsoleProtection**,即开启修改保护后,用户不能通过负载均衡控制台修改实例配置,但可以通过调用API修改实例配置。", "type": "string", "example": "ConsoleProtection" } } }, "ResourceGroupId": { "title": "企业资源组ID", "description": "企业资源组ID。", "type": "string", "example": "rg-atstuj3rtop****" }, "Tags": { "title": "标签列表", "description": "标签列表。", "type": "array", "items": { "description": "标签结构。", "type": "object", "properties": { "Key": { "title": "实例的标签键", "description": "实例的标签键。", "type": "string", "example": "KeyTest" }, "Value": { "title": "实例的标签值", "description": "实例的标签值。", "type": "string", "example": "alueTest" } } } }, "VpcId": { "title": "Vpc网络ID", "description": "应用型负载均衡实例的专有网络ID。", "type": "string", "example": "vpc-bp1b49rqryhk45nio****" }, "AddressIpVersion": { "title": "协议版本", "description": "协议版本。取值:\n\n- **IPv4**:IPv4类型。\n\n- **DualStack**:双栈类型。", "type": "string", "example": "DualStack" }, "Ipv6AddressType": { "title": "IPV6地址类型", "description": "应用型负载均衡IPv6的网络地址类型。取值:\n\n- **Internet**:公网。负载均衡具有公网IP地址,DNS域名被解析到公网IP,因此可以在公网环境访问。\n\n- **Intranet**:私网。负载均衡只有私网IP地址,DNS域名被解析到私网IP,因此只能被负载均衡所在VPC的内网环境访问。", "type": "string", "example": "Intranet" }, "SecurityGroupIds": { "description": "应用型负载均衡实例加入的安全组。", "type": "array", "items": { "description": "应用型负载均衡实例加入的安全组。", "type": "string", "example": "sg-2zejdtxxpu8c9tny****" } } } } }, "MaxResults": { "title": "本次请求所返回的最大记录条数。", "description": "分批次查询时每次显示的条目数。\n\n", "type": "integer", "format": "int32", "example": "20" }, "NextToken": { "title": "用来表示当前调用返回读取到的位置,空代表数据已经读取完毕。", "description": "是否拥有下一次查询的令牌(Token)。取值:\n- 如果**NextToken**为空表示没有下一次查询。\n- 如果**NextToken**有返回值,该取值表示下一次查询开始的令牌。", "type": "string", "example": "FFmyTO70tTpLG6I3FmYAXGKPd****" }, "RequestId": { "title": "Id of the request", "description": "请求ID。", "type": "string", "example": "365F4154-92F6-4AE4-92F8-7FF34B540710" }, "TotalCount": { "title": "本次请求条件下的数据总量。", "description": "列表条目数。", "type": "integer", "format": "int32", "example": "100" } } } } }, "responseDemo": "[{\"type\":\"json\",\"example\":\"{\\n \\\"LoadBalancers\\\": [\\n {\\n \\\"AccessLogConfig\\\": {\\n \\\"LogProject\\\": \\\"sls-setter\\\",\\n \\\"LogStore\\\": \\\"test\\\"\\n },\\n \\\"AddressAllocatedMode\\\": \\\"Fixed\\\",\\n \\\"AddressType\\\": \\\"Intranet\\\",\\n \\\"BandwidthPackageId\\\": \\\"cbwp-bp1vevu8h3ieh****\\\",\\n \\\"CreateTime\\\": \\\"2022-07-02T02:49:05Z\\\",\\n \\\"DNSName\\\": \\\"alb-95qnr2itwu9orb****.cn-hangzhou.alb.aliyuncs.com\\\",\\n \\\"DeletionProtectionConfig\\\": {\\n \\\"Enabled\\\": true,\\n \\\"EnabledTime\\\": \\\"2022-08-02T02:49:05Z\\\"\\n },\\n \\\"LoadBalancerBillingConfig\\\": {\\n \\\"PayType\\\": \\\"PostPay\\\"\\n },\\n \\\"LoadBalancerBussinessStatus\\\": \\\"Normal\\\",\\n \\\"LoadBalancerEdition\\\": \\\"Standard\\\",\\n \\\"LoadBalancerId\\\": \\\"alb-o9ulmq5hgn68jk****\\\",\\n \\\"LoadBalancerName\\\": \\\"alb-instance-test\\\",\\n \\\"LoadBalancerOperationLocks\\\": [\\n {\\n \\\"LockReason\\\": \\\"\\\",\\n \\\"LockType\\\": \\\"FinancialLocked\\\"\\n }\\n ],\\n \\\"LoadBalancerStatus\\\": \\\"Active\\\",\\n \\\"ModificationProtectionConfig\\\": {\\n \\\"Reason\\\": \\\"Managed Instance\\\",\\n \\\"Status\\\": \\\"ConsoleProtection\\\"\\n },\\n \\\"ResourceGroupId\\\": \\\"rg-atstuj3rtop****\\\",\\n \\\"Tags\\\": [\\n {\\n \\\"Key\\\": \\\"KeyTest\\\",\\n \\\"Value\\\": \\\"alueTest\\\"\\n }\\n ],\\n \\\"VpcId\\\": \\\"vpc-bp1b49rqryhk45nio****\\\",\\n \\\"AddressIpVersion\\\": \\\"DualStack\\\",\\n \\\"Ipv6AddressType\\\": \\\"Intranet\\\",\\n \\\"SecurityGroupIds\\\": [\\n \\\"sg-2zejdtxxpu8c9tny****\\\"\\n ]\\n }\\n ],\\n \\\"MaxResults\\\": 20,\\n \\\"NextToken\\\": \\\"FFmyTO70tTpLG6I3FmYAXGKPd****\\\",\\n \\\"RequestId\\\": \\\"365F4154-92F6-4AE4-92F8-7FF34B540710\\\",\\n \\\"TotalCount\\\": 100\\n}\",\"errorExample\":\"\"},{\"type\":\"xml\",\"example\":\"<ListLoadBalancersResponse>\\n <LoadBalancers>\\n <AccessLogConfig>\\n <LogProject>sls-setter</LogProject>\\n <LogStore>test</LogStore>\\n </AccessLogConfig>\\n <AddressAllocatedMode>Fixed</AddressAllocatedMode>\\n <AddressType>Intranet</AddressType>\\n <BandwidthPackageId>cbwp-bp1vevu8h3ieh****</BandwidthPackageId>\\n <CreateTime>2022-07-02T02:49:05Z</CreateTime>\\n <DNSName>alb-95qnr2itwu9orb****.cn-hangzhou.alb.aliyuncs.com</DNSName>\\n <DeletionProtectionConfig>\\n <Enabled>true</Enabled>\\n <EnabledTime>2022-08-02T02:49:05Z</EnabledTime>\\n </DeletionProtectionConfig>\\n <LoadBalancerBillingConfig>\\n <PayType>PostPay</PayType>\\n </LoadBalancerBillingConfig>\\n <LoadBalancerBussinessStatus>Normal</LoadBalancerBussinessStatus>\\n <LoadBalancerEdition>Standard</LoadBalancerEdition>\\n <LoadBalancerId>alb-o9ulmq5hgn68jk****</LoadBalancerId>\\n <LoadBalancerName>alb-instance-test</LoadBalancerName>\\n <LoadBalancerOperationLocks>\\n <LockReason>欠费</LockReason>\\n <LockType>FinancialLocked</LockType>\\n </LoadBalancerOperationLocks>\\n <LoadBalancerStatus>Active</LoadBalancerStatus>\\n <ModificationProtectionConfig>\\n <Reason>托管实例</Reason>\\n <Status>ConsoleProtection</Status>\\n </ModificationProtectionConfig>\\n <ResourceGroupId>rg-atstuj3rtop****</ResourceGroupId>\\n <Tags>\\n <Key>KeyTest</Key>\\n <Value>alueTest</Value>\\n </Tags>\\n <VpcId>vpc-bp1b49rqrybk45nio****</VpcId>\\n <AddressIpVersion>DualStack</AddressIpVersion>\\n <Ipv6AddressType>Intranet</Ipv6AddressType>\\n </LoadBalancers>\\n <MaxResults>20</MaxResults>\\n <NextToken>FFmyTO70tTpLG6I3FmYAXGKPd****</NextToken>\\n <RequestId>365F4154-92F6-4AE4-92F8-7FF34B540710</RequestId>\\n <TotalCount>100</TotalCount>\\n</ListLoadBalancersResponse>\",\"errorExample\":\"\"}]", "title": "查询负载均衡" }, "ListListeners": { "summary": "查询指定地域的监听。", "methods": [ "get", "post" ], "schemes": [ "http", "https" ], "security": [ { "AK": [] } ], "operationType": "read", "deprecated": false, "systemTags": { "operationType": "get", "abilityTreeCode": "190", "abilityTreeNodes": [ "FEATUREslbM7ALO6", "FEATUREslbK3ZR0L", "FEATUREslbN5IE4S" ] }, "parameters": [ { "name": "NextToken", "in": "query", "schema": { "title": "用来标记当前开始读取的位置,置空表示从头开始。", "description": "是否拥有下一次查询的令牌(Token)。取值:\n- 第一次查询和没有下一次查询时,均无需填写。\n- 如果有下一次查询,取值为上一次API调用返回的**NextToken**值。", "type": "string", "required": false, "example": "FFmyTO70tTpLG6I4FmYAXGKPd****" } }, { "name": "MaxResults", "in": "query", "schema": { "title": "本次读取的最大数据记录数量,此参数为可选参数,取值1-100,用户传入为空时,默认为20。", "description": "本次读取的最大数据记录数量,此参数为可选参数。取值范围:**1~100**。入参为空时,默认值为**20**。", "type": "integer", "format": "int32", "required": false, "example": "50" } }, { "name": "ListenerIds", "in": "query", "style": "flat", "schema": { "title": "监听ID列表,N最大支持20", "description": "监听实例ID列表。最多支持20个监听ID。", "type": "array", "items": { "description": "监听实例ID。", "type": "string", "required": false, "example": "lsn-o4u54y73wq7b******" }, "required": false, "maxItems": 20, "minItems": 1 } }, { "name": "LoadBalancerIds", "in": "query", "style": "flat", "schema": { "title": "实例ID列表,N最大支持20", "description": "应用型负载均衡实例ID。最多支持20个实例ID。", "type": "array", "items": { "description": "应用型负载均衡实例ID。", "type": "string", "required": false, "example": "alb-bd6oylbckp6k9x****" }, "required": false, "maxItems": 21, "minItems": 1 } }, { "name": "ListenerProtocol", "in": "query", "schema": { "title": "监听协议", "description": "需要过滤的监听协议。取值:\n\n- **HTTP**:协议类型为HTTP。\n- **HTTPS**:协议类型为HTTPS。\n- **QUIC**:协议类型为QUIC。", "type": "string", "required": false, "example": "HTTP" } }, { "name": "Tag", "in": "query", "style": "flat", "schema": { "description": "标签。", "type": "array", "items": { "description": "标签结构。", "type": "object", "properties": { "Key": { "description": "标签键。最多支持128个字符,不能以aliyun或acs:开头,不能包含http://或https://。", "type": "string", "required": false, "example": "env" }, "Value": { "description": "标签值。最多支持128个字符,不能以aliyun或acs:开头,不能包含http://或https://。", "type": "string", "required": false, "example": "product" } }, "required": false }, "required": false } } ], "responses": { "200": { "schema": { "title": "Schema of Response", "description": "应用型负载均衡监听信息。", "type": "object", "properties": { "Listeners": { "title": "监听列表", "description": "应用型负载均衡监听列表。", "type": "array", "items": { "description": "应用型负载均衡监听结构。", "type": "object", "properties": { "DefaultActions": { "title": "默认动作", "description": "默认规则动作列表。", "type": "array", "items": { "description": "默认规则动作结构。", "type": "object", "properties": { "ForwardGroupConfig": { "title": "转发到服务器组", "description": "转发规则动作对应的配置。动作类型为**ForwardGroup**时有效。", "type": "object", "properties": { "ServerGroupTuples": { "title": "服务器组列表", "description": "转发目标服务器组。", "type": "array", "items": { "description": "转发目标服务器组。", "type": "object", "properties": { "ServerGroupId": { "title": "服务器组ID", "description": "转发到的目的服务器组ID。", "type": "string", "example": "sgp-i5qt20******" } } } } } }, "Type": { "title": "类型", "description": "动作类型。取值:**ForwardGroup**,表示转发至多个服务器组。", "type": "string", "example": "ForwardGroup" } } } }, "GzipEnabled": { "title": "是否开启Gzip压缩", "description": "是否开启Gzip压缩,对特定文件类型进行压缩。取值:\n\n- **true**:是。\n- **false**:否。\n\n", "type": "boolean", "example": "false" }, "Http2Enabled": { "title": "是否开启HTTP/2特性", "description": "是否开启HTTP/2特性。取值:\n\n- **true**:是。\n- **false**:否。\n\n> 仅HTTPS监听支持此参数。", "type": "boolean", "example": "false" }, "IdleTimeout": { "title": "连接空闲超时时间", "description": "指定连接空闲超时时间。单位:秒。取值范围:**1~60**。\n\n如果在超时时间内一直没有访问请求,负载均衡会暂时中断当前连接,直到接收到下一次请求时重新建立新的连接。", "type": "integer", "format": "int32", "example": "3" }, "ListenerDescription": { "title": "监听描述", "description": "自定义监听名称。", "type": "string", "example": "HTTP_80" }, "ListenerId": { "title": "监听标识", "description": "监听ID。", "type": "string", "example": "lsn-o4u34y73wq7b******" }, "ListenerPort": { "title": "监听端口", "description": "应用型负载均衡实例前端使用的端口。取值:**1~65535**。", "type": "integer", "format": "int32", "example": "80" }, "ListenerProtocol": { "title": "监听协议", "description": "监听协议。取值:\n\n- **HTTP**:协议类型为HTTP。\n- **HTTPS**:协议类型为HTTPS。\n- **QUIC**:协议类型为QUIC。", "type": "string", "example": "HTTP" }, "ListenerStatus": { "title": "监听状态", "description": "当前监听的状态,取值:\n\n- **Provisioning**:创建中。\n\n- **Running**:运行中。\n\n- **Configuring**:配置中。\n\n- **Stopped**:已停止。", "type": "string", "example": "Running" }, "LoadBalancerId": { "title": "负载均衡标识", "description": "应用型负载均衡实例ID。", "type": "string", "example": "alb-bd6oylbckp6k9x****" }, "LogConfig": { "title": "监听访问日志相关配置", "description": "日志配置。", "type": "object", "properties": { "AccessLogRecordCustomizedHeadersEnabled": { "title": "访问日志是否开启携带自定义Header", "description": "访问日志是否开启携带自定义头。取值:\n\n- **true**:是。\n- **false**:否。\n", "type": "boolean", "example": "true" }, "AccessLogTracingConfig": { "title": "访问日志Xtrace相关的配置", "description": "访问日志Xtrace相关的配置信息。", "type": "object", "properties": { "TracingEnabled": { "title": "Xtrace功能状态", "description": "是否开启Xtrace功能。取值:\n\n- **true**:是。\n- **false**:否。\n\n> 只有实例访问日志开关**AccessLogEnabled**打开时,才能设置此参数为**true**。", "type": "boolean", "example": "true" }, "TracingSample": { "title": "Xtrace功能状态", "description": "Xtrace的采样率。取值:**1~10000**。\n\n> **TracingEnabled**为**true**时,此值有效。", "type": "integer", "format": "int32", "example": "100" }, "TracingType": { "title": "xtrace的类型", "description": "Xtrace类型,合法取值为**Zipkin**。\n\n> **TracingEnabled**为**true**时,此值有效。", "type": "string", "example": "Zipkin" } } } } }, "QuicConfig": { "title": "HTTPS启用QUIC时相关属性", "description": "启用关联QUIC监听时的配置信息。", "type": "object", "properties": { "QuicListenerId": { "title": "需要关联的QUIC监听ID,HTTPS监听时有效,QuicUpgradeEnabled为true时必选", "description": "需要关联的QUIC监听ID。**QuicUpgradeEnabled**为**true**时必选。HTTPS监听时有效。\n\n> 原始监听和关联的QUIC监听必须属于同一个ALB实例,并且此QUIC监听之前没有被关联过。", "type": "string", "example": "lsn-o4u54y73wq7b******" }, "QuicUpgradeEnabled": { "title": "是否开启quic升级,HTTPS监听时有效", "description": "是否开启QUIC升级。取值:\n\n- **true**:是。\n- **false**:否。\n\n> 仅HTTPS监听时有效。", "type": "boolean", "example": "true" } } }, "RequestTimeout": { "title": "请求超时时间", "description": "指定请求超时时间。单位:秒。取值:**1~180**。\n\n如果在超时时间内后端服务器一直没有响应,负载均衡将放弃等待,给客户端返回`HTTP 504`错误码。", "type": "integer", "format": "int32", "example": "34" }, "SecurityPolicyId": { "title": "安全策略", "description": "安全策略。\n\n> 仅HTTPS监听支持此参数。", "type": "string", "example": "tls_cipher_policy_1_1" }, "XForwardedForConfig": { "title": "XForward字段相关的配置", "description": "`XForward`头字段配置信息。", "type": "object", "properties": { "XForwardedForClientCertClientVerifyAlias": { "title": "自定义HEADER头名称,只有当XForwardedForClientCertClientVerifyEnabled的值为true的时候,此值才会生效;否则该值不会生效。HTTPS监听有效", "description": "自定义头字段名称,只有当**XForwardedForClientCertClientVerifyEnabled**的值为**true**的时候,此值才会生效;否则该值不会生效。\n\n取值限制:长度为1~40字符。支持字母a-z、数字、短划线(-)和下划线(_)。\n\n> 仅HTTPS监听支持此参数。", "type": "string", "example": "test_client-verify-alias_123456" }, "XForwardedForClientCertClientVerifyEnabled": { "title": "是否通过X-Forwarded-Clientcert-clientverify 头字段获取对访问负载均衡实例客户端证书的校验结果。HTTPS监听有效。", "description": "是否通过`X-Forwarded-Clientcert-clientverify`头字段获取对访问负载均衡实例客户端证书的校验结果。取值:\n\n- **true**:是。\n- **false**:否。\n\n> 仅HTTPS监听支持此参数。", "type": "boolean", "example": "true" }, "XForwardedForClientCertFingerprintAlias": { "title": "自定义HEADER头名称,只有当XForwardedForClientCertFingerprintEnabled的值为true的时候,此值才会生效;否则该值不会生效。HTTPS监听有效", "description": "自定义头名称,只有当**XForwardedForClientCertFingerprintEnabled**的值为**true**时生效。\n\n取值限制:长度为1~40字符。支持字母a-z、数字、短划线(-)和下划线(_)。\n\n> 仅HTTPS监听支持此参数。", "type": "string", "example": "test_finger-print-alias_123456" }, "XForwardedForClientCertFingerprintEnabled": { "title": "是否通过X-Forwarded-Clientcert-fingerprint 头字段获取访问负载均衡实例客户端证书的指纹取值,HTTPS监听有效。", "description": "是否通过`X-Forwarded-Clientcert-fingerprint`头字段获取访问负载均衡实例客户端证书的指纹取值。取值:\n\n- **true**:是。\n- **false**:否。\n\n> 仅HTTPS监听支持此参数。", "type": "boolean", "example": "true" }, "XForwardedForClientCertIssuerDNAlias": { "title": "自定义HEADER头名称,只有当XForwardedForClientCertIssuerDNEnabled的值为‘On’的时候,此值才会生效;否则该值不会生效。HTTPS监听有效", "description": "自定义头名称,只有当**XForwardedForClientCertIssuerDNEnabled**的值为**true**的时候,此值才会生效。\n\n取值限制:长度为1~40字符。支持字母a-z、数字、短划线(-)和下划线(_)。\n\n> 仅HTTPS监听支持此参数。", "type": "string", "example": "test_issue-dn-alias_123456" }, "XForwardedForClientCertIssuerDNEnabled": { "title": "是否通过 X-Forwarded-Clientcert-issuerdn 头字段获取访问负载均衡实例客户端证书的发行者信息。HTTPS监听有效。", "description": "是否通过`X-Forwarded-Clientcert-issuerdn`头字段获取访问负载均衡实例客户端证书的发行者信息。取值:\n\n- **true**:是。\n- **false**:否。\n\n> 仅HTTPS监听支持此参数。", "type": "boolean", "example": "true" }, "XForwardedForClientCertSubjectDNAlias": { "title": "自定义HEADER头名称,只有当XForwardedForClientCertSubjectDNEnabled的值为true的时候,此值才会生效;否则该值不会生效。HTTPS监听有效", "description": "自定义头名称,只有当**XForwardedForClientCertSubjectDNEnabled**的值为**true**时,此值才会生效。\n\n取值限制:长度为1~40字符。支持字母a-z、数字、短划线(-)和下划线(_)。\n\n> 仅HTTPS监听支持此参数。", "type": "string", "example": "test_subject-dn-alias_123456" }, "XForwardedForClientCertSubjectDNEnabled": { "title": "是否通过X-Forwarded-Clientcert-subjectdn 头字段获取访问负载均衡实例客户端证书的所有者信息。HTTPS监听有效。", "description": "是否通过`X-Forwarded-Clientcert-subjectdn`头字段获取访问负载均衡实例客户端证书的所有者信息。取值:\n\n- **true**:是。\n- **false**:否。\n\n> 仅HTTPS监听支持此参数。", "type": "boolean", "example": "true" }, "XForwardedForClientSrcPortEnabled": { "title": "是否通过X-Forwarded-Client-Port 头字段获取访问负载均衡实例客户端的端口。HTTPS监听有效。", "description": "是否通过`X-Forwarded-Client-Port`头字段获取访问负载均衡实例客户端的端口。取值:\n\n- **true**:是。\n- **false**:否。\n\n> HTTP和HTTPS监听支持此参数。", "type": "boolean", "example": "true" }, "XForwardedForEnabled": { "title": "是否开启通过X-Forwarded-For头字段获取来访者真实 IP", "description": "是否通过`X-Forwarded-For`头字段获取来访者真实IP。取值:\n- **true**(默认值):是。\n- **false**:否。\n\n> 1. 配置**true**,**XForwardedForProcessingMode**默认取值**append**,支持修改为**remove**。\n> 2. 配置**false**,将请求发送至后端服务之前保留`X-Forwarded-For`头字段,不做额外处理。\n> 3. HTTP和HTTPS监听支持此参数。", "type": "boolean", "example": "true" }, "XForwardedForProcessingMode": { "description": "处理`X-Forwarded-For`头字段的模式。只有当**XForwardedForEnabled**为**true**时,此值才会生效。取值:\n- **append**(默认值):附加。\n- **remove**:删除。\n\n> 1. 配置**append**,将请求发送至后端服务之前把最后一跳IP加入`X-Forwarded-For`头字段。\n> 2. 配置**remove**,将请求发送至后端服务之前删除`X-Forwarded-For`标头,无论请求是否携带`X-Forwarded-For`头字段。\n> 3. HTTP和HTTPS监听支持此参数。", "type": "string", "example": "append" }, "XForwardedForProtoEnabled": { "title": "是否通过X-Forwarded-Proto头字段获取负载均衡实例的监听协议。", "description": "是否通过`X-Forwarded-Proto`头字段获取负载均衡实例的监听协议。取值:\n\n- **true**:是。\n- **false**:否。\n\n> HTTP、HTTPS和QUIC监听支持此参数。", "type": "boolean", "example": "true" }, "XForwardedForSLBIdEnabled": { "title": "是否通过SLB-ID头字段获取负载均衡实例ID。", "description": "是否通过`SLB-ID`头字段获取负载均衡实例ID。取值:\n\n- **true**:是。\n- **false**:否。\n\n> HTTP、HTTPS和QUIC监听支持此参数。", "type": "boolean", "example": "true" }, "XForwardedForSLBPortEnabled": { "title": "是否通过X-Forwarded-Port 头字段获取负载均衡实例的监听端口。HTTPS监听有效。", "description": "是否通过`X-Forwarded-Port`头字段获取负载均衡实例的监听端口。取值:\n\n- **true**:是。\n- **false**:否。\n\n> HTTP、HTTPS和QUIC监听支持此参数。", "type": "boolean", "example": "true" }, "XForwardedForClientSourceIpsEnabled": { "description": "是否允许ALB从X-Forwarded-For头字段中查找真实客户端IP。取值:\n\n- **true**:是。\n\n- **false**:否。\n\n> HTTP、HTTPS监听支持此参数。", "type": "boolean", "example": "false" }, "XForwardedForClientSourceIpsTrusted": { "description": "指定可信的代理IP。\n\n应用型负载均衡ALB会从后往前遍历`X-Forwarded-For`,选取第一个不在可信IP列表中的IP作为真实的客户端IP,该IP会被用于源IP限速。", "type": "string", "example": "10.1.1.0/24" }, "XForwardedForHostEnabled": { "description": "是否开启通过`X-Forwarded-Host`头字段获取访问负载均衡实例客户端的域名。取值:\n- **true**:是。\n- **false**(默认值):否。\n\n> HTTP、HTTPS和QUIC监听支持此参数。", "type": "boolean", "example": "false" } } }, "Tags": { "description": "标签。", "type": "array", "items": { "description": "标签结构。", "type": "object", "properties": { "Key": { "description": "标签键。最多支持128个字符,不能以aliyun或acs:开头,不能包含http://或https://。", "type": "string", "example": "env" }, "Value": { "description": "标签值。最多支持128个字符,不能以aliyun或acs:开头,不能包含http://或https://。", "type": "string", "example": "product" } } } } } } }, "MaxResults": { "title": "本次请求所返回的最大记录条数。", "description": "本次请求所返回的最大记录条数。", "type": "integer", "format": "int32", "example": "50" }, "NextToken": { "title": "用来表示当前调用返回读取到的位置,空代表数据已经读取完毕。", "description": "当前调用返回读取到的位置,设置为空代表数据已经读取完毕。", "type": "string", "example": "FFmyTO70tTpLG6I3FmYAXGKPd****" }, "RequestId": { "title": "Id of the request", "description": "请求ID。", "type": "string", "example": "365F4154-92F6-4AE4-92F8-7FF3******" }, "TotalCount": { "title": "本次请求条件下的数据总量。", "description": "本次请求条件下的数据总量。", "type": "integer", "format": "int32", "example": "1000" } } } } }, "errorCodes": { "403": [ { "errorCode": "Forbidden.LoadBalancer", "errorMessage": "Authentication is failed for %s." } ] }, "responseDemo": "[{\"type\":\"json\",\"example\":\"{\\n \\\"Listeners\\\": [\\n {\\n \\\"DefaultActions\\\": [\\n {\\n \\\"ForwardGroupConfig\\\": {\\n \\\"ServerGroupTuples\\\": [\\n {\\n \\\"ServerGroupId\\\": \\\"sgp-i5qt20******\\\"\\n }\\n ]\\n },\\n \\\"Type\\\": \\\"ForwardGroup\\\"\\n }\\n ],\\n \\\"GzipEnabled\\\": false,\\n \\\"Http2Enabled\\\": false,\\n \\\"IdleTimeout\\\": 3,\\n \\\"ListenerDescription\\\": \\\"HTTP_80\\\",\\n \\\"ListenerId\\\": \\\"lsn-o4u34y73wq7b******\\\",\\n \\\"ListenerPort\\\": 80,\\n \\\"ListenerProtocol\\\": \\\"HTTP\\\",\\n \\\"ListenerStatus\\\": \\\"Running\\\",\\n \\\"LoadBalancerId\\\": \\\"alb-bd6oylbckp6k9x****\\\",\\n \\\"LogConfig\\\": {\\n \\\"AccessLogRecordCustomizedHeadersEnabled\\\": true,\\n \\\"AccessLogTracingConfig\\\": {\\n \\\"TracingEnabled\\\": true,\\n \\\"TracingSample\\\": 100,\\n \\\"TracingType\\\": \\\"Zipkin\\\"\\n }\\n },\\n \\\"QuicConfig\\\": {\\n \\\"QuicListenerId\\\": \\\"lsn-o4u54y73wq7b******\\\",\\n \\\"QuicUpgradeEnabled\\\": true\\n },\\n \\\"RequestTimeout\\\": 34,\\n \\\"SecurityPolicyId\\\": \\\"tls_cipher_policy_1_1\\\",\\n \\\"XForwardedForConfig\\\": {\\n \\\"XForwardedForClientCertClientVerifyAlias\\\": \\\"test_client-verify-alias_123456\\\",\\n \\\"XForwardedForClientCertClientVerifyEnabled\\\": true,\\n \\\"XForwardedForClientCertFingerprintAlias\\\": \\\"test_finger-print-alias_123456\\\",\\n \\\"XForwardedForClientCertFingerprintEnabled\\\": true,\\n \\\"XForwardedForClientCertIssuerDNAlias\\\": \\\"test_issue-dn-alias_123456\\\",\\n \\\"XForwardedForClientCertIssuerDNEnabled\\\": true,\\n \\\"XForwardedForClientCertSubjectDNAlias\\\": \\\"test_subject-dn-alias_123456\\\",\\n \\\"XForwardedForClientCertSubjectDNEnabled\\\": true,\\n \\\"XForwardedForClientSrcPortEnabled\\\": true,\\n \\\"XForwardedForEnabled\\\": true,\\n \\\"XForwardedForProcessingMode\\\": \\\"append\\\",\\n \\\"XForwardedForProtoEnabled\\\": true,\\n \\\"XForwardedForSLBIdEnabled\\\": true,\\n \\\"XForwardedForSLBPortEnabled\\\": true,\\n \\\"XForwardedForClientSourceIpsEnabled\\\": false,\\n \\\"XForwardedForClientSourceIpsTrusted\\\": \\\"10.1.1.0/24\\\",\\n \\\"XForwardedForHostEnabled\\\": false\\n },\\n \\\"Tags\\\": [\\n {\\n \\\"Key\\\": \\\"env\\\",\\n \\\"Value\\\": \\\"product\\\"\\n }\\n ]\\n }\\n ],\\n \\\"MaxResults\\\": 50,\\n \\\"NextToken\\\": \\\"FFmyTO70tTpLG6I3FmYAXGKPd****\\\",\\n \\\"RequestId\\\": \\\"365F4154-92F6-4AE4-92F8-7FF3******\\\",\\n \\\"TotalCount\\\": 1000\\n}\",\"errorExample\":\"\"},{\"type\":\"xml\",\"example\":\"<ListListenersResponse>\\n <Listeners>\\n <DefaultActions>\\n <ForwardGroupConfig>\\n <ServerGroupTuples>\\n <ServerGroupId>rsp-cige6j****</ServerGroupId>\\n </ServerGroupTuples>\\n </ForwardGroupConfig>\\n <Type>ForwardGroup</Type>\\n </DefaultActions>\\n <GzipEnabled>false</GzipEnabled>\\n <Http2Enabled>false</Http2Enabled>\\n <IdleTimeout>3</IdleTimeout>\\n <ListenerDescription>HTTP_80</ListenerDescription>\\n <ListenerId>lsr-bp1bpn0kn908w4nbw****</ListenerId>\\n <ListenerPort>80</ListenerPort>\\n <ListenerProtocol>HTTP</ListenerProtocol>\\n <ListenerStatus>Running</ListenerStatus>\\n <LoadBalancerId>alb-bd6oylbckp6k9x****</LoadBalancerId>\\n <LogConfig>\\n <AccessLogRecordCustomizedHeadersEnabled>true</AccessLogRecordCustomizedHeadersEnabled>\\n <AccessLogTracingConfig>\\n <TracingEnabled>true</TracingEnabled>\\n <TracingSample>100</TracingSample>\\n <TracingType>Zipkin</TracingType>\\n </AccessLogTracingConfig>\\n </LogConfig>\\n <QuicConfig>\\n <QuicListenerId>lsr-bp1bpn908w4nbw****</QuicListenerId>\\n <QuicUpgradeEnabled>true</QuicUpgradeEnabled>\\n </QuicConfig>\\n <RequestTimeout>34</RequestTimeout>\\n <SecurityPolicyId>tls_cipher_policy_1_1</SecurityPolicyId>\\n <XForwardedForConfig>\\n <XForwardedForClientCertClientVerifyAlias>test_client-verify-alias_123456</XForwardedForClientCertClientVerifyAlias>\\n <XForwardedForClientCertClientVerifyEnabled>true</XForwardedForClientCertClientVerifyEnabled>\\n <XForwardedForClientCertFingerprintAlias>test_finger-print-alias_123456</XForwardedForClientCertFingerprintAlias>\\n <XForwardedForClientCertFingerprintEnabled>true</XForwardedForClientCertFingerprintEnabled>\\n <XForwardedForClientCertIssuerDNAlias>test_issue-dn-alias_123456</XForwardedForClientCertIssuerDNAlias>\\n <XForwardedForClientCertIssuerDNEnabled>true</XForwardedForClientCertIssuerDNEnabled>\\n <XForwardedForClientCertSubjectDNAlias>test_subject-dn-alias_123456</XForwardedForClientCertSubjectDNAlias>\\n <XForwardedForClientCertSubjectDNEnabled>true</XForwardedForClientCertSubjectDNEnabled>\\n <XForwardedForClientSrcPortEnabled>true</XForwardedForClientSrcPortEnabled>\\n <XForwardedForEnabled>true</XForwardedForEnabled>\\n <XForwardedForProtoEnabled>true</XForwardedForProtoEnabled>\\n <XForwardedForSLBIdEnabled>true</XForwardedForSLBIdEnabled>\\n <XForwardedForSLBPortEnabled>true</XForwardedForSLBPortEnabled>\\n <XForwardedForClientSourceIpsEnabled>false</XForwardedForClientSourceIpsEnabled>\\n <XForwardedForClientSourceIpsTrusted>10.1.1.0/24</XForwardedForClientSourceIpsTrusted>\\n </XForwardedForConfig>\\n </Listeners>\\n <MaxResults>50</MaxResults>\\n <NextToken>FFmyTO70tTpLG6I3FmYAXGKPd****</NextToken>\\n <RequestId>365F4154-92F6-4AE4-92F8-7FF34B540710</RequestId>\\n <TotalCount>1000</TotalCount>\\n</ListListenersResponse>\",\"errorExample\":\"\"}]", "title": "查询监听" }, "ListServerGroups": { "summary": "查询服务器组列表。", "methods": [ "get", "post" ], "schemes": [ "http", "https" ], "security": [ { "AK": [] } ], "operationType": "read", "deprecated": false, "systemTags": { "operationType": "get", "abilityTreeCode": "166", "abilityTreeNodes": [ "FEATUREslbVRSQEA" ] }, "parameters": [ { "name": "ServerGroupIds", "in": "query", "style": "flat", "schema": { "title": "服务器组Id列表", "description": "服务器组ID列表。", "type": "array", "items": { "description": "服务器组ID,一次最多支持查询20个服务器组ID。", "type": "string", "required": false, "example": "sgp-atstuj3rtop****" }, "required": false, "maxItems": 20 } }, { "name": "ServerGroupNames", "in": "query", "style": "flat", "schema": { "title": "服务器组名称", "description": "服务器组名称列表,最多10个。", "type": "array", "items": { "description": "服务器组名称,一次最多支持查询10个服务器组名称。", "type": "string", "required": false, "example": "Group3" }, "required": false, "maxItems": 10 } }, { "name": "ResourceGroupId", "in": "query", "schema": { "title": "资源组ID", "description": "资源组ID。", "type": "string", "required": false, "example": "rg-atstuj3rtop****" } }, { "name": "NextToken", "in": "query", "schema": { "title": "分页查询标识", "description": "是否拥有下一次查询的令牌(Token)。取值:\n- 第一次查询和没有下一次查询时,均无需填写。\n- 如果有下一次查询,取值为上一次API调用返回的**NextToken**值。", "type": "string", "required": false, "example": "FFmyTO70tTpLG6I3FmYAXG****" } }, { "name": "MaxResults", "in": "query", "schema": { "title": "查询数量", "description": "分批次查询时每次显示的条目数。取值范围:**1**~**100**,默认值为**20**。", "type": "integer", "format": "int32", "required": false, "maximum": "100", "minimum": "1", "example": "20", "default": "20" } }, { "name": "VpcId", "in": "query", "schema": { "title": "VpcId", "description": "VPC实例ID。", "type": "string", "required": false, "example": "vpc-bp15zckdt37pq72zv****" } }, { "name": "ServerGroupType", "in": "query", "schema": { "title": "服务器组类型", "description": "服务器组类型。取值:\n\n- **Instance**:服务器类型,包括Ecs、Eni、Eci实例。\n\n- **Ip**:IP地址类型。\n\n- **Fc**:函数计算类型。\n\n- 不填则查询所有类型。", "type": "string", "required": false, "example": "Instance" } }, { "name": "Tag", "in": "query", "style": "flat", "schema": { "title": "Tag列表", "description": "服务器组绑定的标签列表。一次请求中,绑定的标签列表中最多支持10个标签。", "type": "array", "items": { "description": "服务器组绑定的标签,单次支持传入10个标签。", "type": "object", "properties": { "Key": { "title": "标签键", "description": "标签键。最多支持10个标签键。\n\n最多支持64个字符,不能以`aliyun`和`acs:`开头,不能包含`http://`或者`https://`。", "type": "string", "required": false, "example": "Test" }, "Value": { "title": "标签值", "description": "标签值。最多支持10个标签值。\n\n最多支持128个字符,不能以`aliyun`和`acs:`开头,不能包含`http://`或者`https://`。\n\n", "type": "string", "required": false, "example": "Test" } }, "required": false }, "required": false, "example": "Instance" } } ], "responses": { "200": { "schema": { "title": "Schema of Response", "description": " 返回数据结构体。", "type": "object", "properties": { "MaxResults": { "title": "本次查询返回记录数量", "description": "分批次查询时每次显示的条目数。", "type": "integer", "format": "int32", "example": "50" }, "NextToken": { "title": "分页查询标识", "description": "是否拥有下一次查询的令牌(Token)。取值:\n- 如果**NextToken**为空表示没有下一次查询。\n- 如果**NextToken**有返回值,该取值表示下一次查询开始的令牌。", "type": "string", "example": "caeba0bbb2be03f8****" }, "RequestId": { "title": "Id of the request", "description": "请求ID。", "type": "string", "example": "CEF72CEB-54B6-4AE8-B225-F876******" }, "ServerGroups": { "title": "服务器组", "description": "后端服务器组列表。", "type": "array", "items": { "description": "后端服务器组列表。", "type": "object", "properties": { "HealthCheckConfig": { "title": "健康检查配置", "description": "健康检查配置。", "type": "object", "properties": { "HealthCheckConnectPort": { "title": "端口", "description": "健康检查的后端服务器的端口。取值范围:**0**~**65535**。\n\n返回为**0**时代表使用后端服务器的端口进行健康检查。", "type": "integer", "format": "int32", "example": "80" }, "HealthCheckEnabled": { "title": "是否启用健康检查", "description": "是否启用健康检查,取值:\n- **true**:启用。\n- **false**:不启用。", "type": "boolean", "example": "true" }, "HealthCheckHost": { "title": "域名", "description": "健康检查域名。\n\n- **使用后端服务器的内网IP**(默认):使用后端服务器的内网IP地址作为健康检查的域名。\n\n- **指定特定域名**:输入一个域名。\n\n - 长度限制为1~80个字符。\n\n - 可包含小写字母、数字、短划线(-)和半角句号(.)。\n\n - 至少包含一个半角句号(.),半角句号(.)不能出现在开头或结尾。\n\n - 最右侧的域标签,只能包含字母,不能包含数字或短划线(-)。\n\n - 短划线(-)不能出现在开头或结尾。\n\n> \n> 只有HealthCheckProtocol设置为HTTP、HTTPS或gRPC时,该参数生效。", "type": "string", "example": "www.example.com" }, "HealthCheckCodes": { "title": "状态码", "description": "健康检查正常的状态码列表。", "type": "array", "items": { "description": "健康检查正常的状态码。\n\n- 当**HealthCheckProtocol**取值为**HTTP**或**HTTPS**时,**HealthCheckCodes**可以选择**http\\_2xx**、 **http\\_3xx**、**http\\_4xx**和**http\\_5xx**。多个状态码用半角逗号(,)分隔。\n\n- 当**HealthCheckProtocol**取值为**gRPC**时,**HealthCheckCodes**状态码范围:**0~99**。支持范围输入,最多支持20个范围值,多个范围值使用半角逗号(,)隔开。\n\n> **HealthCheckProtocol**为**HTTP**或**HTTPS**或**gRPC**时,该参数生效。", "type": "string", "example": "http_2xx" } }, "HealthCheckHttpVersion": { "title": "版本", "description": "健康检查HTTP协议版本。\n\n取值:**HTTP1.0**或**HTTP1.1**。\n\n> 只有**HealthCheckProtocol**设置为**HTTP**或**HTTPS**时,该参数生效。", "type": "string", "example": "HTTP1.1" }, "HealthCheckInterval": { "title": "间隔时间", "description": "健康检查的时间间隔。单位:秒。取值范围:**1**~**50**。", "type": "integer", "format": "int32", "example": "5" }, "HealthCheckMethod": { "title": "方法", "description": "健康检查方法。取值:\n\n- **GET**:如果响应报文长度超过8K,会被截断,但不会影响健康检查结果的判定。\n\n- **POST**:gRPC监听健康检查默认采用POST方法。\n\n- **HEAD**:HTTP和HTTPS监听健康检查默认采用HEAD方法。\n\n\n> 只有**HealthCheckProtocol**设置为**HTTP**或**HTTPS**或**gRPC**时,该参数生效。", "type": "string", "example": "HEAD" }, "HealthCheckPath": { "title": "uri", "description": "健康检查的转发规则路径。\n\n> 只有**HealthCheckProtocol**设置为**HTTP**或**HTTPS**时,该参数生效。", "type": "string", "example": "/test/index.html" }, "HealthCheckProtocol": { "title": "协议", "description": "健康检查协议。取值:\n\n- **HTTP**:通过发送HEAD或GET请求模拟浏览器的访问行为来检查服务器应用是否健康。\n\n- **HTTPS**:通过发送HEAD或GET请求模拟浏览器的访问行为来检查服务器应用是否健康。(数据加密,相比HTTP更安全。)\n\n- **TCP**:通过发送SYN握手报文来检测服务器端口是否存活。\n\n- **gRPC**:通过发送POST或GET请求来检查服务器应用是否健康。", "type": "string", "example": "HTTP" }, "HealthCheckTimeout": { "title": "超时时间", "description": "接收来自运行状况检查的响应需要等待的时间。如果后端服务器在指定的时间内没有正确响应,则判定为健康检查失败。单位:秒。\n\n", "type": "integer", "format": "int32", "example": "3" }, "HealthyThreshold": { "title": "健康阈值", "description": "健康检查连续成功多少次后,将后端服务器的健康检查状态由**失败**判定为**成功**。", "type": "integer", "format": "int32", "example": "4" }, "UnhealthyThreshold": { "title": "不健康阈值", "description": "健康检查连续失败多少次后,将后端服务器的健康检查状态由**成功**判定为**失败**。", "type": "integer", "format": "int32", "example": "4" } } }, "Protocol": { "title": "服务器组协议", "description": "后端协议类型。取值:\n\n- **HTTP**:支持关联HTTPS、HTTP和QUIC监听。\n- **HTTPS**:支持关联HTTPS监听。\n\n- **GRPC**:关联HTTPS和QUIC监听。\n", "type": "string", "example": "HTTP" }, "RelatedLoadBalancerIds": { "title": "关联的实例id", "description": "关联的实例id", "type": "array", "items": { "description": "关联的负载均衡实例id", "type": "string", "example": "alb-n5qw04uq8savfe****" } }, "ResourceGroupId": { "title": "资源组id", "description": "资源组ID。", "type": "string", "example": "rg-atstuj3rtop****" }, "Scheduler": { "title": "调度策略", "description": "调度算法。取值:\n\n- **Wrr**:加权轮询,权重值越高的后端服务器,被轮询到的概率也越高。\n- **Wlc**:加权最小连接数,除了根据每台后端服务器设定的权重值来进行轮询,同时还考虑后端服务器的实际负载(即连接数)。当权重值相同时,当前连接数越小的后端服务器被轮询到的概率也越高。\n- **Sch**:一致性哈希,相同哈希因子计算结果的请求将会调度到相同的后端服务器。不配置UchConfig参数时,默认哈希因子为源IP,相同源IP地址的请求会分发到同一台后端服务器;配置了UchConfig参数时,哈希因子为URL参数,相同URL参数的请求会分发到同一台后端服务器。", "type": "string", "example": "Wrr" }, "ServerGroupId": { "title": "服务器组Id", "description": "服务器组ID。", "type": "string", "example": "sgp-cige6j****" }, "ServerGroupName": { "title": "服务器组名称", "description": "服务器组名称。", "type": "string", "example": "Group3" }, "ServerGroupStatus": { "title": "服务器组状态", "description": "服务器组状态。取值:\n- **Creating**:创建中。\n\n- **Available**:可用。\n\n- **Configuring**:变配中。", "type": "string", "example": "Available" }, "ServerGroupType": { "title": "服务器组类型", "description": "服务器组类型。取值:\n\n- **Instance**:服务器类型,包括Ecs、Eni、Eci实例。\n\n- **Ip**:IP类型。\n\n- **Fc**:函数计算类型。", "type": "string", "example": "Instance" }, "StickySessionConfig": { "title": "会话保持配置", "description": "会话保持配置结构体。", "type": "object", "properties": { "Cookie": { "title": "Cookie", "description": "服务器上配置的Cookie。", "type": "string", "example": "B490B5EBF6F3CD402E515D22BCDA****" }, "CookieTimeout": { "title": "Cookie超时时间", "description": "Cookie超时时间。单位:秒。取值范围:**1**~**86400**。\n\n> 当**StickySessionEnabled**为**true**且**StickySessionType**为**Insert**时,该参数生效。\n\n\n\n", "type": "integer", "format": "int32", "example": "1000" }, "StickySessionEnabled": { "title": "是否开启会话保持", "description": "是否启用会话保持。取值:\n\n- **true**:开启。\n- **false**:关闭。\n", "type": "boolean", "example": "false" }, "StickySessionType": { "title": "会话保持类型", "description": "Cookie的处理方式。取值:\n\n- **Insert**:植入Cookie。\n客户端第一次访问时,负载均衡会在返回请求中植入Cookie(即在HTTP或HTTPS响应报文中插入SERVERID),下次客户端携带此Cookie访问,负载均衡服务会将请求定向转发给之前记录到的后端服务器上。\n- **Server**:重写Cookie。\n负载均衡发现用户自定义了Cookie,将会对原来的Cookie进行重写,下次客户端携带新的Cookie访问,负载均衡服务会将请求定向转发给之前记录到的后端服务器。", "type": "string", "example": "Insert" } } }, "VpcId": { "title": "服务器组所在VpcId", "description": "VPC实例ID。", "type": "string", "example": "vpc-bp15zckdt37pq72zv****" }, "Tags": { "title": "标签列表", "description": "服务器组绑定的标签列表。", "type": "array", "items": { "description": "服务器组绑定的标签列表。", "type": "object", "properties": { "Key": { "title": "标签键", "description": "标签键。", "type": "string", "example": "Test" }, "Value": { "title": "标签值", "description": "标签值。", "type": "string", "example": "Test" } } } }, "ConfigManagedEnabled": { "title": "是否开启配置管理", "description": "是否开启配置管理。取值:\n- **true**:开启。\n- **false**:关闭。", "type": "boolean", "example": "false" }, "UpstreamKeepaliveEnabled": { "title": "是否开启后端长链接", "description": "是否开启后端长链接。取值:\n- **true**:开启。\n- **false**:关闭。", "type": "boolean", "example": "false" }, "Ipv6Enabled": { "title": "是否支持Ipv6", "description": "是否支持IPv6。取值:\n- **true**:支持。\n- **false**:不支持。", "type": "boolean", "example": "false" }, "ServerCount": { "title": "服务器组内服务器数量", "description": "服务器组内服务器数量。", "type": "integer", "format": "int32", "example": "1" }, "ServiceName": { "title": "服务器名称", "description": "服务名称。", "type": "string", "example": "test" }, "UchConfig": { "title": "url一致性hash参数配置", "description": "url一致性hash参数配置。", "type": "object", "properties": { "Type": { "title": "参数类型", "description": "参数类型。只能填QueryString。", "type": "string", "example": "QueryString" }, "Value": { "title": "一致性hash参数值", "description": "一致性hash参数值。", "type": "string", "example": "abc" } } }, "CreateTime": { "description": "资源创建时间。", "type": "string", "example": "2022-07-02T02:49:05Z" }, "ConnectionDrainConfig": { "description": "连接优雅中断相关配置。\n\n开启连接优雅中断,在移除后端服务器或者健康检查失败后,负载均衡使现有连接在一定时间内正常传输。\n>\n> - 基础版实例不支持开启连接优雅中断,仅标准版、WAF增强版实例支持。\n> - 服务器类型、IP类型服务器组支持连接优雅中断,函数计算类型不支持。", "type": "object", "properties": { "ConnectionDrainEnabled": { "description": "是否开启连接优雅中断。\n\n- **true**:开启\n- **false**:关闭", "type": "boolean", "example": "false" }, "ConnectionDrainTimeout": { "description": "连接优雅中断超时时间。", "type": "integer", "format": "int32", "example": "300" } } }, "SlowStartConfig": { "title": "慢启动配置", "description": "慢启动相关配置。\n\n开启慢启动后,将会在设定的时间段内对新添加到后端服务器组的后端服务器进行预热,转发到该服务器的请求数量线性增加。\n>\n> - 基础版实例不支持开启慢启动,仅标准版、WAF增强版实例支持。\n> - 服务器类型、IP类型服务器组支持配置慢启动,函数计算类型不支持。\n> - 慢启动仅在后端调度算法是加权轮询算法时可开启。", "type": "object", "properties": { "SlowStartEnabled": { "description": "是否开启慢启动。\n\n- **true**:开启\n- **false**:关闭", "type": "boolean", "example": "false" }, "SlowStartDuration": { "description": "慢启动持续时间。", "type": "integer", "format": "int32", "example": "30" } } }, "CrossZoneEnabled": { "description": "服务器组是否开启跨AZ负载均衡。取值:\n\n- **true**:开启(默认值)\n\n- **false**:关闭", "type": "boolean", "example": "true" } } } }, "TotalCount": { "title": "总记录数", "description": "列表条目数。", "type": "integer", "format": "int32", "example": "1000" } } } } }, "eventInfo": { "enable": false, "eventNames": [] }, "responseDemo": "[{\"type\":\"json\",\"example\":\"{\\n \\\"MaxResults\\\": 50,\\n \\\"NextToken\\\": \\\"caeba0bbb2be03f8****\\\",\\n \\\"RequestId\\\": \\\"CEF72CEB-54B6-4AE8-B225-F876******\\\",\\n \\\"ServerGroups\\\": [\\n {\\n \\\"HealthCheckConfig\\\": {\\n \\\"HealthCheckConnectPort\\\": 80,\\n \\\"HealthCheckEnabled\\\": true,\\n \\\"HealthCheckHost\\\": \\\"www.example.com\\\",\\n \\\"HealthCheckCodes\\\": [\\n \\\"http_2xx\\\"\\n ],\\n \\\"HealthCheckHttpVersion\\\": \\\"HTTP1.1\\\",\\n \\\"HealthCheckInterval\\\": 5,\\n \\\"HealthCheckMethod\\\": \\\"HEAD\\\",\\n \\\"HealthCheckPath\\\": \\\"/test/index.html\\\",\\n \\\"HealthCheckProtocol\\\": \\\"HTTP\\\",\\n \\\"HealthCheckTimeout\\\": 3,\\n \\\"HealthyThreshold\\\": 4,\\n \\\"UnhealthyThreshold\\\": 4\\n },\\n \\\"Protocol\\\": \\\"HTTP\\\",\\n \\\"RelatedLoadBalancerIds\\\": [\\n \\\"alb-n5qw04uq8savfe****\\\"\\n ],\\n \\\"ResourceGroupId\\\": \\\"rg-atstuj3rtop****\\\",\\n \\\"Scheduler\\\": \\\"Wrr\\\",\\n \\\"ServerGroupId\\\": \\\"sgp-cige6j****\\\",\\n \\\"ServerGroupName\\\": \\\"Group3\\\",\\n \\\"ServerGroupStatus\\\": \\\"Available\\\",\\n \\\"ServerGroupType\\\": \\\"Instance\\\",\\n \\\"StickySessionConfig\\\": {\\n \\\"Cookie\\\": \\\"B490B5EBF6F3CD402E515D22BCDA****\\\",\\n \\\"CookieTimeout\\\": 1000,\\n \\\"StickySessionEnabled\\\": false,\\n \\\"StickySessionType\\\": \\\"Insert\\\"\\n },\\n \\\"VpcId\\\": \\\"vpc-bp15zckdt37pq72zv****\\\",\\n \\\"Tags\\\": [\\n {\\n \\\"Key\\\": \\\"Test\\\",\\n \\\"Value\\\": \\\"Test\\\"\\n }\\n ],\\n \\\"ConfigManagedEnabled\\\": false,\\n \\\"UpstreamKeepaliveEnabled\\\": false,\\n \\\"Ipv6Enabled\\\": false,\\n \\\"ServerCount\\\": 1,\\n \\\"ServiceName\\\": \\\"test\\\",\\n \\\"UchConfig\\\": {\\n \\\"Type\\\": \\\"QueryString\\\",\\n \\\"Value\\\": \\\"abc\\\"\\n },\\n \\\"CreateTime\\\": \\\"2022-07-02T02:49:05Z\\\",\\n \\\"ConnectionDrainConfig\\\": {\\n \\\"ConnectionDrainEnabled\\\": false,\\n \\\"ConnectionDrainTimeout\\\": 300\\n },\\n \\\"SlowStartConfig\\\": {\\n \\\"SlowStartEnabled\\\": false,\\n \\\"SlowStartDuration\\\": 30\\n },\\n \\\"CrossZoneEnabled\\\": true\\n }\\n ],\\n \\\"TotalCount\\\": 1000\\n}\",\"errorExample\":\"\"},{\"type\":\"xml\",\"example\":\"<ListServerGroupsResponse>\\n <MaxResults>50</MaxResults>\\n <NextToken>caeba0bbb2be03f8****</NextToken>\\n <RequestId>CEF72CEB-54B6-4AE8-B225-F876FF7BA984</RequestId>\\n <ServerGroups>\\n <HealthCheckConfig>\\n <HealthCheckConnectPort>80</HealthCheckConnectPort>\\n <HealthCheckEnabled>true</HealthCheckEnabled>\\n <HealthCheckHost>www.example.com</HealthCheckHost>\\n <HealthCheckCodes>http_2xx</HealthCheckCodes>\\n <HealthCheckHttpVersion>HTTP1.1</HealthCheckHttpVersion>\\n <HealthCheckInterval>5</HealthCheckInterval>\\n <HealthCheckMethod>HEAD</HealthCheckMethod>\\n <HealthCheckPath>/test/index.html</HealthCheckPath>\\n <HealthCheckProtocol>HTTP</HealthCheckProtocol>\\n <HealthCheckTimeout>3</HealthCheckTimeout>\\n <HealthyThreshold>4</HealthyThreshold>\\n <UnhealthyThreshold>4</UnhealthyThreshold>\\n </HealthCheckConfig>\\n <Protocol>HTTP</Protocol>\\n <ResourceGroupId>rg-atstuj3rtop****</ResourceGroupId>\\n <Scheduler>Wrr</Scheduler>\\n <ServerGroupId>sgp-cige6j****</ServerGroupId>\\n <ServerGroupName>Group3</ServerGroupName>\\n <ServerGroupStatus>Available</ServerGroupStatus>\\n <ServerGroupType>Instance</ServerGroupType>\\n <StickySessionConfig>\\n <Cookie>B490B5EBF6F3CD402E515D22BCDA****</Cookie>\\n <CookieTimeout>1000</CookieTimeout>\\n <StickySessionEnabled>false</StickySessionEnabled>\\n <StickySessionType>Insert</StickySessionType>\\n </StickySessionConfig>\\n <VpcId>vpc-bp15zckdt37pq72zv****</VpcId>\\n <Tags>\\n <Key>Test</Key>\\n <Value>Test</Value>\\n </Tags>\\n <ConfigManagedEnabled>false</ConfigManagedEnabled>\\n <UpstreamKeepaliveEnabled>false</UpstreamKeepaliveEnabled>\\n <Ipv6Enabled>false</Ipv6Enabled>\\n <ServerCount>1</ServerCount>\\n <ServiceName>test</ServiceName>\\n <CreateTime>2023-03-21T07:43:10Z</CreateTime>\\n </ServerGroups>\\n <TotalCount>1000</TotalCount>\\n</ListServerGroupsResponse>\",\"errorExample\":\"\"}]", "title": "查询服务器组" }, "ListServerGroupServers": { "summary": "查询服务器组中的服务器。", "methods": [ "get", "post" ], "schemes": [ "http", "https" ], "security": [ { "AK": [] } ], "operationType": "read", "deprecated": false, "systemTags": { "operationType": "get", "riskType": "none", "chargeType": "free", "abilityTreeCode": "167", "abilityTreeNodes": [ "FEATUREslbULKWF1" ] }, "parameters": [ { "name": "NextToken", "in": "query", "schema": { "title": "分页查询标识", "description": "是否拥有下一次查询的令牌(Token)。取值:\n- 第一次查询和没有下一次查询时,均无需填写。\n- 如果有下一次查询,取值为上一次API调用返回的**NextToken**值。", "type": "string", "required": false, "example": "FFmyTO70tTpLG6I3FmYAXG****" } }, { "name": "MaxResults", "in": "query", "schema": { "title": "查询数量", "description": "本次读取的最大数据记录数量。取值范围:**1**~**100**,入参为空时,默认值为**20**。", "type": "integer", "format": "int32", "required": false, "maximum": "1000", "minimum": "1", "example": "50", "default": "20" } }, { "name": "ServerGroupId", "in": "query", "schema": { "title": "服务器组id", "description": "服务器组ID。", "type": "string", "required": false, "example": "sgp-cb25e2i2vr******" } }, { "name": "ServerIds", "in": "query", "style": "flat", "schema": { "title": "服务器id列表", "description": "服务器ID列表。", "type": "array", "items": { "title": "服务器id", "description": "服务器ID。单次调用最多支持展示40个服务器。\n\n- 当服务器组为**Instance**类型时,该参数为Ecs、Eni、Eci的资源Id。\n- 当服务器组为**Ip**类型时,该参数为IP地址。\n- 当服务器组为**Fc**时,该参数为函数计算的ARN标识。\n\n", "type": "string", "required": false, "example": "i-bp1e0u8f10by57wl****" }, "required": false, "maxItems": 20, "minItems": 1 } }, { "name": "Tag", "in": "query", "style": "flat", "schema": { "title": "服务器组绑定的标签列表", "description": "服务器组绑定的标签列表。一次请求中,绑定的标签列表中最多支持10个标签。", "type": "array", "items": { "title": "服务器组绑定的标签", "description": "服务器组绑定的标签列表。一次请求中,绑定的标签列表中最多支持10个标签。", "type": "object", "properties": { "Key": { "title": "标签键", "description": "标签键。最多支持10个标签键。\n\n最多支持64个字符,不能以`aliyun`和`acs:`开头,不能包含`http://`或者`https://`。", "type": "string", "required": false, "example": "Test" }, "Value": { "title": "标签值", "description": "标签值。最多支持10个标签值。\n\n最多支持128个字符,不能以`aliyun`和`acs:`开头,不能包含`http://`或者`https://`。", "type": "string", "required": false, "example": "Test" } }, "required": false }, "required": false } } ], "responses": { "200": { "schema": { "title": "Schema of Response", "description": "返回数据结构体。", "type": "object", "properties": { "MaxResults": { "title": "本次查询返回记录数量", "description": "本次请求所返回的最大记录条数。", "type": "integer", "format": "int32", "example": "50" }, "NextToken": { "title": "分页查询标识", "description": "是否拥有下一次查询的令牌(Token)。取值:\n- 如果**NextToken**为空表示没有下一次查询。\n- 如果**NextToken**有返回值,该取值表示下一次查询开始的令牌。", "type": "string", "example": "caeba0bbb2be03f8****" }, "RequestId": { "title": "Id of the request", "description": "请求ID。", "type": "string", "example": "CEF72CEB-54B6-4AE8-B225-F876FF*****" }, "Servers": { "title": "后端服务器列表", "description": "服务器列表。", "type": "array", "items": { "title": "后端服务器", "description": "后端服务器描述结构体。", "type": "object", "properties": { "Description": { "title": "描述信息", "description": "后端服务器描述。", "type": "string", "example": "test" }, "Port": { "title": "端口", "description": "后端服务器使用的端口。取值范围:**1**~**65535**。", "type": "integer", "format": "int32", "example": "80" }, "ServerId": { "title": "服务器id", "description": "后端服务器ID。\n\n>当**ServerType**为**Fc**时,**ServerId**为函数计算的ARN标识。", "type": "string", "example": "i-bp1f9kdprbgy9uiu****" }, "ServerIp": { "title": "服务器ip", "description": "指定的IP地址。", "type": "string", "example": "192.168.XX.XX" }, "ServerType": { "title": "后端服务器类型", "description": "后端服务器类型。", "type": "string", "example": "Ecs" }, "Status": { "title": "状态", "description": "后端服务器的添加状态。取值:\n\n- **Adding**:添加中。\n- **Available**:正常可用状态。\n- **Configuring**:配置中。\n- **Removing**:移除中。", "type": "string", "example": "Available" }, "Weight": { "title": "权重", "description": "后端服务器的权重。权重越高的服务器将被分配到更多的访问请求。", "type": "integer", "format": "int32", "example": "100" }, "ServerGroupId": { "title": "服务器组id", "description": "服务器组ID。", "type": "string", "example": "sgp-qy042e1jabmprh****" }, "RemoteIpEnabled": { "title": "是否是远端ip", "description": "是否开启远端IP。取值:\n \n- **true**:是。\n- **false**:否。", "type": "boolean", "example": "true" } } } }, "TotalCount": { "title": "总记录数", "description": "本次请求条件下的数据总量。", "type": "integer", "format": "int32", "example": "3" } } } } }, "errorCodes": { "403": [ { "errorCode": "Forbidden.ServerGroup", "errorMessage": "Authentication has failed for ServerGroup." } ] }, "responseDemo": "[{\"type\":\"json\",\"example\":\"{\\n \\\"MaxResults\\\": 50,\\n \\\"NextToken\\\": \\\"caeba0bbb2be03f8****\\\",\\n \\\"RequestId\\\": \\\"CEF72CEB-54B6-4AE8-B225-F876FF*****\\\",\\n \\\"Servers\\\": [\\n {\\n \\\"Description\\\": \\\"test\\\",\\n \\\"Port\\\": 80,\\n \\\"ServerId\\\": \\\"i-bp1f9kdprbgy9uiu****\\\",\\n \\\"ServerIp\\\": \\\"192.168.XX.XX\\\",\\n \\\"ServerType\\\": \\\"Ecs\\\",\\n \\\"Status\\\": \\\"Available\\\",\\n \\\"Weight\\\": 100,\\n \\\"ServerGroupId\\\": \\\"sgp-qy042e1jabmprh****\\\",\\n \\\"RemoteIpEnabled\\\": true\\n }\\n ],\\n \\\"TotalCount\\\": 3\\n}\",\"errorExample\":\"\"},{\"type\":\"xml\",\"example\":\"<ListServerGroupServersResponse>\\n <MaxResults>50</MaxResults>\\n <NextToken>caeba0bbb2be03f8****</NextToken>\\n <RequestId>CEF72CEB-54B6-4AE8-B225-F876FF7BA984</RequestId>\\n <Servers>\\n <Description>test</Description>\\n <Port>80</Port>\\n <ServerId>i-bp1f9kdprbgy9uiu****</ServerId>\\n <ServerIp>192.168.XX.XX</ServerIp>\\n <ServerType>Ecs</ServerType>\\n <Status>Available</Status>\\n <Weight>100</Weight>\\n <ServerGroupId>sgp-qy042e1jabmprh****</ServerGroupId>\\n <RemoteIpEnabled>true</RemoteIpEnabled>\\n </Servers>\\n <TotalCount>3</TotalCount>\\n</ListServerGroupServersResponse>\",\"errorExample\":\"\"}]", "title": "查询服务器" }, "ListRules": { "summary": "查询指定地域的转发规则。", "methods": [ "get", "post" ], "schemes": [ "http", "https" ], "security": [ { "AK": [] } ], "operationType": "read", "deprecated": false, "systemTags": { "operationType": "get", "riskType": "none", "chargeType": "free", "abilityTreeNodes": [ "FEATUREslbM7ALO6" ] }, "parameters": [ { "name": "NextToken", "in": "query", "schema": { "title": "用来标记当前开始读取的位置,置空表示从头开始。", "description": "是否拥有下一次查询的令牌(Token)。取值:\n\n- 第一次查询和没有下一次查询时,均无需填写。\n\n- 如果有下一次查询,取值为上一次API调用返回的**NextToken**值。", "type": "string", "required": false, "example": "FFmyTO70tTpLG6I3FmYAXGKPd****" } }, { "name": "MaxResults", "in": "query", "schema": { "title": "本次读取的最大数据记录数量,此参数为可选参数,取值1-100,用户传入为空时,默认为20。", "description": "本次读取的最大数据记录数。\n\n取值:**1~100**。\n\n默认值:**20**,表示用户没有传入数据。\n\n> 此参数为可选。", "type": "integer", "format": "int32", "required": false, "example": "20" } }, { "name": "RuleIds", "in": "query", "style": "flat", "schema": { "title": "转发规则ID列表,N最大支持20", "description": "转发规则列表,一次最多支持查询20个转发规则。", "type": "array", "items": { "description": "转发规则ID。", "type": "string", "required": false, "example": "rule-sada******" }, "required": false, "maxItems": 20, "minItems": 1 } }, { "name": "ListenerIds", "in": "query", "style": "flat", "schema": { "title": "监听ID列表", "description": "监听ID列表。一次最多支持查询20个监听。", "type": "array", "items": { "description": "监听ID。", "type": "string", "required": false, "example": "lsn-i35udpz3pxsmnf****" }, "required": false, "maxItems": 20 } }, { "name": "LoadBalancerIds", "in": "query", "style": "flat", "schema": { "title": "实例ID列表", "description": "负载均衡实例ID列表。一次最多支持查询20个实例。", "type": "array", "items": { "description": "负载均衡实例ID。", "type": "string", "required": false, "example": "alb-x30o38azsuj0sx****" }, "required": false, "maxItems": 20 } }, { "name": "Direction", "in": "query", "schema": { "title": "转发规则方向", "description": "转发规则的方向。取值:\n\n- **Request**(默认值):请求类型,对从客户端发送到ALB的报文进行条件匹配并进行相应的处理。\n\n- **Response**:响应类型,对从后端服务器组返回到ALB的报文进行条件匹配并进行相应的处理。\n\n>基础版的ALB实例不支持Response类型.", "type": "string", "required": false, "example": "Request" } }, { "name": "Tag", "in": "query", "style": "flat", "schema": { "description": "标签。", "type": "array", "items": { "description": "标签结构。", "type": "object", "properties": { "Key": { "description": "标签键。最多支持128个字符,不能以aliyun或acs:开头,不能包含http://或https://。", "type": "string", "required": false, "example": "env" }, "Value": { "description": "标签值。最多支持128个字符,不能以aliyun或acs:开头,不能包含http://或https://。", "type": "string", "required": false, "example": "product" } }, "required": false }, "required": false, "maxItems": 20 } } ], "responses": { "200": { "schema": { "title": "Schema of Response", "description": "转发规则。", "type": "object", "properties": { "MaxResults": { "title": "本次请求所返回的最大记录条数。", "description": "本次请求所返回的最大记录条数。", "type": "integer", "format": "int32", "example": "50" }, "NextToken": { "title": "用来表示当前调用返回读取到的位置,空代表数据已经读取完毕。", "description": "是否拥有下一次查询的令牌(Token)。取值:\n- 如果**NextToken**为空表示没有下一次查询。\n- 如果**NextToken**有返回值,该取值表示下一次查询开始的令牌。", "type": "string", "example": "FFmyTO70tTpLG6I3FmYAXGKPd****" }, "RequestId": { "title": "Id of the request", "description": "请求ID。", "type": "string", "example": "CEF72CEB-54B6-4AE8-B225-F876F******" }, "Rules": { "title": "转发规则列表", "description": "转发规则列表。", "type": "array", "items": { "description": "转发规则结构。", "type": "object", "properties": { "ListenerId": { "title": "监听ID", "description": "转发规则所属监听ID。", "type": "string", "example": "lsn-i35udpz3pxsmnf****" }, "LoadBalancerId": { "title": "实例ID", "description": "转发规则所属负载均衡实例ID。", "type": "string", "example": "alb-x30o38azsuj0sx****" }, "Priority": { "title": "转发规则优先级", "description": "规则优先级,取值为**1~10000**。值越小表示优先级越高。\n\n> 同一个监听内规则优先级必须唯一。", "type": "integer", "format": "int32", "example": "1" }, "RuleActions": { "title": "转发规则动作", "description": "转发规则动作列表。", "type": "array", "items": { "description": "转发规则动作结构。", "type": "object", "properties": { "FixedResponseConfig": { "title": "返回固定内容动作配置", "description": "固定响应内容配置。", "type": "object", "properties": { "Content": { "title": "内容", "description": "返回的固定内容。最大1 KB字节,只支持ASCII字符。", "type": "string", "example": "dssacav" }, "ContentType": { "title": "内容类型", "description": "返回固定内容的格式。\n\n取值:**text/plain**、**text/css**、**text/html**、**application/javascript**或**application/json**。", "type": "string", "example": "text/plain" }, "HttpCode": { "title": "HTTP响应码", "description": "返回的HTTP响应码,仅支持**HTTP_2xx**、**HTTP_4xx**、**HTTP_5xx**数字型字符串,**x**为任意数字。", "type": "string", "example": "HTTP_2xx" } } }, "ForwardGroupConfig": { "title": "转发组动作配置", "description": "转发组配置。", "type": "object", "properties": { "ServerGroupTuples": { "title": "转发到的目的服务器组列表", "description": "转发到的目的服务器组列表。", "type": "array", "items": { "description": "转发到的目的服务器组列表。", "type": "object", "properties": { "ServerGroupId": { "title": "服务器组标识", "description": "转发到的目的服务器组ID。", "type": "string", "example": "sgp-atstuj3rtoptyui****" }, "Weight": { "title": "当ServerGroupTuple.N数量大于1时,可配置每个服务器组的权重", "description": "权重。取值范围:**0**~**100**。", "type": "integer", "format": "int32", "example": "2" } } } }, "ServerGroupStickySession": { "title": "服务器组间会话保持配置", "description": "服务器组间会话保持配置", "type": "object", "properties": { "Enabled": { "title": "当ServerGroupTuple.N数量大于1时,可选是否开启在服务器组间的会话保持", "description": "当ServerGroupTuple.N数量大于1时,可选是否开启在服务器组间的会话保持", "type": "boolean" }, "Timeout": { "title": "当Enabled=True时,可以配置会话保持的超时时间", "description": "当Enabled=True时,可以配置会话保持的超时时间", "type": "integer", "format": "int32", "example": "100" } } } } }, "InsertHeaderConfig": { "title": "插入头部动作配置", "description": "写入头字段配置。", "type": "object", "properties": { "Key": { "title": "HTTP标头", "description": "插入的头字段名称,长度为1\\~40个字符,支持大小写字母a\\~z、数字、下划线(_)和短划线(-)。头字段名称不能重复用于`InsertHeader`中。\n\n> 不允许用户在头字段名称中使用**Cookie**和**Host**。", "type": "string", "example": "key" }, "Value": { "title": "HTTP标头内容", "description": "插入的头字段内容。\n\n- **ValueType**取值为**SystemDefined**时取值如下:\n - **ClientSrcPort**:客户端端口。\n - **ClientSrcIp**:客户端IP地址。\n - **Protocol**:客户端请求的协议(HTTP或HTTPS)。\n - **SLBId**:应用型负载均衡实例ID。\n - **SLBPort**:应用型负载均衡实例监听端口。\n- **ValueType**取值为**UserDefined**时:您可自定义头字段内容,限制长度为1\\~128个字符,支持通配符星号(*)、半角问号(?)和ASCII码值`ch >= 32 && ch < 127`范围内的可打印字符,开头和结尾不能为空格。\n- **ValueType**取值为**ReferenceHeader**时:您可以引用请求头字段中的某一个字段,限制长度限制为1\\~128个字符,支持小写字母a\\~z、数字、短划线(-)和下划线(_)。", "type": "string", "example": "ClientSrcPort" }, "ValueType": { "title": "取值类型", "description": "头字段内容类型。取值:\n\n- **UserDefined**:用户指定。\n\n- **ReferenceHeader**:引用用户请求头中的某一个字段。\n\n- **SystemDefined**:系统定义。", "type": "string", "example": "SystemDefined" } } }, "Order": { "title": "优先级", "description": "转发规则动作执行的顺序,取值为**1~50000**,按值从小到大执行动作。值不能为空,不能重复。", "type": "integer", "format": "int32", "example": "1" }, "RedirectConfig": { "title": "重定向动作配置", "description": "重定向配置。", "type": "object", "properties": { "Host": { "title": "要跳转的主机地址", "description": "要跳转的主机地址。取值:\n- **${host}**(默认值):取此值时不支持和其他字符拼接使用。\n- 其他取值,字符集和格式限制如下:\n - 主机名长度为3\\~128个字符,支持小写字母a\\~z、数字、短划线(-)、半角句号(.)以及通配符星号(*)和半角问号(?)。\n - 主机名至少包含一个半角句号(.),且半角句号(.)不能出现在开头或结尾。\n - 最右侧的域标签只能包含字母和通配符,不能包含数字或短划线(-)。\n - 短划线(-)不能出现在其它域标签的开头或结尾。\n - 通配符星号(*)和半角问号(?)可以出现在域标签的任意位置。", "type": "string", "example": "www.example.com" }, "HttpCode": { "title": "跳转方式", "description": "跳转方式,取值为**301**、**302**、**303**、**307**或**308**。", "type": "string", "example": "301" }, "Path": { "title": "要跳转的路径", "description": "要跳转的路径。取值:\n- **${path}**(默认值):可以引用**${host}**、**${protocol}**和**${port}**,由**${host}**、**${protocol}**和**${port}**组成,每个变量最多出现一次。上述变量可以同时使用,也可以和下面罗列的可取值范围内的字符串拼接使用。\n- 其他取值,字符集和格式限制如下:\n - 长度为1~128个字符。\n - 必须以正斜线(/)开头,支持字母、数字和特殊字符`$-_.+/&~@:`,不支持`“%#;!()[]^,” `,同时支持通配符星号(*)和半角问号(?)。", "type": "string", "example": "/test" }, "Port": { "title": "要跳转的端口", "description": "要跳转的端口。取值:\n- **${port}**(默认值):该取值不支持和其他字符同时使用。\n- 其他取值:**1~63335**。", "type": "string", "example": "10" }, "Protocol": { "title": "要跳转的协议", "description": "要跳转的协议。取值:\n- **${protocol}**(默认值):取该值时不支持和其他字符拼接使用。\n- **HTTP**或**HTTPS**。\n\n \n> HTTPS监听仅支持跳转HTTPS协议。", "type": "string", "example": "HTTP" }, "Query": { "title": "要跳转的查询字符串", "description": "要跳转的查询字符串。长度为1~128个字符,支持小写字母和可见字符,不支持 `#[]{}\\|<>&`。\n", "type": "string", "example": "quert" } } }, "RemoveHeaderConfig": { "title": "去除HTTP标头", "description": "去除HTTP头部配置。", "type": "object", "properties": { "Key": { "title": "HTTP标头", "description": "去除的头字段名称,长度为1\\~40个字符,支持大小写字母a~z、数字、下划线(_)和短划线(-)。头字段名称不能重复用于RemoveHeader中。\n\n* 请求方向(Direction取值为Request):不允许将头名称设置为以下字段(不区分大小写):`slb-id`、`slb-ip`、`x-forwarded-for`、`x-forwarded-proto`、`x-forwarded-eip`、`x-forwarded-port`、`x-forwarded-client-srcport`、`connection`、`upgrade`、`content-length`、`transfer-encoding`、`keep-alive`、`te`、`host`、`cookie`、`remoteip`、`authority`。\n* 响应方向(Direction取值为Response):响应方向不允许将头名称设置为以下字段(不区分大小写):`connection`、`upgrade`、`content-length`、`transfer-encoding`。", "type": "string", "example": "key" } } }, "RewriteConfig": { "title": "内部重定向动作配置", "description": "重写配置。", "type": "object", "properties": { "Host": { "title": "主机名", "description": "要跳转的主机地址。取值:\n- **${host}**(默认值):取此值时不支持和其他字符拼接使用。\n- 其他取值,字符集和格式限制如下:\n - 主机名长度为3\\~128个字符,支持小写字母a\\~z、数字、短划线(-)、半角句号(.)以及通配符星号(*)和半角问号(?)。\n - 主机名至少包含一个半角句号(.),且半角句号(.)不能出现在开头或结尾。\n - 最右侧的域标签只能包含字母和通配符,不能包含数字或短划线(-)。\n - 短划线(-)不能出现在其它域标签的开头或结尾。\n - 通配符星号(*)和半角问号(?)可以出现在域标签的任意位置。", "type": "string", "example": "www.example.com" }, "Path": { "title": "路径", "description": "内部跳转的目的路径。长度为1~128个字符,以正斜线(/)开头,支持字母、数字、星号(*)、半角问号(?)和`$-_.+/&~@:`,不支持`“%#;!()[]^,” `。", "type": "string", "example": "/tsdf" }, "Query": { "title": "查询", "description": "内部跳转的查询字符串。长度为1~128个字符,支持小写字母和可见字符,不支持 `#[]{}\\|<>&`。\n\n", "type": "string", "example": "quedsa" } } }, "TrafficMirrorConfig": { "title": "流量镜像Action对应的配置,type为TrafficMirror时必填且有效", "description": "流量镜像。", "type": "object", "properties": { "TargetType": { "title": "流量镜像的目的,可以是服务器组", "description": "流量镜像的目的,可以是服务器组", "type": "string", "example": "ForwardGroupMirror" }, "MirrorGroupConfig": { "title": "TargetType为服务器组时必选,目标服务器组", "description": "流量镜像至服务器组。", "type": "object", "properties": { "ServerGroupTuples": { "description": "流量镜像至服务器组。", "type": "array", "items": { "type": "object", "properties": { "ServerGroupId": { "description": "服务器组ID。", "type": "string", "example": "sgp-00mkgijak0w4qgz9****" }, "Weight": { "description": "权重。取值范围:**0**~**100**。", "type": "integer", "format": "int32", "example": "2" } } } } } } } }, "TrafficLimitConfig": { "description": "流量限速。", "type": "object", "properties": { "QPS": { "description": "每秒请求次数。取值范围:**1**~**100000**。", "type": "integer", "format": "int32", "example": "4" }, "PerIpQps": { "description": "单IP每秒请求次数。 取值范围:**1 ~ 100000**。\n\n> 如果同时配置**QPS**参数,**PerIpQps**参数的取值必须小于**QPS**参数的取值。", "type": "integer", "format": "int32", "example": "80" } } }, "Type": { "title": "转发规则动作类型", "description": "动作类型。取值:\n\n- **ForwardGroup**:转发至多个虚拟服务器组。\n\n- **Redirect**:重定向。\n\n- **FixedResponse**:返回固定内容。\n\n- **Rewrite**:重写。\n\n- **InsertHeader**:写入头字段。\n\n- **RemoveHeaderConfig**:删除头字段。\n\n- **TrafficLimitConfig**:流量限速。\n\n- **TrafficMirrorConfig**:流量镜像。\n\n- **CorsConfig**:跨域。", "type": "string", "example": "ForwardGroup" }, "CorsConfig": { "title": "跨域", "description": "跨域。", "type": "object", "properties": { "AllowOrigin": { "title": "允许的访问来源", "description": "允许的访问来源。", "type": "array", "items": { "description": "允许访问的来源。支持配置为`*`或配置为一个或多个value值。value的值不能为`*`。\n\n- 单个value值必须以`http://`或者`https://`开头,后面加一个正确的域名或者一级的泛域名(例如,`*.test.abc.example.com`)。\n- 单个value值可以不加端口,也可以指定端口,端口范围:**1**~**65535**。", "type": "string", "example": "http://test.com" } }, "AllowMethods": { "title": "选择跨域访问时允许的HTTP方法", "description": "选择跨域访问时允许的HTTP方法。", "type": "array", "items": { "description": "选择跨域访问时允许的HTTP方法。取值:\n- **GET**。\n- **POST**。\n- **PUT**。\n- **DELETE**。\n- **HEAD**。\n- **OPTIONS**。\n- **PATCH**。", "type": "string", "example": "GET" } }, "AllowHeaders": { "title": "允许跨域的Header列表", "description": "允许跨域的Header列表。", "type": "array", "items": { "description": "允许跨域的Header列表。支持配置为`*`或配置一个或多个value值,多个value值用半角逗号(,)隔开。单个value值只允许包含大小写字母、数字,以及不在首尾的下划线(_)和短划线(-),最大长度限制为32个字符。", "type": "string", "example": "test_123" } }, "ExposeHeaders": { "title": "允许暴露的Header列表", "description": "允许暴露的Header列表。", "type": "array", "items": { "description": "允许跨域的Header列表。支持配置为`*`或配置一个或多个value值,多个value值用半角逗号(,)隔开。单个value值只允许包含大小写字母、数字,以及不在首尾的下划线(_)和短划线(-),最大长度限制为32个字符。", "type": "string", "example": "test_123" } }, "AllowCredentials": { "title": "是否允许携带凭证信息", "description": "是否允许携带凭证信息。取值:\n\n- **on**:是。\n- **off**:否。", "type": "string", "example": "on" }, "MaxAge": { "title": "预检请求在浏览器的最大缓存时间", "description": "预检请求在浏览器的最大缓存时间,单位:秒。\n\n取值范围:**-1**~**172800**。", "type": "integer", "format": "int64", "example": "1000" } } } } } }, "RuleConditions": { "title": "转发规则条件", "description": "转发规则条件列表。", "type": "array", "items": { "description": "转发规则条件结构。", "type": "object", "properties": { "CookieConfig": { "title": "Cookie条件配置", "description": "Cookie配置。", "type": "object", "properties": { "Values": { "title": "Cookie键值对列表", "description": "Cookie值。", "type": "array", "items": { "description": "Cookie值。", "type": "object", "properties": { "Key": { "title": "Cookie条件键", "description": "Cookie键。长度为1~100个字符,支持小写字母、可见字符、星号(*)和半角问号(?),不支持空格和`#[]{}\\|<>&`。", "type": "string", "example": "test" }, "Value": { "title": "Cookie条件值", "description": "Cookie值。长度为1~128个字符,支持小写字母、可见字符、星号(*)和半角问号(?),不支持空格和`#[]{}\\|<>&`。", "type": "string", "example": "test" } } } } } }, "HeaderConfig": { "title": "HTTP标头条件配置", "description": "头字段配置。", "type": "object", "properties": { "Key": { "title": "HTTP标头键", "description": "头字段键。长度为1\\~40个字符。支持字母a\\~z、数字、短划线(-)和下划线(_)。不支持Cookie和Host。", "type": "string", "example": "Port" }, "Values": { "title": "HTTP标头值列表", "description": "头字段值。", "type": "array", "items": { "description": "头字段值。长度为1\\~128个字符。支持ASCII码值`ch >= 32 && ch < 127`范围内可打印字符、小写字母、星号(*)和半角问号(?)。开头和结尾不能为空格。", "type": "string", "example": "5006" } } } }, "HostConfig": { "title": "主机名条件配置", "description": "主机配置。", "type": "object", "properties": { "Values": { "title": "主机名列表", "description": "主机名。", "type": "array", "items": { "description": "主机名。命名规则:\n\n- 域名长度为3\\~128个字符,支持小写字母a\\~z、数字、短划线(-)、半角句号(.)、星号(*)和半角问号(?)。\n\n- 域名至少包含一个半角句号(.),且半角句号(.)不能出现在开头或结尾。\n\n- 最右侧的域标签只能包含字母、星号(*)和半角问号(?),不能包含数字或短划线(-)。\n\n- 短划线(-)不能出现在其它域标签的开头或结尾。星号(*)和半角问号(?)可以出现在域标签的任意位置。", "type": "string", "example": "www.example.com" } } } }, "MethodConfig": { "title": "HTTP请求方法条件配置", "description": "请求方法配置。", "type": "object", "properties": { "Values": { "title": "HTTP请求方法列表", "description": "请求方法。", "type": "array", "items": { "description": "请求方法。\n\n取值:**HEAD**、**GET**、**POST**、**OPTIONS**、**PUT**、**PATCH**或**DELETE**。", "type": "string", "example": "PUT" } } } }, "PathConfig": { "title": "路径条件配置", "description": "转发路径配置。", "type": "object", "properties": { "Values": { "title": "路径条件列表", "description": "转发路径。", "type": "array", "items": { "description": "转发路径。长度为1~128个字符,以正斜线(/)开头,支持字母、数字、星号(*)、半角问号(?)和`$-_.+/&~@:`,不支持`“%#;!()[]^,” `。", "type": "string", "example": "/test" } } } }, "QueryStringConfig": { "title": "查询字符串条件配置", "description": "查询字符串配置。", "type": "object", "properties": { "Values": { "title": "查询字符串条件键值对列表", "description": "查询字符串。", "type": "array", "items": { "description": "查询字符串。", "type": "object", "properties": { "Key": { "title": "查询字符串条件键", "description": "查询字符串键。长度为1~100个字符,支持小写字母、可见字符、星号(*)和半角问号(?),不支持空格和`#[]{}\\|<>&`。", "type": "string", "example": "test" }, "Value": { "title": "查询字符串条件值", "description": "查询字符串值。长度为1~128个字符,支持小写字母、可见字符、星号(*)和半角问号(?),不支持空格和`#[]{}\\|<>&`。", "type": "string", "example": "test" } } } } } }, "SourceIpConfig": { "title": "源IP业务流量匹配", "description": "基于源IP业务流量匹配。", "type": "object", "properties": { "Values": { "title": "需要匹配的源IP列表", "description": "需要匹配的源IP列表。", "type": "array", "items": { "description": "添加一个或多个IP地址或者IP地址段。\n\n一条转发规则中最多支持添加5条源IP。", "type": "string", "example": "192.168.XX.XX/32" } } } }, "ResponseStatusCodeConfig": { "title": "返回状态码条件", "description": "响应状态码配置。", "type": "object", "properties": { "Values": { "title": "返回状态码条件列表", "description": "响应状态码列表。", "type": "array", "items": { "description": "响应状态码。", "type": "string", "example": "200" } } } }, "ResponseHeaderConfig": { "title": "返回HTTP标头", "description": "响应HTTP头部配置。", "type": "object", "properties": { "Key": { "title": "返回HTTP标头键", "description": "响应HTTP头部键。长度为1\\~40个字符。支持字母a~z、数字、短划线(-)和下划线(_)。不支持Cookie和Host。", "type": "string", "example": "key" }, "Values": { "title": "返回HTTP标头值", "description": "响应HTTP头部值列表。", "type": "array", "items": { "description": "响应HTTP头部值。长度为1~128个字符。", "type": "string", "example": "value" } } } }, "Type": { "title": "条件类型", "description": "转发规则类型。取值:\n\n- **Host**:主机。\n\n- **Path**:路径。\n\n- **Header**:HTTP头字段。\n\n- **QueryString**:查询字符串。\n\n- **Method**:请求方法。\n\n- **Cookie**:Cookie。\n\n- **SourceIp**:源IP。", "type": "string", "example": "Host" } }, "required": true } }, "RuleId": { "title": "转发规则标识", "description": "转发规则ID。", "type": "string", "example": "rule-bpn0kn908w4nbw****" }, "RuleName": { "title": "转发规则名称", "description": "转发规则名称。 长度为2~128个英文或中文字符,必须以大小字母或中文开头,可包含数字,半角句号(.),下划线(_)和短划线(-)。", "type": "string", "example": "rule-instance-test" }, "RuleStatus": { "title": "转发规则状态", "description": "转发规则状态。取值:\n\n- **Provisioning**:创建中。\n\n- **Configuring**:变配中。\n\n- **Available**:运行中。", "type": "string", "example": "Available" }, "Direction": { "title": "转发规则方向", "description": "转发规则的方向。取值:\n\n* Request(默认值):请求类型,对从客户端发送到ALB的报文进行条件匹配并进行相应的处理。\n\n* Response:响应类型,对从后端服务器组返回到ALB的报文进行条件匹配并进行相应的处理。\n\n> 基础版的ALB实例不支持Response类型。", "type": "string", "example": "Request" }, "Tags": { "description": "标签。", "type": "array", "items": { "description": "标签结构。", "type": "object", "properties": { "Key": { "description": "标签键。最多支持128个字符,不能以aliyun或acs:开头,不能包含http://或https://。", "type": "string", "example": "env" }, "Value": { "description": "标签值。最多支持128个字符,不能以aliyun或acs:开头,不能包含http://或https://。", "type": "string", "example": "product" } } } } } } }, "TotalCount": { "title": "本次请求条件下的数据总量。", "description": "本次请求条件下返回的总数据记录数。", "type": "integer", "format": "int32", "example": "1000" } } } } }, "errorCodes": { "403": [ { "errorCode": "Forbidden.LoadBalancer", "errorMessage": "Authentication is failed for %s." } ] }, "responseDemo": "[{\"type\":\"json\",\"example\":\"{\\n \\\"MaxResults\\\": 50,\\n \\\"NextToken\\\": \\\"FFmyTO70tTpLG6I3FmYAXGKPd****\\\",\\n \\\"RequestId\\\": \\\"CEF72CEB-54B6-4AE8-B225-F876F******\\\",\\n \\\"Rules\\\": [\\n {\\n \\\"ListenerId\\\": \\\"lsn-i35udpz3pxsmnf****\\\",\\n \\\"LoadBalancerId\\\": \\\"alb-x30o38azsuj0sx****\\\",\\n \\\"Priority\\\": 1,\\n \\\"RuleActions\\\": [\\n {\\n \\\"FixedResponseConfig\\\": {\\n \\\"Content\\\": \\\"dssacav\\\",\\n \\\"ContentType\\\": \\\"text/plain\\\",\\n \\\"HttpCode\\\": \\\"HTTP_2xx\\\"\\n },\\n \\\"ForwardGroupConfig\\\": {\\n \\\"ServerGroupTuples\\\": [\\n {\\n \\\"ServerGroupId\\\": \\\"sgp-atstuj3rtoptyui****\\\",\\n \\\"Weight\\\": 2\\n }\\n ],\\n \\\"ServerGroupStickySession\\\": {\\n \\\"Enabled\\\": true,\\n \\\"Timeout\\\": 100\\n }\\n },\\n \\\"InsertHeaderConfig\\\": {\\n \\\"Key\\\": \\\"key\\\",\\n \\\"Value\\\": \\\"ClientSrcPort\\\",\\n \\\"ValueType\\\": \\\"SystemDefined\\\"\\n },\\n \\\"Order\\\": 1,\\n \\\"RedirectConfig\\\": {\\n \\\"Host\\\": \\\"www.example.com\\\",\\n \\\"HttpCode\\\": \\\"301\\\",\\n \\\"Path\\\": \\\"/test\\\",\\n \\\"Port\\\": \\\"10\\\",\\n \\\"Protocol\\\": \\\"HTTP\\\",\\n \\\"Query\\\": \\\"quert\\\"\\n },\\n \\\"RemoveHeaderConfig\\\": {\\n \\\"Key\\\": \\\"key\\\"\\n },\\n \\\"RewriteConfig\\\": {\\n \\\"Host\\\": \\\"www.example.com\\\",\\n \\\"Path\\\": \\\"/tsdf\\\",\\n \\\"Query\\\": \\\"quedsa\\\"\\n },\\n \\\"TrafficMirrorConfig\\\": {\\n \\\"TargetType\\\": \\\"ForwardGroupMirror\\\",\\n \\\"MirrorGroupConfig\\\": {\\n \\\"ServerGroupTuples\\\": [\\n {\\n \\\"ServerGroupId\\\": \\\"sgp-00mkgijak0w4qgz9****\\\",\\n \\\"Weight\\\": 2\\n }\\n ]\\n }\\n },\\n \\\"TrafficLimitConfig\\\": {\\n \\\"QPS\\\": 4,\\n \\\"PerIpQps\\\": 80\\n },\\n \\\"Type\\\": \\\"ForwardGroup\\\",\\n \\\"CorsConfig\\\": {\\n \\\"AllowOrigin\\\": [\\n \\\"http://test.com\\\"\\n ],\\n \\\"AllowMethods\\\": [\\n \\\"GET\\\"\\n ],\\n \\\"AllowHeaders\\\": [\\n \\\"test_123\\\"\\n ],\\n \\\"ExposeHeaders\\\": [\\n \\\"test_123\\\"\\n ],\\n \\\"AllowCredentials\\\": \\\"on\\\",\\n \\\"MaxAge\\\": 1000\\n }\\n }\\n ],\\n \\\"RuleConditions\\\": [\\n {\\n \\\"CookieConfig\\\": {\\n \\\"Values\\\": [\\n {\\n \\\"Key\\\": \\\"test\\\",\\n \\\"Value\\\": \\\"test\\\"\\n }\\n ]\\n },\\n \\\"HeaderConfig\\\": {\\n \\\"Key\\\": \\\"Port\\\",\\n \\\"Values\\\": [\\n \\\"5006\\\"\\n ]\\n },\\n \\\"HostConfig\\\": {\\n \\\"Values\\\": [\\n \\\"www.example.com\\\"\\n ]\\n },\\n \\\"MethodConfig\\\": {\\n \\\"Values\\\": [\\n \\\"PUT\\\"\\n ]\\n },\\n \\\"PathConfig\\\": {\\n \\\"Values\\\": [\\n \\\"/test\\\"\\n ]\\n },\\n \\\"QueryStringConfig\\\": {\\n \\\"Values\\\": [\\n {\\n \\\"Key\\\": \\\"test\\\",\\n \\\"Value\\\": \\\"test\\\"\\n }\\n ]\\n },\\n \\\"SourceIpConfig\\\": {\\n \\\"Values\\\": [\\n \\\"192.168.XX.XX/32\\\"\\n ]\\n },\\n \\\"ResponseStatusCodeConfig\\\": {\\n \\\"Values\\\": [\\n \\\"200\\\"\\n ]\\n },\\n \\\"ResponseHeaderConfig\\\": {\\n \\\"Key\\\": \\\"key\\\",\\n \\\"Values\\\": [\\n \\\"value\\\"\\n ]\\n },\\n \\\"Type\\\": \\\"Host\\\"\\n }\\n ],\\n \\\"RuleId\\\": \\\"rule-bpn0kn908w4nbw****\\\",\\n \\\"RuleName\\\": \\\"rule-instance-test\\\",\\n \\\"RuleStatus\\\": \\\"Available\\\",\\n \\\"Direction\\\": \\\"Request\\\",\\n \\\"Tags\\\": [\\n {\\n \\\"Key\\\": \\\"env\\\",\\n \\\"Value\\\": \\\"product\\\"\\n }\\n ]\\n }\\n ],\\n \\\"TotalCount\\\": 1000\\n}\",\"errorExample\":\"\"},{\"type\":\"xml\",\"example\":\"<ListRulesResponse>\\n <MaxResults>50</MaxResults>\\n <NextToken>FFmyTO70tTpLG6I3FmYAXGKPd****</NextToken>\\n <RequestId>CEF72CEB-54B6-4AE8-B225-F876FF7BA984</RequestId>\\n <Rules>\\n <ListenerId>lsn-i35udpz3pxsmnf****</ListenerId>\\n <LoadBalancerId>alb-x30o38azsuj0sx****</LoadBalancerId>\\n <Priority>1</Priority>\\n <RuleActions>\\n <FixedResponseConfig>\\n <Content>dssacav</Content>\\n <ContentType>text/plain</ContentType>\\n <HttpCode>HTTP_2xx</HttpCode>\\n </FixedResponseConfig>\\n <ForwardGroupConfig>\\n <ServerGroupTuples>\\n <ServerGroupId>sg-atstuj3rtoptyui****</ServerGroupId>\\n <Weight>2</Weight>\\n </ServerGroupTuples>\\n </ForwardGroupConfig>\\n <InsertHeaderConfig>\\n <Key>key</Key>\\n <Value>ClientSrcPort</Value>\\n <ValueType>SystemDefined</ValueType>\\n </InsertHeaderConfig>\\n <Order>1</Order>\\n <RedirectConfig>\\n <Host>www.example.com</Host>\\n <HttpCode>301</HttpCode>\\n <Path>/test</Path>\\n <Port>10</Port>\\n <Protocol>HTTP</Protocol>\\n <Query>quert</Query>\\n </RedirectConfig>\\n <RewriteConfig>\\n <Host>www.example.com</Host>\\n <Path>/tsdf</Path>\\n <Query>quedsa</Query>\\n </RewriteConfig>\\n <TrafficMirrorConfig>\\n <MirrorGroupConfig>\\n <ServerGroupTuples>\\n <ServerGroupId>srg-00mkgijak0w4qgz9****</ServerGroupId>\\n <Weight>2</Weight>\\n </ServerGroupTuples>\\n </MirrorGroupConfig>\\n </TrafficMirrorConfig>\\n <TrafficLimitConfig>\\n <QPS>4</QPS>\\n <PerIpQps>80</PerIpQps>\\n </TrafficLimitConfig>\\n <Type>ForwardGroup</Type>\\n <CorsConfig>\\n <AllowOrigin>http://test.com</AllowOrigin>\\n <AllowMethods>GET</AllowMethods>\\n <AllowHeaders>test_123</AllowHeaders>\\n <ExposeHeaders>test_123</ExposeHeaders>\\n <AllowCredentials>on</AllowCredentials>\\n <MaxAge>1000</MaxAge>\\n </CorsConfig>\\n </RuleActions>\\n <RuleConditions>\\n <CookieConfig>\\n <Values>\\n <Key>test</Key>\\n <Value>test</Value>\\n </Values>\\n </CookieConfig>\\n <HeaderConfig>\\n <Key>Port</Key>\\n <Values>5006</Values>\\n </HeaderConfig>\\n <HostConfig>\\n <Values>www.example.com</Values>\\n </HostConfig>\\n <MethodConfig>\\n <Values>PUT</Values>\\n </MethodConfig>\\n <PathConfig>\\n <Values>/test</Values>\\n </PathConfig>\\n <QueryStringConfig>\\n <Values>\\n <Key>test</Key>\\n <Value>test</Value>\\n </Values>\\n </QueryStringConfig>\\n <SourceIpConfig>\\n <Values>192.168.XX.XX/32</Values>\\n </SourceIpConfig>\\n <Type>Host</Type>\\n </RuleConditions>\\n <RuleId>rule-bpn0kn908w4nbw****</RuleId>\\n <RuleName>rule-instance-test</RuleName>\\n <RuleStatus>Available</RuleStatus>\\n </Rules>\\n <TotalCount>1000</TotalCount>\\n</ListRulesResponse>\",\"errorExample\":\"\"}]", "title": "查询转发规则" } }, "endpoints": [ { "regionId": "cn-wulanchabu", "endpoint": "alb.cn-wulanchabu.aliyuncs.com" } ] } -
出站身份验证:选择上一步创建的AccessKey凭证。
-
函数计算
本示例接入一个数学计算Web函数。
添加函数计算类型的服务前,需在函数计算控制台创建并部署Web函数:
-
单击创建函数,函数类型选择Web 函数。输入函数名称,运行环境选择自定义运行时 > Python > Python 3.10(Debian 11),代码上传方式选择使用示例代码,启动命令为命令模式,填入
python app.py,单击创建。 -
在WebIDE中将示例代码替换为以下数学计算服务代码,将文件名改为
app.py,保存后单击部署代码。 -
单击界面右侧的复制 ARN,后续添加服务时需要使用。
提供数学计算功能的Web函数示例代码
from http.server import HTTPServer, BaseHTTPRequestHandler
import urllib
import json
class MathHandler(BaseHTTPRequestHandler):
def do_GET(self):
"""Handle GET request: /?a=10&b=5&op=add"""
params = urllib.parse.parse_qs(urllib.parse.urlparse(self.path).query)
try:
a = float(params.get('a', [0])[0])
b = float(params.get('b', [0])[0])
op = params.get('op', ['add'])[0]
# Perform calculation
if op == 'add':
result = a + b
elif op == 'sub':
result = a - b
elif op == 'mul':
result = a * b
elif op == 'div':
result = a / b
else:
raise ValueError(f"Unsupported operation: {op}")
response = {'result': result, 'message': f'{a} {op} {b} = {result}'}
self.send_response(200)
except (ValueError, ZeroDivisionError) as e:
response = {'error': str(e)}
self.send_response(400)
self.send_header('Content-type', 'application/json')
self.end_headers()
self.wfile.write(json.dumps(response).encode())
if __name__ == "__main__":
server = HTTPServer(('0.0.0.0', 9000), MathHandler)
print("Server running on http://localhost:9000")
server.serve_forever()完成准备后,返回MCP服务器组,单击添加MCP服务,完成以下配置后单击确定。
-
服务名称:输入易于大模型理解的名称,本文为
math-calculator,表示提供数学计算服务。 -
服务类型:选择函数计算。
-
函数计算ARN:输入已复制的函数ARN。
-
OpenAPI 配置:将以下OpenAPI配置文件粘贴或导入。
-
出站身份验证:选择RAM角色。
上述函数对应的OpenAPI配置
{
"openapi": "3.1.0",
"info": {
"title": "Math Calculator API",
"version": "1.0.0",
"description": "Math calculator supporting addition, subtraction, multiplication, and division"
},
"paths": {
"/": {
"get": {
"summary": "Math calculation",
"description": "Perform basic mathematical operations (addition, subtraction, multiplication, division)",
"operationId": "calculate",
"parameters": [
{
"name": "op",
"in": "query",
"required": true,
"description": "Operation type: add=addition, sub=subtraction, mul=multiplication, div=division",
"schema": {
"type": "string",
"enum": ["add", "sub", "mul", "div"]
}
},
{
"name": "a",
"in": "query",
"required": true,
"description": "First operand",
"schema": {
"type": "number"
}
},
{
"name": "b",
"in": "query",
"required": true,
"description": "Second operand",
"schema": {
"type": "number"
}
}
],
"responses": {
"200": {
"description": "Calculation successful",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"result": {
"type": "number",
"description": "Calculation result"
},
"message": {
"type": "string",
"description": "Calculation description"
}
}
}
}
}
}
}
}
}
}
}3.创建监听
-
在ALB控制台,单击目标实例ID进入实例详情页。在监听页签单击创建监听。
-
在配置监听步骤,选择监听协议为HTTPS,监听端口填写
443,完成后单击下一步。 -
在配置SSL证书步骤,选择与自定义域名匹配的服务器证书,单击下一步。
-
在选择服务器组步骤,依次选择服务器类型和服务器组
sgp-default,完成后单击下一步。此处选择的服务器组将用于监听的默认规则,即在请求未命中其他转发规则时处理请求。本文的MCP请求均通过转发规则精确匹配,不会命中该规则。
-
在配置审核步骤,确认配置并单击提交。
4.配置转发规则
请求按优先级数字从小到大依次匹配转发规则,匹配到某条规则后执行其转发动作,不再匹配后续规则。创建转发条件为路径的转发规则,将MCP协议相关请求路由至MCP类型服务器组。
-
在实例监听页签,单击目标监听ID。在监听详情页切换到转发规则页签。
-
单击插入新规则,完成以下配置后单击确定。
-
转发条件:选择路径,匹配方式选择精确匹配,输入
/mcp。 -
服务扩展(可选):使用模板快速创建,选择MCP认证代理,单击创建。输入服务扩展名称,选择启用语义搜索后单击创建。该模板会自动添加API Key认证组件并生成凭证。
-
转发动作:转发至
sgp-mcp服务器组。
-
-
在转发规则列表中单击刚创建的服务扩展ID进入详情页,在页面下方展开API Key认证组件,在凭证字段获取API Key,后续验证测试时需要使用。
5.设置域名解析
将自有域名通过CNAME解析指向ALB实例的DNS名称,客户端通过自有域名访问ALB。
本文以阿里云云解析DNS为例,对于非阿里云注册域名,需先将域名添加到云解析控制台。
6.验证测试
完成上述配置后,可通过以下方式验证MCP服务是否正常运行。
MCP Inspector调试
-
安装Node.js环境,执行以下命令启动MCP Inspector:
npx @modelcontextprotocol/inspector -
将Transport Type切换为Streamable HTTP,在URL字段填入ALB的MCP服务访问地址,如
https://mcp.example.com/mcp。展开Authentication,在Custom Headers中添加一条Header,名称为Authorization,值为Bearer <API Key凭证>(即步骤4中获取的凭证),并开启左侧开关。单击Connect,显示Connected表示连接成功。 -
单击List Tools可获取当前挂载的所有工具列表。分别验证各类型服务:
-
MCP服务器类型:选择温度换算工具
temperature-converter::celsius_to_fahrenheit,输入celsius为22,单击Run Tool,可获取转换结果为71.6华氏度。 -
函数计算类型:选择数学计算工具
math-calculator::calculate,选择op为add,a为10,b为5,单击Run Tool,可获取计算结果为15。 -
REST API类型:选择ALB管理工具
alb-operator::ListLoadBalancers,单击Run Tool,可获取目标账号下的ALB实例列表。 -
语义搜索:选择
x-aliyun-alb-search工具,可利用MCP代理组件内置的语义搜索能力搜索匹配的工具。例如输入query为查询负载均衡信息,topk为2,可返回现有工具中最匹配的两个工具,避免加载全量工具列表,节省LLM的Token消耗。
-
Agent测试
以下示例基于LangChain构建Agent,通过MCP代理组件的语义搜索能力动态检索并调用工具。
-
安装Python(3.10及以上版本)并安装依赖:
pip install "langchain>=1.2.4" "langchain-community>=0.4.1" "langchain-mcp-adapters>=0.2.1" "langchain-openai>=1.0.1" "langgraph>=1.0.1" -
保存以下代码为
agent.py:# -*- coding: utf-8 -*- import asyncio import os import httpx from langchain.agents import create_agent from langchain_openai import ChatOpenAI from mcp import ClientSession from mcp.client.streamable_http import streamable_http_client from mcp.types import Tool from langchain_mcp_adapters.tools import convert_mcp_tool_to_langchain_tool async def search_alb_tools(session: ClientSession, query: str, topk: int = 3) -> list: """Search for relevant tools via MCP protocol.""" result = await session.call_tool( "x-aliyun-alb-search", {"query": query, "topk": topk} ) payload = result.structuredContent or {} allowed_fields = {"name", "title", "description", "inputSchema"} mcp_tools = [ Tool(**{k: v for k, v in t.items() if k in allowed_fields and v}) for t in payload.get("tools", []) ] return [convert_mcp_tool_to_langchain_tool(session, t) for t in mcp_tools] class AlbChatAgent: def __init__(self, session: ClientSession, llm: ChatOpenAI): self.session = session self.llm = llm async def chat(self, user_query: str) -> None: print(f"\nUser: {user_query}") tools = await search_alb_tools(self.session, user_query) system_prompt = ( "You are an expert assistant. Only use the provided ALB tools to answer questions. " "If the tools are insufficient, clearly inform the user. Be concise and professional." ) agent = create_agent( model=self.llm, tools=tools, system_prompt=system_prompt ) try: response = await agent.ainvoke( {"messages": [{"role": "user", "content": user_query}]}, ) print(f"Assistant: {response['messages'][-1].content}") except Exception as e: print(f"Error: {type(e).__name__}: {str(e)}") async def main(): mcp_url = os.getenv("MCP_URL") mcp_api_key = os.getenv("MCP_API_KEY") qwen_api_key = os.getenv("QWEN_API_KEY") if not mcp_url: raise EnvironmentError("Environment variable not set: MCP_URL") if not mcp_api_key: raise EnvironmentError("Environment variable not set: MCP_API_KEY") if not qwen_api_key: raise EnvironmentError("Environment variable not set: QWEN_API_KEY") async with httpx.AsyncClient( headers={"Authorization": f"Bearer {mcp_api_key}"}, timeout=httpx.Timeout(60, read=300), ) as http_client: async with streamable_http_client( mcp_url, http_client=http_client, ) as (reader, writer, _): async with ClientSession(reader, writer) as session: await session.initialize() llm = ChatOpenAI( model="qwen-plus", api_key=qwen_api_key, base_url="https://dashscope.aliyuncs.com/compatible-mode/v1" ) agent = AlbChatAgent(session, llm) while True: try: query = input("\n>>> ").strip() if query: await agent.chat(query) except (KeyboardInterrupt, EOFError): break if __name__ == "__main__": asyncio.run(main()) -
设置以下环境变量并运行:
-
MCP_URL:ALB实例的MCP服务访问地址,本文中为https://mcp.example.com/mcp -
MCP_API_KEY:步骤4中生成的API Key凭证。
Linux/macOS
export MCP_URL=https://mcp.example.com/mcp export MCP_API_KEY=your_api_key export QWEN_API_KEY=sk-xxx python agent.pyWindows
$env:MCP_URL="https://mcp.example.com/mcp" $env:MCP_API_KEY="your_api_key" $env:QWEN_API_KEY="sk-xxx" python agent.py -
-
运行后通过自然语言输入问题,Agent会通过
x-aliyun-alb-search检索匹配的工具并调用。>>> 帮我换算下22摄氏度是多少华氏度 User: 帮我换算下22摄氏度是多少华氏度 Assistant: 22摄氏度等于71.6华氏度。 >>> 帮我计算下22 * 33是多少 User: 帮我计算下22 * 33是多少 Assistant: 22 × 33 = 726 >>> 帮我列举出当前的ALB实例 User: 帮我列举出当前的ALB实例 Assistant: 当前共有2个ALB实例,详情如下: | 实例ID | 名称 | 地址类型 | 状态 | |--------|------|----------|------| | alb-xxxx1 | my-alb-1 | Internet | Active | | alb-xxxx2 | my-alb-2 | Intranet | Active |
更多信息
计费说明
ALB扩展版支持的地域
|
区域 |
地域 |
可用区 |
|
中国 |
华北6(乌兰察布) |
可用区A、可用区B、可用区C |
|
华东1(杭州) |
可用区J、可用区K |
|
|
华北2(北京) |
可用区I、可用区K、可用区L |
|
|
华东2(上海) |
可用区B、可用区F |
|
|
中国香港 |
可用区B、可用区C、可用区D |
|
|
亚太 |
新加坡 |
可用区A、可用区B、可用区C |
|
日本(东京) |
可用区B、可用区C、可用区E |
|
|
马来西亚(吉隆坡) |
可用区A、可用区B、可用区C |
|
|
欧洲与美洲 |
德国(法兰克福) |
可用区A、可用区B |
|
美国(硅谷) |
可用区A、可用区B |
|
|
中东 |
阿联酋(迪拜) |
可用区A、可用区B |
使用建议
-
工具列表获取策略:工具数量较少时,可直接调用
tools/list获取完整列表;工具数量较多时,建议使用x-aliyun-alb-search语义搜索匹配相关工具,减少Token消耗。 -
工具描述优化:OpenAPI配置中的工具描述直接影响语义搜索的匹配准确率。建议用自然语言准确描述每个工具的用途,必要时可借助LLM优化描述文本。
-
内网域名解析:ALB扩展版通过公网DNS解析MCP服务器地址。若MCP服务器部署在VPC内网,需在公网DNS中将域名解析到对应的私网IP,并确保ALB与该服务器网络互通。
-
安全性:API Key应避免硬编码在客户端代码中,推荐通过环境变量或密钥管理服务管理。
常见问题
MCP服务器连接超时,报错upstream connect error或connection timeout
-
确保ALB到MCP服务器网络可达。
-
MCP 服务部署在 VPC 内:确保ALB实例能通过私网访问MCP服务。同VPC内默认互通;跨VPC或跨地域场景需通过云企业网等产品打通私网。同时确保安全组规则允许ALB访问MCP服务端口。
-
MCP服务部署在公网:确保ALB实例所在交换机已经正确配置公网SNAT。
-
-
确认已在公网DNS上正确配置域名解析。
-
确认MCP服务器进程已启动并监听在预期端口。
语义搜索未返回预期的工具
-
检查工具描述是否足够准确,语义搜索依赖描述与查询的语义相似度。
-
适当增大
topk参数的值,扩大返回的候选工具数量。
函数计算类型的服务添加后无法调用
-
确认OpenAPI配置文件格式正确,且接口路径和参数与函数的实际行为一致。
-
确认代码已成功部署到函数计算服务。