All Products
Search
Document Center

Server Load Balancer:CreateLoadBalancerHTTPListener

Last Updated:Mar 02, 2026

Creates an HTTP listener for a Classic Load Balancer (CLB) instance.

Operation description

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.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

slb:CreateLoadBalancerHTTPListener

create

*acl

acs:slb:{#regionId}:{#accountId}:acl/{#aclId}

*loadbalancer

acs:slb:{#regionId}:{#accountId}:loadbalancer/{#loadbalancerId}

  • slb:tag
  • slb:tag
  • slb:tag
None

Request parameters

Parameter

Type

Required

Description

Example

RegionId

string

No

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.

cn-hangzhou

LoadBalancerId

string

Yes

The ID of the CLB instance.

lb-bp1c9vixxjh92q83tw*****

Bandwidth

integer

No

The maximum bandwidth of the listener. Unit: Mbit/s. Valid values:

-1: specifies that the bandwidth of the listener is unlimited.

-1

ListenerPort

integer

Yes

The frontend port that is used by the CLB instance.

Valid values: 1 to 65535.

80

BackendServerPort

integer

No

The backend port that is used by the CLB instance.

Valid values: 1 to 65535.

Note

If the VServerGroupId parameter is not specified, this parameter is required.

80

XForwardedFor

string

No

Specifies whether to use the X-Forwarded-For header to retrieve client IP addresses. Valid values:

  • on (default)

  • off

on

Scheduler

string

No

The scheduling algorithm. Valid values:

  • wrr (default): Backend servers with higher weights receive more requests than those with lower weights.

  • rr: Requests are distributed to backend servers in sequence.

wrr

StickySession

string

No

Specifies whether to enable session persistence. Valid values:

  • on

  • off (default)

off

StickySessionType

string

No

The method that is used to handle cookies. Valid values:

  • insert: inserts a cookie.

    The first time a client accesses CLB, CLB inserts a cookie into the response packet. Subsequent requests from the client that carry the cookie are distributed to the same backend server as the first request.

  • server: rewrites the original cookie.

    CLB rewrites the custom cookies in requests from a client. Subsequent requests from the client that carry the new cookie are forwarded to the same backend server as the first request.

Note

This parameter is required if the StickySession parameter is set to on.

insert

Tag

array<object>

No

The tags.

object

No

Key

string

No

The tag key of the bastion host. Valid values of N: 1 to 20. The tag key cannot be an empty string.

The tag key can be at most 64 characters in length, and cannot contain http:// or https://. It must not start with aliyun or acs:.

TestKey

Value

string

No

The tag value. Valid values of N: 1 to 20. The tag value can be an empty string.

The tag value can be up to 128 characters in length and cannot start with acs: or aliyun. The tag value cannot contain http:// or https://.

TestValue

CookieTimeout

integer

No

The timeout period of a 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.

500

Cookie

string

No

The cookie configured for the server.

The cookie must be 1 to 200 characters in length, and can contain only ASCII letters and digits. It cannot contain commas (,), semicolons (;), space characters, or start with a dollar sign ($).

Note

This parameter is required when the StickySession parameter is set to on and the StickySessionType parameter is set to server.

testCookie

HealthCheck

string

Yes

Specifies whether to enable the health check feature. Valid values:

  • on: yes

  • off: no

on

HealthCheckMethod

string

No

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.

get

HealthCheckDomain

string

No

The domain name that is used for health checks. Valid values:

  • $_ip: the private IP address of a backend server. If an IP address is specified, or this parameter is not specified, the CLB instance uses the private IP address of each backend server as the domain name for health checks.

  • domain: The domain name must be 1 to 80 characters in length, and can contain letters, digits, periods (.), and hyphens (-).

Note

This parameter takes effect only if the HealthCheck parameter is set to on.

172.16.*.*/12

HealthCheckURI

string

No

The 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 must 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.

/test/index.html

HealthyThreshold

integer

No

The number of times that an unhealthy backend server must consecutively pass health checks before it is declared healthy. In this case, the health status 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.

4

UnhealthyThreshold

integer

No

The number of times that a healthy backend server must consecutively fail health checks before it is declared unhealthy. In this case, the health status 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.

4

HealthCheckTimeout

integer

No

The timeout period of a health check response. If a backend ECS instance does not respond within the specified timeout period, the ECS instance fails the health check. Unit: seconds

Valid values: 1 to 300.

Note

This parameter takes effect only if the HealthCheck parameter is set to on.

3

HealthCheckConnectPort

integer

No

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.

80

HealthCheckInterval

integer

No

The 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.

5

HealthCheckHttpCode

string

No

The HTTP status code for a successful health check. Separate multiple HTTP status codes with commas (,).

Valid values: http_2xx (default), http_3xx, http_4xx, and http_5xx.

Note

This parameter takes effect only if the HealthCheck parameter is set to on.

http_2xx

VServerGroupId

string

No

The ID of the vServer group.

rsp-cige6j*****

XForwardedFor_SLBIP

string

No

Specifies whether to use the SLB-IP header to retrieve the virtual IP address of the client. Valid values:

  • on

  • off (default)

on

XForwardedFor_SLBID

string

No

Specifies whether to use the SLB-ID header to retrieve the ID of the CLB instance. Valid values:

  • on

  • off (default)

on

XForwardedFor_proto

string

No

Specifies whether to use the X-Forwarded-Proto header to retrieve the listener protocol. Valid values:

  • on

  • off (default)

on

Gzip

string

No

Specifies whether to enable GZIP compression to compress specific types of files. Valid values:

  • on (default)

  • off

on

AclId

string

No

The ID of the network access control list (ACL) that is associated with the listener.

Note

If AclStatus is set to on, this parameter is required.

acl-uf60jw******

AclType

string

No

The type of access control. Valid values:

  • white: Only requests from IP addresses and CIDR blocks on the whitelist are forwarded by the listener. Your service may be adversely affected if the whitelist is not properly configured. If a whitelist is configured, the listener forwards only requests from IP addresses that are added to the whitelist.

    If you configure a whitelist but do not add an IP address to the whitelist, the listener forwards all requests.

  • black: Requests from the IP addresses and CIDR blocks on the blacklist are blocked.

    If you configure a blacklist but do not add an IP address to the blacklist, the listener forwards all requests.

Note

When AclStatus is set to on, this parameter takes effect.

white

AclStatus

string

No

Specifies whether to enable access control. Valid values:

  • on: yes

  • off (default): no

off

Description

string

No

The name of the listener.

The name must be 1 to 256 characters in length, and can contain letters, digits, hyphens (-), forward slashes (/), periods (.), and underscores (_).

HTTP_443

ListenerForward

string

No

Specifies whether to enable HTTP-to-HTTPS redirection. Valid values:

  • on: yes

  • off (default): no

off

ForwardPort

integer

No

The listening port that is used to redirect HTTP requests to HTTPS.

443

IdleTimeout

integer

No

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, SLB closes the connection. When a request is received, SLB establishes a new connection.

3

RequestTimeout

integer

No

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 HTTP 504 error code to the client.

6

XForwardedFor_SLBPORT

string

No

Specifies whether to use the XForwardedFor_SLBPORT header to retrieve the listener port of the CLB instance. Valid values:

  • on

  • off

off

XForwardedFor_ClientSrcPort

string

No

Specifies whether to use the XForwardedFor_ClientSrcPort header to retrieve the client port. Valid values:

  • on

  • off

off

Response elements

Element

Type

Description

Example

object

RequestId

string

The ID of the request.

CEF72CEB-54B6-4AE8-B225-F876FF7BA984

Examples

Success response

JSON format

{
  "RequestId": "CEF72CEB-54B6-4AE8-B225-F876FF7BA984"
}

Error codes

HTTP status code

Error code

Error message

Description

400 InvalidParameter.RegionNotSupport The region does not support the parameter: %s.
400 IpVersionConflict The ip version of this LoadBalancer and the Acl is conflict.
400 InvalidParameter The specified ListenerPort or ForwardPort is invalid.
400 ListenerForwardNotSupport X-Forward-For is not supported to a ipv6 instance.
400 InvalidParameter.IdleTimeout The specified IdleTimeout exceeds the limit.
400 InvalidParameter.RequestTimeout The specified RequestTimeout exceeds the limit.
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.
400 OperationUnsupported.CreateLoadBalancerLayer7Listener The slb instance does not support create HTTP or HTTPS listener.
400 InvalidParameter.VServerGroupId The MasterSlaveServerGroup can not be attached to HTTP or HTTPS listener.
400 MissingParam.HealthCheckDomain The HealthCheckDomain is required when HealthCheckHttpVersion is http1.1.
400 InvalidParameter.HealthCheckHttpVersion The param HealthCheckHttpVersion is invalid.
400 Duplicated.AclEntry %s. %s
400 OperationFailed.InsufficientResources The loadbalancer does not support this operation because of insufficient resources.
400 InvalidParameter.ForwardCode The specified ForwardCode is invalid.
400 LbNotSupportTcpssl You cannot create a TCP SSL type listener for the specified load balancer.
400 LbSupportTcpsslOnly The specified load balancer supports TCP SSL type listener only.
400 ListenerNotSupportRule You cannot create a rule for the specified listener. You cannot create a rule for the specified listener.
400 Mismatch.SlbSpecTypeAndListenerProtocol The SlbSpecType and ListenerProtocol are mismatched.
400 InvalidParam.TagValue %s.
400 InvalidParam.TagKey %s.
400 SizeLimitExceeded.Tag %s.
400 MissingParam.TagKey The param MissingParam.TagKey is missing.
400 AclListenerOverLimit This acl has reached the limit of binding to listeners.
400 QuotaLimitExceeds.AclAttachedToListener The number of Acl bound listeners has reached the quota limit
400 QuotaLimitExceeds.TotalAclEntry The number of Acl entries has reached the quota limit.
400 QuotaLimitExceeds.AclListenerOverLimit This acl has reached the limit of binding to listeners.

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.