CreateLoadBalancerHTTPListener

Last Updated: Apr 18, 2018

Description

Create an HTTP protocol listener.

Note: After the listener is created, the listener status is stopped. Call the StartLoadBalancerListener API to start the listener to distribute traffic.

Request parameter

Name Type Required Description
Action String Yes

The action to perform. Valid value:

CreateLoadBalancerHTTPListener

RegionId String Yes The ID of the region where the SLB instance is located.
LoadBalancerId Integer Yes The ID of the SLB instance for which the HTTP listener is created.
Bandwidth Integer Yes

The peak bandwidth of the listener. Valid value: [1,1000] Mbps

Note: Set it to -1 if the Internet SLB instance is charged by traffic.

ListenerPort Integer Yes

The front-end port of the listener that is used to receive incoming traffic and distribute the traffic to the backend servers.

Valid value: [1, 65535]

BackendServerPort Integer No

The port opened on the backend server to receive requests.

Valid value: [1, 65535]

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

VServerGroupId String No The ID of the VServer group to add to the listener.
Scheduler String No

The algorithm used to distribute traffic. Valid values:

  • wrr (Default)

    Backend servers with higher weights receive more requests than those with smaller weights.

  • wlc

    A server with a higher weight will receive a larger percentage of live connections at any one time. If the weights are the same, the system directs network connections to the server with the fewest established connections.

  • rr

    Requests are evenly and sequentially distributed to the backend servers.

XForwardedFor String No

Whether to use the XForwardedFor header to obtain the actual IP address of the client.

Valid value: on (Default) | off

XForwardedFor_SLBIP String No

Whether to use the XForwardedFor_SLBIP header to obtain the public IP address of the SLB instance.

Valid value: on | off(Default)

XForwardedFor_SLBID String No

Whether to use the XForwardedFor header to obtain the ID of the SLB instance.

Valid value: on | off(Default)

XForwardedFor_proto String No

Whether to use the XForwardedFor_proto header to obtain the protocol used by the listener.

Valid value: on | off(Default)

StickySession String Yes

Whether to enable session persistence. If enabled, all session requests from the same client are sent to the same backend server.

Valid value: on | off

StickySessionType String No

The method used to handle the cookie. Valid values:

  • insert

    Server Load Balancer adds a session cookie to the first response from the backend server and identifies the server which has sent the response. The next request will contain the cookie and the listener will distribute the request to the same backend server.

  • server

    You can set the cookie name in the response. Server Load Balancer will overwrite the original cookie when it discovers that a new cookie is set. The next time the client carries the new cookie to access the Server Load Balancer, the listener will distribute the request to the previously recorded backend server.

Note: This parameter is required when the value of the StickySession parameter is on.

CookieTimeout Integer No

The cookie timeout in seconds.

Valid value: [1,86400]

Note: This parameter is required when the value of the StickySessionType parameter is insert.

Cookie String No

The cookie configured on the backend server.

Note: This parameter is required when the value of the StickySessionType parameter is server.

Gzip String No

Whether to enable the Gzip compression.

Valid value: on (Default) | off

AclStatus String No

Specify whether to enable the access control function.

Valid value: on | off (Default)

AclType String No

Select an access control method after enabling the access control function:

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

    Enabling whitelist poses some business risks. If you enable the whitelist without adding any IP entry in the corresponding access control list, no requests are forwarded.

  • blacklist: Requests from IP addresses or CIDR blocks in the selected access control lists are not forwarded. It applies to scenarios where the application only denies access from some specific IP addresses.

    If you enable a blacklist without adding any IP entry in the corresponding access control list, all requests are forwarded.

This parameter is required if the value of the AclStatus parameter is on.

AclId String No

Select an access control list as the whitelist or the blacklist. For more information, see Configure an access control list.

This parameter is required if the value of the AclStatus parameter is on.

IdleTimeout String No

Specify the idle connection timeout in seconds. Valid value: 1-60

If no request is received during the specified timeout period, Server Load Balancer will temporarily terminate the connection and restart the connection when the next request comes.

RequestTimeout String No

Specify the request timeout in seconds. Valid value: 1-180

If no response is received from the backend server during the specified timeout period, Server Load Balancer will stop waiting and send an HTTP 504 error to the client.

HealthCheck String Yes

Whether to enable health check.

Valid value: on | off

HealthCheckDomain String No

The domain name used for health check.

By default, Server Load Balancer sends an HTTP head request to the default homepage configured on the application server through the intranet IP address of the backend ECS instance to do the health check.

If your backend server verifies the host field in the request, you must configure a domain name to make sure the health check works.

You can specify the IP address of host to do the health check in the form of $_ip.

HealthCheckURI String No The URI used for health check.
HealthyThreshold Integer No

The number of consecutive successes of health check performed by the same LVS mode server on the same ECS instance (from failure to success).

Valid value: [2,10]

UnhealthyThreshold Integer No

The number of consecutive failures of health check performed by the same LVS node server on the same ECS instance (from success to failure).

When HealthCheck is on, the parameter is required; and when HealthCheck is off, the parameter will be ignored.

Valid value: [2,10]

HealthCheckConnectPort Integer No

The port used for health check.

Valid value: [1, 65535]

HealthCheckTimeout Integer No

The amount of time in seconds to wait for the response from a health check. If an ECS instance sends no response within the specified timeout period, the health check fails.

Valid value: [1,300]

Note: If the value of the HealthCheckInterval is greater than the value of the HealthCHeckTimeout parameter, the timeout is set to the value of the HealthCheckInterval parameter.

HealthCheckInterval Integer No

The time interval between two consecutive health checks.

Valid value: [1,50]

HealthCheckHttpCode String No

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

Valid values: http_2xx (Default) | http_3xx | http_4xx | http_5xx

Response parameter

Name Type Description
RequestId String The ID of the request.

Example

Request example

  1. https://slb.aliyuncs.com/?Action=CreateLoadBalancerHTTPListener
  2. &LoadBalancerId=139a00604ad-cn-east-hangzhou-01
  3. &ListenerPort=80
  4. &BackendServerPort=80
  5. &Bandwidth=-1
  6. &HealthCheck=on
  7. &HealthCheckDomain=$_ip
  8. &HealthCheckURI=/test/index.html
  9. &HealthCheckConnectPort=8080
  10. &HealthyThreshold=4
  11. &UnhealthyThreshold=4
  12. &HealthCheckTimeout=3
  13. &HealthCheckInterval=5
  14. &VServerGroupId=rsp-cige6j5e7p
  15. &<CommonParameters>

Response example

  • XML format

    1. <?xml version="1.0" encoding="UTF-8"?>
    2. <CreateLoadBalancerHTTPListenerResponse>
    3. <RequestId>CEF72CEB-54B6-4AE8-B225-F876FF7BA984</RequestId>
    4. </CreateLoadBalancerHTTPListenerResponse>
  • JSON format

    1. {
    2. "RequestId":" CEF72CEB-54B6-4AE8-B225-F876FF7BA984"
    3. }
Thank you! We've received your feedback.