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

添加监听器

最近更新时间2023.07.03 16:32:37

首次发布时间2022.02.25 18:58:31

本接口用于为负载均衡实例添加监听器。

接口说明

前提条件:

  • 后端服务器类型为边缘实例时,负载均衡实例所绑定的节点下需存在边缘实例。

使用限制:

  • 一个负载均衡实例下,最多可创建 20 个监听器。
  • 后端服务器为边缘实例时,一个监听器最多支持 20 个后端服务器。

请求方法

POST

请求参数

下表列出了接口特定的请求参数以及公共请求参数 Action 和 Version。 其他公共参数,请参见公共参数

名称

类型

是否必选

示例值

描述

Action

String

AddLBListener

公共参数。该参数表示接口名称。取值:AddLBListener。

Version

String

2021-04-30

公共参数。该参数表示接口版本。取值:2021-04-30。

lb_identity

String

veew-lb2131011027612112****

负载均衡实例的 ID。您可以通过 ListLBs 接口查询负载均衡实例的 ID。

name

String

listener-1

监听器的名称。命名规则如下:

  • 允许 5~20 个字符。
  • 支持中文、大写字母、小写字母、数字。
  • 支持特殊字符 ()`~!@#$%^&*-+=_|{}[]:;'<>,.?/。
  • 不能包含双引号(")、反斜线( \)和 空格,且不能以正斜线(/)开头。

listen_port_protocol

String

TCP

监听协议,也称前端协议:

  • TCP
  • UDP

listen_port

Integer

80

监听端口,也称前端端口。取值范围:1~65535。

loadbalance_strategy

String

sip

负载均衡策略。取值范围:

  • sip:源IP一致性哈希。
  • sip+sport:源IP+源端口一致性哈希。

endpoints

[]EndpointReq

[
  {
    "endpoint_identity": "veen1128038002028****",
    "endpoint_type": "veen",
    "port": 80,
    "weight": 10
  }
]

后端服务器列表。
说明:
添加的后端服务器的公网类型需与负载均衡实例的公网类型一致。

health_check

HealthCheck

{
  "failure_threshold": 2,
  "http_host": "",
  "http_path": "",
  "http_success_codes": "",
  "period": 10,
  "port": 80,
  "protocol": "TCP",
  "success_threshold": 2,
  "timeout": 10,
  "udp_check_string": "",
  "use_endpoint_port": false
}

健康检查配置。
当您配置了 health_check 参数后,健康检查功能同步开启。

desc

String

This is a test

监听器的描述。最多可输入 80 个字符。

default_endpoint_port

Integer

80

默认后端端口。默认值:与前端端口相同。取值范围:1~65535。
如需为单个后端服务器配置其他端口,请通过 endpoints 参数进行配置。

返回数据


请求示例

POST https://veenedge.volcengineapi.com/?Action=AddLBListener&Version=2021-04-30
&<其他公共参数>
{
  "lb_identity": "veew-lb2063021453005555****",
  "name": "listener-1",
  "listen_port_protocol": "TCP",
  "listen_port": 80,
  "loadbalance_strategy": "sip",
  "endpoints": [
    {
      "endpoint_identity": "veen8580100583220550****",
      "endpoint_type": "veen",
      "port": 80
    }
  ],
  "health_check": {
    "failure_threshold": 2,
    "port": 80,
    "period": 10,
    "protocol": "TCP",
    "success_threshold": 2,
    "timeout": 10,
    "use_endpoint_port": false
  }
}

返回示例

{
    "ResponseMetadata": {
        "RequestId": "202305311418124563864534F61CAB****",
        "Action": "AddLBListener",
        "Version": "2021-04-30",
        "Service": "veenedge",
        "Region": "cn-north-1"
    }
}

错误码

如果响应正文中包含 Error 字段,则表示 API 请求失败。关于错误码的更多信息,参见错误码