Creates an HTTP listener.
Usage notes
A newly created listener is in the stopped state. After a listener is created, you can call the StartLoadBalancerListener operation to start the listener. After the listener is started, the listener can forward traffic to backend servers.
Prerequisites
A Classic Load Balancer (CLB) instance is created. For more information, see CreateLoadBalancer.
Debugging
Request parameters
Parameter | Type | Required | Example | Description |
---|---|---|---|---|
Action | String | Yes | CreateLoadBalancerHTTPListener |
The operation that you want to perform. Set the value to CreateLoadBalancerHTTPListener. |
HealthCheck | String | Yes | on |
Specifies whether to enable health checks. Valid values:
|
ListenerPort | Integer | Yes | 80 |
The frontend port that is used by the CLB instance. Valid values: 1 to 65535. |
LoadBalancerId | String | Yes | lb-bp1c9vixxjh92q83tw***** |
The ID of the CLB instance. |
StickySession | String | Yes | off |
Specifies whether to enable session persistence. Valid values:
|
RegionId | String | Yes | cn-hangzhou |
The ID of the region where the CLB instance is deployed. You can query the region ID from the Regions and zones list or by calling the DescribeRegions operation. |
Bandwidth | Integer | No | -1 |
The maximum bandwidth of the listener. Unit: Mbit/s. Valid values:
Note This parameter is available only in mainland China.
|
BackendServerPort | Integer | No | 80 |
The backend port that is used by the CLB instance. Valid values: 1 to 65535. Note If the VServerGroupId parameter is not set, this parameter is required.
|
XForwardedFor | String | No | on |
Specifies whether to use the
|
Scheduler | String | No | wrr |
The scheduling algorithm. Valid values:
|
StickySessionType | String | No | insert |
The method that is used to handle a cookie. Valid values:
|
CookieTimeout | Integer | No | 500 |
The timeout period of the cookie. Unit: seconds. Valid values: 1 to 86400. Note If StickySession is set to on and StickySessionType is set to insert, this parameter is required.
|
Cookie | String | No | B490B5EBF6F3CD402E515D22BCDA1598 |
The cookie that is configured on the backend server. The cookie must be 1 to 200 characters in length, and can contain only ASCII characters and digits. It cannot contain commas (,), semicolons (;), or spaces. It cannot start with a dollar sign ($). Note If StickySession is set to on and StickySessionType is set to insert, this parameter is required.
|
HealthCheckMethod | String | No | get |
The health check method used in HTTP health checks. Valid values: head and get. Note This parameter takes effect only if the HealthCheck parameter is set to on.
|
HealthCheckDomain | String | No | 172.16.0.0/12 |
The domain name that is used for health checks. Valid values:
Note This parameter takes effect only when the HealthCheck parameter is set to on.
|
HealthCheckURI | String | No | /test/index.html |
The uniform resource identifier (URI) that is used for health checks. The URI must be 1 to 80 characters in length, and can contain letters, digits, hyphens (-), forward slashes (/), periods (.), percent signs (%), question marks (?), number signs (#), and ampersands (&). The URI start with a forward slash (/) but cannot be a single forward slash (/). Note This parameter takes effect only if the HealthCheck parameter is set to on.
|
HealthyThreshold | Integer | No | 4 |
The number of health checks that an unhealthy backend server must consecutively pass before it can be declared healthy. In this case, the health check state is changed from fail to success. Valid values: 2 to 10. Note This parameter takes effect only if the HealthCheck parameter is set to on.
|
UnhealthyThreshold | Integer | No | 4 |
The number of health checks that a healthy backend server must consecutively fail before it can be declared unhealthy. In this case, the health check state is changed from success to fail. Valid values: 2 to 10. Note This parameter takes effect only if the HealthCheck parameter is set to on.
|
HealthCheckTimeout | Integer | No | 3 |
The timeout period of a health check response. If a backend Elastic Compute Service (ECS) instance does not send an expected response within the specified period of time, the ECS instance is considered unhealthy. Unit: seconds. Valid values: 1 to 300. Note
|
HealthCheckConnectPort | Integer | No | 80 |
The backend port that is used for health checks. Valid values: 1 to 65535. Note This parameter takes effect only if the HealthCheck parameter is set to on.
|
HealthCheckInterval | Integer | No | 5 |
The time interval between two consecutive health checks. Unit: seconds. Valid values: 1 to 50. Note This parameter takes effect only if the HealthCheck parameter is set to on.
|
HealthCheckHttpCode | String | No | http_2xx |
The HTTP status code that indicates a successful health check. Separate HTTP status codes with commas (,). Valid values: http_2xx, http_3xx, http_4xx, and http_5xx. Default value: http_2xx. Note This parameter takes effect only if the HealthCheck parameter is set to on.
|
VServerGroupId | String | No | rsp-cige6j***** |
The ID of the vServer group. |
XForwardedFor_SLBIP | String | No | on |
Specifies whether to use the
|
XForwardedFor_SLBID | String | No | on |
Indicates whether the
|
XForwardedFor_proto | String | No | on |
Specifies whether to use the
|
Gzip | String | No | on |
Specifies whether to enable
|
AclId | String | No | 123 |
The ID of the access control list (ACL) to be associated with the listener. Note If AclStatus is set to on, this parameter is required.
|
AclType | String | No | white |
The type of the ACL. Valid values:
Note If AclStatus is set to on, this parameter is required.
|
AclStatus | String | No | off |
Specifies whether to enable the access control feature. Valid values:
|
Description | String | No | Listener1 |
The description of the listener. The description must be 1 to 80 characters in length, and can contain letters, digits, hyphens (-), forward slashes (/), periods (.),and underscores (_). |
ListenerForward | String | No | off |
Specifies whether to enable HTTP-to-HTTPS redirection. Valid values:
|
ForwardPort | Integer | No | 443 |
The listener port that is used to redirect HTTP requests to HTTPS requests. |
IdleTimeout | Integer | No | 3 |
The timeout period of an idle connection. Unit: seconds. Default value: 15. Valid values: 1 to 60. If no request is received within the specified timeout period, CLB closes the connection. When another request is received, CLB establishes a new connection. |
RequestTimeout | Integer | No | 6 |
The timeout period of a request. Unit: seconds. Default value: 60. Valid values: 1 to 180. If no response is received from the backend server within the specified timeout period,
CLB sends an |
Response parameters
Parameter | Type | Example | Description |
---|---|---|---|
RequestId | String | CEF72CEB-54B6-4AE8-B225-F876FF7BA984 |
The ID of the request. |
Examples
Sample requests
http(s)://[Endpoint]/?Action=CreateLoadBalancerHTTPListener
&HealthCheck=on
&ListenerPort=80
&LoadBalancerId=lb-bp1c9vixxjh92q83tw*****
&StickySession=off
&<Common request parameters>
Sample success responses
XML
format
<CreateLoadBalancerHTTPListenerResponse>
d>CEF72CEB-54B6-4AE8-B225-F876FF7BA984</RequestId>
</CreateLoadBalancerHTTPListenerResponse>
JSON
format
{"RequestId":"CEF72CEB-54B6-4AE8-B225-F876FF7BA984"}
Error codes
HttpCode | Error code | Error message | Description |
---|---|---|---|
400 | LbNotSupportTcpssl | You cannot create a TCP SSL type listener for the specified load balancer. | The error message returned because the specified CLB instance does not support TCP listeners. |
400 | LbSupportTcpsslOnly | The specified load balancer supports TCP SSL type listener only. | The error message returned because the specified instance allows you to create only TCP listeners. |
400 | ListenerNotSupportRule | You cannot create a rule for the specified listener. | The error message returned because the specified listener does not allow you to create forwarding rules. |
400 | Mismatch.SlbSpecTypeAndListenerProtocol | The SlbSpecType and ListenerProtocol are mismatched. | The error message returned because the specified instance type and listener type do not match. |
For a list of error codes, visit the API Error Center.