在网络型负载均衡实例中创建TCP、UDP或TCPSSL监听。
调试
您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。

授权信息
操作 |
访问级别 |
资源类型 |
条件关键字 |
关联操作 |
nlb:CreateListener |
create |
*ServerGroup
SecurityPolicy
*LoadBalancer
|
nlb:ListenerProtocol
nlb:SecurityPolicyId
|
无 |
请求参数
名称 |
类型 |
必填 |
描述 |
示例值 |
ListenerProtocol |
string |
是 |
监听协议。取值:TCP、UDP 或 TCPSSL。 |
TCP |
ListenerPort |
integer |
是 |
监听端口。取值范围:0~65535。 0:表示使用全端口功能。当设置为 0 时,您需要配置 StartPort 和 EndPort。 |
80 |
ListenerDescription |
string |
否 |
自定义监听名称。 长度限制为 2~256 个字符,支持中文和英文字母,可包含数字、半角逗号(,)、半角句号(.)、半角分号(;)、正斜线(/)、at(@)、下划线(_)和短划线(-)。 |
tcp_80 |
LoadBalancerId |
string |
是 |
网络型负载均衡实例 ID。 |
nlb-83ckzc8d4xlp8o**** |
ServerGroupId |
string |
是 |
服务器组 ID。 说明
|
sgp-ppdpc14gdm3x4o**** |
IdleTimeout |
integer |
否 |
连接空闲超时时间。单位:秒。
|
900 |
SecurityPolicyId |
string |
否 |
安全策略 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 |
否 |
是否启动双向认证。取值:
|
false |
DryRun |
boolean |
否 |
是否只预检此次请求。取值:
|
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 协议携带客户端源地址到后端服务器。取值:
|
false |
SecSensorEnabled |
boolean |
否 |
是否开启秒级监控功能。取值:
|
false |
AlpnEnabled |
boolean |
否 |
是否开启 ALPN。取值:
|
false |
AlpnPolicy |
string |
否 |
ALPN 策略。取值:
说明
AlpnEnabled 开启后需配置该参数。 |
HTTP1Only |
StartPort |
integer |
否 |
全端口监听起始端口。取值范围:1 ~ 65535。 说明
当 ListenerPort 为 0 时,需要配置该参数。 |
244 |
EndPort |
integer |
否 |
全端口监听结束端口。取值范围:1 ~ 65535。 终止端口的取值大于起始端口。 说明
当 ListenerPort 为 0 时,需要配置该参数。 |
566 |
Cps |
integer |
否 |
该监听在每个可用区(VIP)处理的每秒新建连接限速值。取值范围:0~1000000。0 表示不限速。 |
100 |
Mss |
integer |
否 |
TCP 报文的最大段大小。单位:字节,取值范围:0~1500。 0:表示不修改用户 TCP 报文的 MSS 值。 说明
仅 TCP、TCPSSL 类型的监听支持该字段值。 |
43 |
Tag |
array<object> |
否 |
标签列表。 |
|
object |
否 |
标签。 |
||
Key |
string |
否 |
标签键。最多支持 64 个字符,不能以 一次调用最多支持添加 20 个标签。 |
KeyTest |
Value |
string |
否 |
标签值。最多支持 128 个字符,不能以 一次调用最多支持添加 20 个标签。 |
Test |
ProxyProtocolV2Config |
object |
否 |
通过 Proxy Protocol 协议携带 VpcId、PrivateLinkEpId、PrivateLinkEpsId 信息到后端服务器配置。 |
|
Ppv2VpcIdEnabled |
boolean |
否 |
是否开启通过 Proxy Protocol 协议携带 VpcId 到后端服务器。取值:
|
false |
Ppv2PrivateLinkEpIdEnabled |
boolean |
否 |
是否开启通过 Proxy Protocol 协议携带 Ppv2PrivateLinkEpId 到后端服务器。取值:
|
false |
Ppv2PrivateLinkEpsIdEnabled |
boolean |
否 |
是否开启通过 Proxy Protocol 协议携带 PrivateLinkEpsId 到后端服务器。取值:
|
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和资源%s的VpcId不匹配。请检查两种资源是否在同一个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 不存在,请检查输入参数。 |
访问错误中心查看更多错误码。
变更历史
更多信息,参考变更详情。