Creates an HTTP listener.

Note A newly created listener is in the stopped state. After you create a listener, you must call StartLoadBalancerListener to start the listener to forward traffic.

Debug

Use OpenAPI Explorer to perform debug operations and generate SDK code examples.

Request parameters

Parameter Type Required? Example value Description
Action String Yes CreateLoadBalancerHTTPListener

The name of this action.

Value: CreateLoadBalancerHTTPListener

HealthCheck String Yes on

Indicates whether to enable health checks.

Valid values: on | off

ListenerPort Integer Yes 80

The frontend port used by the Server Load Balancer (SLB) instance.

Value range: 1 to 65535

LoadBalancerId String Yes lb-bp1c9vixxjh92q83tw*****

The ID of the SLB instance.

RegionId String Yes cn-hangzhou

The region to which the SLB instance belongs.

To query the region ID, refer to the list of regions and zones or call DescribeRegions.

StickySession String Yes off

Indicates whether to enable session persistence.

Valid values: on | off

AclId String No 123

The ID of the access control list associated with the listener.

If the value of the AclStatus parameter is on, this parameter is required.

AclStatus String No off

Indicates whether to enable access control.

Valid values: on | off. Default value: off

AclType String No white

The access control type. Valid values:

  • white: Indicates a whitelist. Only requests from the IP addresses or CIDR blocks in the selected access control list are forwarded. It applies to scenarios where an application allows access only from specific IP addresses.

    Enabling a whitelist poses some risks to your services.

    After a whitelist is configured, only the IP addresses in the list can access the listener.

    If you enable a whitelist without adding any IP addresses in the list, all requests are forwarded.

  • black: Indicates a blacklist. Requests from the IP addresses or CIDR blocks in the selected access control list are not forwarded (that is, they are blocked). It applies to scenarios where an application denies access only from specific IP addresses.

    If you enable a blacklist without adding any IP addresses to the list, all requests are forwarded.

If the value of the parameter AclStatus is on, this parameter is required.

BackendServerPort Integer No 80

The backend port used by the SLB instance.

Value range: 1 to 65535

Note If no VServer group is used (the VServerGroupId parameter is not specified), this parameter is required.
Bandwidth Integer No -1

The peak bandwidth of the listener. Valid values:

  • -1: The peak bandwidth is not limited.
  • 1 to 5120: the peak bandwidth of the listener. The sum of the peak bandwidth values of all listeners cannot surpass the peak bandwidth of the SLB instance.
Note This parameter applies only to the China site.
Cookie String No B490B5EBF6F3CD402E515D22BCDA1598

The cookie configured on the backend server.

The cookie must be 1 to 200 characters in length and can only contain ASCII English letters and numbers. It cannot contain commas (,), semicolons (;), or spaces. Nor can it begin with a dollar sign ($).

If the value of the parameter StickySession is on and the value of the parameter StickySessionType is server, this parameter is required.

CookieTimeout Integer No 500

The timeout period of the cookie.

Valid values: 1 to 86400. Unit: seconds.

Note If the value of the parameter StickySession is on and the value of the parameter StickySessionType is insert, this parameter is required.
Description String No Listener description

A description of the listener.

The description must be 1 to 80 characters in length and can contain letters, numbers, hyphens (-), forward slashes (/), periods (.), and underscores (_). Chinese characters are supported.

ForwardPort Integer No 443

The port used for redirection from HTTP to HTTPS.

Gzip String No on

Indicates whether to enable Gzip compression to compress a specific file type. Default value: on

Valid values: on | off

HealthCheckConnectPort Integer No 80

The backend server port used for health checks.

Value range: 1 to 65535

Note This parameter is valid only when the value of the parameter HealthCheck is on.
HealthCheckDomain String No $_ip

The domain name used for health checks. Valid values:

  • $_ip: the private IP address of the backend server. If the IP address is specified or this parameter is not specified, SLB uses the private IP addresses of backend servers as the domain names for health checks.
  • domain: The domain name must be 1 to 80 characters in length, and can only contain letters, numbers, periods (.), and hyphens (-).
HealthCheckHttpCode String No http_2xx,http_3xx

The HTTP status code indicating that the health check is normal. Separate multiple HTTP status codes by commas (,). Default value: http_2xx

Valid values: http_2xx | http_3xx | http_4xx | http_5xx

HealthCheckInterval Integer No 5

The interval between two consecutive health checks.

Value range: 1 to 50. Unit: seconds.

HealthCheckTimeout Integer No 3

The amount of time to wait for a response from a health check. If the backend server does not send a correct response within the specified time, the health check fails.

Value range: 1 to 300. Unit: seconds.

Note If the value of HealthCheckTimeout is smaller than that of HealthCheckInterval, the value of HealthCheckTimeout is invalid and the timeout is set to the value of HealthCheckInterval.
HealthCheckURI String No /test/index.html

The URL used for health checks.

HealthyThreshold Integer No 4

The number of consecutive successes of health checks before a backend server is declared as healthy (from failure to success).

Value range: 2 to 10

IdleTimeout Integer No 3

The idle connection timeout. Value range: 1 to 60. Default value: 15. Unit: seconds.

If no request is received during the specified timeout period, SLB temporarily terminates the connection and restarts the connection when the next request is received.

ListenerForward String No off

Indicates whether to enable redirection from HTTP to HTTPS.

Valid values: on | off

RequestTimeout Integer No 6

The request timeout. Value range: 1 to 180. Default value: 60. Unit: seconds.

If the backend server does not respond within the specified timeout period, SLB stops waiting and returns an HTTP 504 error code to the client.

Scheduler String No wrr

The algorithm used for distributing traffic. Valid values:

  • wrr (default): A backend server with a higher weight receives more requests.
  • wlc: A server with a higher weight receives more requests. When the weight values of two backend servers are the same, the server with a smaller number of connections is more likely to be polled.
  • rr: Requests are evenly and sequentially distributed to backend servers.
StickySessionType String No on

The method used to handle the cookie. Valid values:

  • insert: Insert a cookie.

    SLB adds a cookie to the first response from the backend server (that is, it inserts SERVERID in the HTTP/HTTPS response packet). Then, the next request contains the cookie and the listener distributes the request to the same backend server.

  • server: Rewrite the cookie.

    SLB overwrites the original cookie when a new cookie is set. The next time the client carries the new cookie to access SLB, the listener distributes the request to the previously recorded backend server.
    Note If the value of the parameter StickySession is on, this parameter is required.
UnhealthyThreshold Integer No 4

The number of consecutive failures of health checks before a backend server is declared as unhealthy (from success to failure).

Value range: 2 to 10

VServerGroupId String No rsp-cige6j*****

The ID of the VServer group associated with the listener.

XForwardedFor String No on

Indicates whether to use the X-Forwarded-For header field to obtain the real IP address of a client. Default value: on

Valid values: on | off

XForwardedFor_SLBID String No on

Indicates whether to use the SLB-ID header field to obtain the SLB instance ID.

Valid values: on | off. Default value: off

XForwardedFor_SLBIP String No on

Indicates whether to use the SLB-IP header field to obtain the real IP address of a client request.

Valid values: on | off. Default value: off

XForwardedFor_proto String No on

Indicates whether to use the X-Forwarded-Proto header field to obtain the listening protocol used by the SLB instance.

Valid values: on | off. Default value: off

Response parameters

Parameter Type Example value Description
RequestId String CEF72CEB-54B6-4AE8-B225-F876FF7BA984

The ID of the request.

Examples

Request example


http(s)://[Endpoint]/? Action=CreateLoadBalancerHTTPListener
&HealthCheck=on
&ListenerPort=80
&LoadBalancerId=lb-bp1c9vixxjh92q83tw*****
&StickySession=off
&<CommonParameters>

Response example

XML format

<CreateLoadBalancerHTTPListenerResponse>
			  <RequestId>1FF504CB-BFFF-4508-A51A-58A416604FC8</RequestId>
		</CreateLoadBalancerHTTPListenerResponse>

JSON format

{
	"RequestId":"1FF504CB-BFFF-4508-A51A-58A416604FC8"
}

Errors

For a list of error codes, visit the API Error Center.