调用CreateLoadBalancerHTTPListener接口为传统型负载均衡创建HTTP监听。
注意事项
新建的监听的状态为stopped。创建完成后,调用StartLoadBalancerListener接口启动监听来转发流量。
前提条件
您已经创建传统型负载均衡,具体操作,请参见CreateLoadBalancer。
调试
您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。
请求参数
名称 | 类型 | 是否必选 | 示例值 | 描述 |
---|---|---|---|---|
RegionId | String | 否 | cn-hangzhou |
传统型负载均衡实例的地域ID。 您可以从地域和可用区列表或通过调用DescribeRegions接口获取地域ID。 |
Action | String | 是 | CreateLoadBalancerHTTPListener |
系统规定参数。取值:CreateLoadBalancerHTTPListener。 |
LoadBalancerId | String | 是 | lb-bp1c9vixxjh92q83tw***** |
传统型负载均衡实例ID。 |
Bandwidth | Integer | 否 | -1 |
监听的带宽峰值,单位:Mbps。取值:
说明 该参数只适用于中国内地。
|
ListenerPort | Integer | 是 | 80 |
实例前端使用的端口。 取值:1~65535。 |
BackendServerPort | Integer | 否 | 80 |
实例后端使用的端口。 取值:1~65535。 说明 如果不使用服务器组(不指定VServerGroupId参数),则该参数必选。
|
XForwardedFor | String | 否 | on |
是否开启通过
|
Scheduler | String | 否 | wrr |
调度算法。取值:
|
StickySession | String | 是 | off |
是否开启会话保持。取值:
|
StickySessionType | String | 否 | insert |
Cookie处理方式。取值:
|
CookieTimeout | Integer | 否 | 500 |
Cookie超时时间。单位:秒。 取值:1~86400。 说明 当StickySession为on且StickySessionType为insert时,该参数必选。
|
Cookie | String | 否 | B490B5EBF6F3CD402E515D22BCDA1598 |
服务器上配置的Cookie。 长度为1~200个字符,只能包含ASCII英文字母和数字字符,不能包含半角逗号(,)、半角分号(;)或空格,也不能以美元符号($)开头。 说明 当StickySession为on且StickySessionType为server时,该参数必选。
|
HealthCheck | String | 是 | on |
是否开启健康检查。取值:
|
HealthCheckMethod | String | 否 | get |
监听HTTP类型健康检查的健康检查方法。取值:head或get。 说明 HealthCheck值为on时才会有效。
|
HealthCheckDomain | String | 否 | 172.16.0.0/12 |
用于健康检查的域名,取值:
说明 在HealthCheck值为on时才会有效。
|
HealthCheckURI | String | 否 | /test/index.html |
用于健康检查的URI。 长度限制为1~80个字符,只能使用字母、数字和短划线(-)、正斜线(/)、半角句号(.)、百分号(%)、半角问号(?)、井号(#)和and(&)这些字符。URI不能只为正斜线(/),但必须以正斜线(/)开头。 说明 在HealthCheck值为on时才会有效。
|
HealthyThreshold | Integer | 否 | 4 |
健康检查连续成功多少次后,将后端服务器的健康检查状态由失败判定为成功。 取值:2~10。 说明 在HealthCheck值为on时才会有效。
|
UnhealthyThreshold | Integer | 否 | 4 |
健康检查连续失败多少次后,将后端服务器的健康检查状态由成功判定为失败。 取值:2~10。 说明 在HealthCheck值为on时才会有效。
|
HealthCheckTimeout | Integer | 否 | 3 |
接收来自运行状况检查的响应需要等待的时间。如果后端ECS在指定的时间内没有正确响应,则判定为健康检查失败。单位:秒。 取值:1~300。 说明
|
HealthCheckConnectPort | Integer | 否 | 80 |
健康检查的后端服务器的端口。 取值: 1~65535。 说明 在HealthCheck值为on时才会有效。
|
HealthCheckInterval | Integer | 否 | 5 |
健康检查的时间间隔。单位:秒。 取值: 1~50。 说明 在HealthCheck值为on时才会有效。
|
HealthCheckHttpCode | String | 否 | http_2xx |
健康检查正常的HTTP状态码,多个状态码用逗号分隔。 取值:http_2xx(默认值)、http_3xx、http_4xx或http_5xx。 说明 在HealthCheck值为on时才会有效。
|
VServerGroupId | String | 否 | rsp-cige6j***** |
虚拟服务器组ID。 |
XForwardedFor_SLBIP | String | 否 | on |
是否通过
|
XForwardedFor_SLBID | String | 否 | on |
是否通过
|
XForwardedFor_proto | String | 否 | on |
是否通过
|
Gzip | String | 否 | on |
是否开启
|
AclId | String | 否 | 123 |
监听绑定的访问策略组ID。 说明 当AclStatus参数的值为on时,该参数必选。
|
AclType | String | 否 | white |
访问控制类型。取值:
说明 当AclStatus参数的值为on时,该参数有效。
|
AclStatus | String | 否 | off |
是否开启访问控制功能。取值:
|
Description | String | 否 | HTTP_443 |
自定义监听名称。 长度限制为1~256个字符,支持中文、字母、数字、短划线(-)、正斜线(/)、半角句号(.)和下划线(_)。 |
ListenerForward | String | 否 | off |
是否开启HTTP至HTTPS的转发。取值:
|
ForwardPort | Integer | 否 | 443 |
HTTP至HTTPS的监听转发端口。 |
IdleTimeout | Integer | 否 | 3 |
指定连接空闲超时时间。单位:秒。 默认值为15,取值范围:1~60。 在超时时间内一直没有访问请求,负载均衡会暂时中断当前连接,直到一下次请求来临时重新建立新的连接。 |
RequestTimeout | Integer | 否 | 6 |
指定请求超时时间。单位:秒。 默认值为60,取值范围为1~180。 在超时时间内后端服务器一直没有响应,负载均衡将放弃等待,给客户端返回 |
返回数据
名称 | 类型 | 示例值 | 描述 |
---|---|---|---|
RequestId | String | CEF72CEB-54B6-4AE8-B225-F876FF7BA984 |
请求ID。 |
示例
请求示例
http(s)://[Endpoint]/?RegionId=cn-hangzhou
&Action=CreateLoadBalancerHTTPListener
&LoadBalancerId=lb-bp1c9vixxjh92q83tw*****
&Bandwidth=-1
&ListenerPort=80
&BackendServerPort=80
&XForwardedFor=on
&Scheduler=wrr
&StickySession=off
&StickySessionType=insert
&CookieTimeout=500
&Cookie=B490B5EBF6F3CD402E515D22BCDA1598
&HealthCheck=on
&HealthCheckMethod=get
&HealthCheckDomain=172.16.0.0/12
&HealthCheckURI=/test/index.html
&HealthyThreshold=4
&UnhealthyThreshold=4
&HealthCheckTimeout=3
&HealthCheckConnectPort=80
&HealthCheckInterval=5
&HealthCheckHttpCode=http_2xx
&VServerGroupId=rsp-cige6j*****
&XForwardedFor_SLBIP=on
&XForwardedFor_SLBID=on
&XForwardedFor_proto=on
&Gzip=on
&AclId=123
&AclType=white
&AclStatus=off
&Description=HTTP_443
&ListenerForward=off
&ForwardPort=443
&IdleTimeout=3
&RequestTimeout=6
&公共请求参数
正常返回示例
XML
格式
HTTP/1.1 200 OK
Content-Type:application/xml
<CreateLoadBalancerHTTPListenerResponse>
<RequestId>CEF72CEB-54B6-4AE8-B225-F876FF7BA984</RequestId>
</CreateLoadBalancerHTTPListenerResponse>
JSON
格式
HTTP/1.1 200 OK
Content-Type:application/json
{
"RequestId" : "CEF72CEB-54B6-4AE8-B225-F876FF7BA984"
}
错误码
HttpCode | 错误码 | 错误信息 | 描述 |
---|---|---|---|
400 | InvalidParameter.RegionNotSupport | The region does not support the parameter: %s. | 当前区域不支持指定参数。 |
400 | IpVersionConflict | The ip version of this LoadBalancer and the Acl is conflict. | 指定负载均衡的IP版本与ACL支持的IP类型冲突。 |
400 | InvalidParameter | The specified ListenerPort or ForwardPort is invalid. | 指定的ListenerPort or ForwardPort无效。请检查参数约束,并在修改后重试。 |
400 | ListenerForwardNotSupport | X-Forward-For is not supported to a ipv6 instance. | Ipv6负载均衡实例不支持X-Forward-For。 |
400 | InvalidParameter.IdleTimeout | The specified IdleTimeout exceeds the limit. | 指定的IdleTimeout无效。请检查参数约束,并在修改后重试。 |
400 | InvalidParameter.RequestTimeout | The specified RequestTimeout exceeds the limit. | 指定的RequestTimeout无效。请检查参数约束,并在修改后重试。 |
400 | ListenerProcessing | A previous configuration of the listener is pending,please try again later. | 当前监听正在配置中,请稍后重试。 |
400 | InvalidParameter.ListenerPortConflict | There is conflict listener port exists. | 指定的监听端口已存在。 |
400 | ResourceNotAvailible.HttpListener | The specified Zone did not have enough resource. | 指定可用区资源不足。 |
400 | AclNotExist | Acl does not exist. | 指定的Acl不存在。 |
400 | OperationUnsupported.CreateLoadBalancerLayer7Listener | The slb instance does not support create HTTP or HTTPS listener. | 当前负载均衡实例不支持创建HTTP或者HTTPS类型的监听。 |
400 | InvalidParameter.VServerGroupId | The MasterSlaveServerGroup can not be attached to HTTP or HTTPS listener. | HTTP或HTTPS监听不支持挂载主备服务器组。 |
400 | MissingParam.HealthCheckDomain | The HealthCheckDomain is required when HealthCheckHttpVersion is http1.1. | 参数HealthCheckDomain缺失。 |
400 | InvalidParameter.HealthCheckHttpVersion | The param HealthCheckHttpVersion is invalid. | 指定的HealthCheckHttpVersion无效。请检查参数约束,并在修改后重试。 |
400 | QuotaLimitExceeds.AclAttachedToListener | %s. | Acl绑定监听数已达到配额上限。 |
400 | QuotaLimitExceeds.TotalAclEntry | %s. | Acl条目数已达到配额上限。 |
400 | Duplicated.AclEntry | %s. | Acl条目重复。 |
400 | OperationFailed.InsufficientResources | The loadbalancer does not support this operation because of insufficient resources. | 操作失败,原因是由于资源不足,负载均衡器不支持此操作。 |
400 | InvalidParameter.ForwardCode | The specified ForwardCode is invalid. | 指定的ForwardCode无效。请检查参数约束,并在修改后重试。 |
400 | LbNotSupportTcpssl | You cannot create a TCP SSL type listener for the specified load balancer. | 指定的实例不支持创建tcpssl类型的监听。 |
400 | LbSupportTcpsslOnly | The specified load balancer supports TCP SSL type listener only. | 指定的实例只支持创建tcpssl类型的监听。 |
400 | ListenerNotSupportRule | You cannot create a rule for the specified listener. | 指定的监听不支持创建转发规则。 |
400 | Mismatch.SlbSpecTypeAndListenerProtocol | The SlbSpecType and ListenerProtocol are mismatched. | 实例规格类型和监听类型不匹配。 |
访问错误中心查看更多错误码。