CreateListener - 创建监听

在网络型负载均衡实例中创建TCP、UDPTCPSSL监听。

调试

您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。

调试

授权信息

下表是API对应的授权信息,可以在RAM权限策略语句的Action元素中使用,用来给RAM用户或RAM角色授予调用此API的权限。具体说明如下:

  • 操作:是指具体的权限点。

  • 访问级别:是指每个操作的访问级别,取值为写入(Write)、读取(Read)或列出(List)。

  • 资源类型:是指操作中支持授权的资源类型。具体说明如下:

    • 对于必选的资源类型,用前面加 * 表示。

    • 对于不支持资源级授权的操作,用全部资源表示。

  • 条件关键字:是指云产品自身定义的条件关键字。

  • 关联操作:是指成功执行操作所需要的其他权限。操作者必须同时具备关联操作的权限,操作才能成功。

操作

访问级别

资源类型

条件关键字

关联操作

nlb:CreateListener

create

*ServerGroup

acs:nlb:{#regionId}:{#accountId}:servergroup/{#ServerGroupId}

SecurityPolicy

acs:nlb:{#regionId}:{#accountId}:securitypolicy/{#SecurityPolicyId}

*LoadBalancer

acs:nlb:{#regionId}:{#accountId}:loadbalancer/{#LoadbalancerId}

nlb:ListenerProtocol
nlb:SecurityPolicyId

请求参数

名称

类型

必填

描述

示例值

ListenerProtocol

string

监听协议。取值:TCPUDPTCPSSL

TCP

ListenerPort

integer

监听端口。取值范围:0~65535

0:表示使用全端口功能。当设置为 0 时,您需要配置 StartPortEndPort

80

ListenerDescription

string

自定义监听名称。

长度限制为 2~256 个字符,支持中文和英文字母,可包含数字、半角逗号(,)、半角句号(.)、半角分号(;)、正斜线(/)、at(@)、下划线(_)和短划线(-)。

tcp_80

LoadBalancerId

string

网络型负载均衡实例 ID。

nlb-83ckzc8d4xlp8o****

ServerGroupId

string

服务器组 ID。

说明
  • ListenerProtocol 取值为 TCP 时,该监听支持选择后端协议为 TCP 或者TCP_UDP的服务器组,不支持选择后端协议为 UDP 的服务器组。

  • ListenerProtocol 取值为 UDP 时,该监听支持选择后端协议为 UDP 或者TCP_UDP的服务器组,不支持选择后端协议为 TCP 的服务器组。

  • ListenerProtocol 取值为 TCPSSL 时,该监听支持选择后端协议为 TCP未开启客户端地址保持功能的服务器组,不支持选择后端协议为 TCP开启客户端地址保持功能的服务器组、后端协议为 UDP 或者TCP_UDP的服务器组。

sgp-ppdpc14gdm3x4o****

IdleTimeout

integer

连接空闲超时时间。单位:秒。

  • ListenerProtocol 取值为 TCPTCPSSL 时,连接空闲超时时间取值范围为:10~900。默认值:900

  • ListenerProtocol 取值为 UDP 时,连接空闲超时时间取值范围为:10~90。默认值:90

900

SecurityPolicyId

string

安全策略 ID。支持系统安全策略和自定义安全策略。

  • 系统策略取值:tls_cipher_policy_1_0(默认值)、tls_cipher_policy_1_1tls_cipher_policy_1_2tls_cipher_policy_1_2_stricttls_cipher_policy_1_2_strict_with_1_3

  • 自定义安全策略:输入自定义安全策略 ID。
说明

仅对 TCPSSL 监听生效。

tls_cipher_policy_1_0

CertificateIds

array

服务器证书列表信息。仅对 TCPSSL 监听生效。

说明

目前仅支持添加 1 个服务器证书。

string

服务器证书列表信息。仅对 TCPSSL 监听生效。

说明

目前仅支持添加 1 个服务器证书。

123157******

CaCertificateIds

array

CA 证书列表。仅对 TCPSSL 监听生效。

说明

目前仅支持添加 1 个 CA 证书。

string

CA 证书列表。仅对 TCPSSL 监听生效。

说明

目前仅支持添加 1 个 CA 证书。

139a00******

CaEnabled

boolean

是否启动双向认证。取值:

  • true:启动。

  • false(默认值):关闭。

false

DryRun

boolean

是否只预检此次请求。取值:

  • true:发送检查请求,不会创建监听。检查项包括是否填写了必需参数、请求格式、业务限制。如果检查不通过,则返回对应错误。如果检查通过,则返回错误码DryRunOperation

  • false(默认值):发送正常请求,通过检查后返回 HTTP 2xx 状态码并直接进行操作。

false

ClientToken

string

客户端 Token,用于保证请求的幂等性。

从您的客户端生成一个参数值,确保不同请求间该参数值唯一。ClientToken 只支持 ASCII 字符。

说明

若您未指定,则系统自动使用 API 请求的 RequestId 作为 ClientToken 标识。每次 API 请求的 RequestId 不一样。

123e4567-e89b-12d3-a456-426655440000

RegionId

string

网络型负载均衡实例所在的地域 ID。

您可以通过调用 DescribeRegions 接口获取地域 ID。

cn-hangzhou

ProxyProtocolEnabled

boolean

是否开启通过 Proxy Protocol 协议携带客户端源地址到后端服务器。取值:

  • true:开启。

  • false(默认值):关闭。

false

SecSensorEnabled

boolean

是否开启秒级监控功能。取值:

  • true:开启。

  • false(默认值):关闭。

false

AlpnEnabled

boolean

是否开启 ALPN。取值:

  • true:开启。

  • false(默认值):关闭。

false

AlpnPolicy

string

ALPN 策略。取值:

  • HTTP1Only:只协商使用 HTTP1.x 协议,优先级为 HTTP1.1>HTTP1.0。

  • HTTP2Only:只协商使用 HTTP2.0 协议。

  • HTTP2Optional:优先使用 HTTP1.x 协议,但也接受 HTTP2.0 协议,优先级为 HTTP1.1>HTTP1.0>HTTP2.0。

  • HTTP2Preferred:优先使用 HTTP2.0 协议,但也接受 HTTP1.x 协议,优先级为 HTTP2.0>HTTP1.1>HTTP1.0。

说明

AlpnEnabled 开启后需配置该参数。

HTTP1Only

StartPort

integer

全端口监听起始端口。取值范围:1 ~ 65535

说明

ListenerPort0 时,需要配置该参数。

244

EndPort

integer

全端口监听结束端口。取值范围:1 ~ 65535。 终止端口的取值大于起始端口。

说明

ListenerPort0 时,需要配置该参数。

566

Cps

integer

该监听在每个可用区(VIP)处理的每秒新建连接限速值。取值范围:0~10000000 表示不限速。

100

Mss

integer

TCP 报文的最大段大小。单位:字节,取值范围:0~15000:表示不修改用户 TCP 报文的 MSS 值。

说明

仅 TCP、TCPSSL 类型的监听支持该字段值。

43

Tag

array<object>

标签列表。

object

标签。

Key

string

标签键。最多支持 64 个字符,不能以aliyunacs:开头,不能包含http://https://。支持字符包括字母、数字、下划线 (_)、点 (.)、冒号 (:)、斜线 (/)、等号 (=)、加号 (+)、减号 (-)、@符号 (@) 。

一次调用最多支持添加 20 个标签。

KeyTest

Value

string

标签值。最多支持 128 个字符,不能以aliyunacs:开头,不能包含http://https://。支持字符包括字母、数字、下划线 (_)、点 (.)、冒号 (:)、斜线 (/)、等号 (=)、加号 (+)、减号 (-)、@符号 (@) 。

一次调用最多支持添加 20 个标签。

Test

ProxyProtocolV2Config

object

通过 Proxy Protocol 协议携带 VpcId、PrivateLinkEpId、PrivateLinkEpsId 信息到后端服务器配置。

Ppv2VpcIdEnabled

boolean

是否开启通过 Proxy Protocol 协议携带 VpcId 到后端服务器。取值:

  • true:开启。

  • false(默认值):关闭。

false

Ppv2PrivateLinkEpIdEnabled

boolean

是否开启通过 Proxy Protocol 协议携带 Ppv2PrivateLinkEpId 到后端服务器。取值:

  • true:开启。

  • false(默认值):关闭。

false

Ppv2PrivateLinkEpsIdEnabled

boolean

是否开启通过 Proxy Protocol 协议携带 PrivateLinkEpsId 到后端服务器。取值:

  • true:开启。

  • false(默认值):关闭。

false

返回参数

名称

类型

描述

示例值

object

RpcResponse

RequestId

string

请求 ID。

CEF72CEB-54B6-4AE8-B225-F876FF7BA984

ListenerId

string

监听 ID。

lsn-bp1bpn0kn908w4nbw****@80

JobId

string

异步任务 ID。

72dcd26b-f12d-4c27-b3af-18f6aed5****

示例

正常返回示例

JSON格式

{
  "RequestId": "CEF72CEB-54B6-4AE8-B225-F876FF7BA984",
  "ListenerId": "lsn-bp1bpn0kn908w4nbw****@80",
  "JobId": "72dcd26b-f12d-4c27-b3af-18f6aed5****"
}

错误码

HTTP status code

错误码

错误信息

描述

400 Conflict.Port The Port [%s] is conflict. 指定端口与已有端口存在冲突
400 IllegalParam.MssConflictWithUdpAndGeneve The param of MssConflictWithUdpAndGeneve is illegal. Mss值不为null时,listenerProtocol不可以是udp或者GENEVE。
400 QuotaExceeded.%s The quota of %s is exceeded, usage %s/%s. %s的配额超过限制,已使用%s/%s
400 SystemBusy System is busy, please try again later. 系统繁忙,请稍后重试
400 Mismatch.VpcId The VpcId is mismatched for %s and %s. 资源%s和资源%sVpcId不匹配。请检查两种资源是否在同一个VPC下。
400 ResourceNotEnough.%s The specified resource of %s is not enough. 所需要的资源%s不足了
400 Conflict.Lock The Lock [%s] is conflict. 指定的资源当前存在锁冲突。
400 IllegalParam.AnyPortListenerConflictWithNonAnyPortServerGroup The param of AnyPortListenerConflictWithNonAnyPortServerGroup is illegal. servergroup的全端口转发开关,必须匹配与监听的anyport开关匹配,请检查参数。
400 IncorrectStatus.loadbalancer The status of loadbalancer [%s] is incorrect. 负载均衡的状态无法进行当前操作,请检查负载均衡当前是否处于其他操作下。
400 ResourceNotFound.Certificate The specified resource %s is not found. 资源%s不存在。
400 IllegalParam.ServerGroupId The param of ServerGroupId is illegal. 参数ServerGroupId非法,请检查输入参数。
400 IllegalParam.NonAnyPortListenerConflictWithAnyPortServerGroup The param of NonAnyPortListenerConflictWithAnyPortServerGroup is illegal. 监听端口配置与全端口转发开关冲突。
400 MissingParam.Certificate The param of certificate is missing. 参数Certificate缺失。
400 IllegalParam.Port The param of Port is illegal. 请求中的端口范围非法,请检查输入参数。
400 QuotaExceeded.QuotaInsufficient The quota of %s is exceeded, usage %s/%s. 配额不足,已使用%s/%s。请在配额中心中修改配额大小。
400 Mismatch.Protocol The Protocol is mismatched for %s and %s. 监听和服务器组的协议不匹配。
400 ResourceNotEnough.CaCertificateApiCount The specified resource of CaCertificateApiCount is not enough.
400 MissingParam.ServerGroupId The param of ServerGroupId is missing. 参数ServerGroupId缺失,请检查输入参数。
400 IllegalParam.ListenerDescription The parameter ListenerDescription of listener is illegal. 监听描述不符合输入要求,请根据错误中的详细信息进行修改。
400 DryRunOperation Request validation has been passed with DryRun flag set. dryRun请求验证已通过。
400 IllegalParam.IdleTimeout The param of IdleTimeout is illegal. 参数连接空闲超时时间配置非法。
400 MissingParam.%s The parameter of %s is missing. 参数%s缺失,请检查输入参数。
400 IllegalParam The param of %s is illegal. 输入的参数有值非法,请检查输入。
400 IllegalParamSize.certificateIds The param size of certificateIds or caCertificateIds is illegal. 证书的id只能有一个,请检查是否重复输入。
400 DuplicatedParam.listener The param of any port listener is duplicated. 只能创建一个anyport类型监听,请检查输入参数。
400 IllegalParam.PreserveClientIpSwitch The server group associated with the tcpssl listener does not support enabling PreserveClientIp. tcpssl监听关联的服务器组不支持开启客户端ip保持功能
400 OperationDenied.RegionNotSupportHDMonitor The operation is not allowed because of RegionNotSupportHDMonitor. 当前区域不支持秒级监控。
403 Forbidden.NoPermission Authentication is failed for NoPermission. 因为账号没有权限,所以鉴权失败。
404 ResourceNotFound.VSwitch The specified resource of vSwitch is not found. 找不到指定的虚拟交换机资源,请检查输入参数。
404 ResourceNotFound.loadBalancer The specified resource of loadbalancer is not found. 找不到指定的负载均衡器资源,请检查输入参数。
404 ResourceNotFound.serverGroup The specified resource of serverGroup is not found. 找不到指定的服务器组资源,请检查输入参数。
404 ResourceNotFound.CaCertificate The specified resource of CaCertificate is not found. Ca证书不存在,请检查输入参数。
404 ResourceNotFound.HdMonitorConfigNotExist The specified resource of HdMonitorConfigNotExist is not found. HdMonitorConfig 不存在,请检查输入参数。

访问错误中心查看更多错误码。

变更历史

更多信息,参考变更详情