All Products
Search
Document Center

Server Load Balancer:CreateListener

Last Updated:Oct 15, 2024

Creates a listener.

Operation description

Usage notes

CreateListener is an asynchronous operation. After you call this operation, the system returns a request ID. However, the operation is still being performed in the background. You can call the GetListenerAttribute operation to query the status of the HTTP, HTTPS, or QUIC listener.

  • If the HTTP, HTTPS, or QUIC listener is in the Provisioning state, it indicates that the listener is being created.
  • If the HTTP, HTTPS, or QUIC listener is in the Running state, it indicates that the listener has been created successfully.

Debugging

You can run this interface directly in OpenAPI Explorer, saving you the trouble of calculating signatures. After running successfully, OpenAPI Explorer can automatically generate SDK code samples.

Authorization information

The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:

  • Operation: the value that you can use in the Action element to specify the operation on a resource.
  • Access level: the access level of each operation. The levels are read, write, and list.
  • Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
    • The required resource types are displayed in bold characters.
    • If the permissions cannot be granted at the resource level, All Resources is used in the Resource type column of the operation.
  • Condition Key: the condition key that is defined by the cloud service.
  • Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
OperationAccess levelResource typeCondition keyAssociated operation
alb:CreateListenercreate
  • LoadBalancer
    acs:alb:{#regionId}:{#accountId}:loadbalancer/{#loadbalancerId}
  • SecurityPolicy
    acs:alb:{#regionId}:{#accountId}:securitypolicy/{#securitypolicyId}
  • ServerGroup
    acs:alb:{#regionId}:{#accountId}:servergroup/{#servergroupId}
  • alb:ListenerProtocol
none

Request parameters

ParameterTypeRequiredDescriptionExample
LoadBalancerIdstringYes

The ID of the ALB instance.

alb-n5qw04uq8vavfe****
ClientTokenstringNo

The client token that is used to ensure the idempotence of the request.

You can use the client to generate the value, but you must make sure that it is unique among all requests. The token can contain only ASCII characters.

Note If you do not set this parameter, the system automatically uses the value of RequestId as the value of ClientToken. RequestId may be different for each API request.
123e4567-e89b-12d3-a456-426655440000
DryRunbooleanNo

Specifies whether to perform only a precheck. Valid values:

  • true: prechecks the request without creating a listener. The system checks the required parameters, request syntax, and limits. If the request fails the precheck, an error code is returned based on the cause of the failure. If the request passes the precheck, the DryRunOperation error code is returned.
  • false (default): sends the API request. If the request passes the precheck, a 2xx HTTP status code is returned and the system proceeds to create a listener.
false
ListenerProtocolstringYes

The listener protocol.

Valid values: HTTP, HTTPS, and QUIC.

HTTP
ListenerPortintegerYes

The frontend port that is used by the ALB instance.

Valid values: 1 to 65535.

80
ListenerDescriptionstringNo

The name of the listener.

The description must be 2 to 256 characters in length, and can contain letters, digits, hyphens (-), forward slashes (/), periods (.), and underscores (_). Regular expressions are supported.

HTTP_80
RequestTimeoutintegerNo

The timeout period of a request. Unit: seconds.

Valid values: 1 to 180.

Default value: 60.

If no response is received from the backend server during the request timeout period, ALB sends an HTTP 504 error code to the client.

60
IdleTimeoutintegerNo

The timeout period of an idle connection. Unit: seconds.

Valid values: 1 to 60.

Default value: 15.

If no requests are received within the specified timeout period, ALB closes the current connection. When a new request is received, ALB establishes a new connection.

3
GzipEnabledbooleanNo

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

  • true (default): enables Gzip compression.
  • false: disables Gzip compression.
true
Http2EnabledbooleanNo

Specifies whether to enable HTTP/2. Valid values:

  • true (default): enables HTTP/2.
  • false: disables HTTP/2.
Note Only HTTPS listeners support this parameter.
true
SecurityPolicyIdstringNo

The ID of the security policy. System security policies and custom security policies are supported.

Default value: tls_cipher_policy_1_0 (system security policy).

Note Only HTTPS listeners support this parameter.
tls_cipher_policy_1_0
CaEnabledbooleanNo

Specifies whether to enable mutual authentication. Valid values:

  • true: enables mutual authentication.
  • false (default): disables mutual authentication.
false
XForwardedForConfigobjectNo

The configuration of the XForward header.

XForwardedForClientCertClientVerifyAliasstringNo

The name of the custom header. This parameter takes effect only when you set XForwardedForClientCertClientVerifyEnabled to true.

The name must be 1 to 40 characters in length, and can contain letters, digits, hyphens (-), and underscores (_).

Note Only HTTPS listeners support this parameter.
test_client-verify-alias_123456
XForwardedForClientCertClientVerifyEnabledbooleanNo

Specifies whether to use the X-Forwarded-Clientcert-clientverify header to retrieve the verification result of the client certificate. Valid values:

  • true
  • false (default)
Note Only HTTPS listeners support this parameter.
true
XForwardedForClientCertFingerprintAliasstringNo

The name of the custom header. This parameter takes effect only when XForwardedForClientCertFingerprintEnabled is set to true.

The name must be 1 to 40 characters in length, and can contain letters, digits, hyphens (-), and underscores (_).

Note Only HTTPS listeners support this parameter.
test_finger-print-alias_123456
XForwardedForClientCertFingerprintEnabledbooleanNo

Specifies whether to use the X-Forwarded-Clientcert-fingerprint header to retrieve the fingerprint of the client certificate. Valid values:

  • true
  • false (default)
Note Only HTTPS listeners support this parameter.
true
XForwardedForClientCertIssuerDNAliasstringNo

The name of the custom header. This parameter takes effect only when XForwardedForClientCertIssuerDNEnabled is set to true.

The name must be 1 to 40 characters in length, and can contain letters, digits, hyphens (-), and underscores (_).

Note Only HTTPS listeners support this parameter.
test_issue-dn-alias_123456
XForwardedForClientCertIssuerDNEnabledbooleanNo

Specifies whether to use the X-Forwarded-Clientcert-issuerdn header to retrieve information about the authority that issues the client certificate. Valid values:

  • true
  • false (default)
Note Only HTTPS listeners support this parameter.
true
XForwardedForClientCertSubjectDNAliasstringNo

The name of the custom header. This parameter takes effect only when XForwardedForClientCertSubjectDNEnabled is set to true.

The name must be 1 to 40 characters in length, and can contain letters, digits, hyphens (-), and underscores (_).

Note Only HTTPS listeners support this parameter.
test_subject-dn-alias_123456
XForwardedForClientCertSubjectDNEnabledbooleanNo

Specifies whether to use the X-Forwarded-Clientcert-subjectdn header to retrieve information about the owner of the client certificate. Valid values:

  • true
  • false (default)
Note Only HTTPS listeners support this parameter.
true
XForwardedForClientSrcPortEnabledbooleanNo

Specifies whether to use the X-Forwarded-Client-srcport header to retrieve the client port. Valid values:

  • true
  • false (default)
Note HTTP and HTTPS listeners support this parameter.
true
XForwardedForEnabledbooleanNo

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

  • true (default)
  • false
Note HTTP and HTTPS listeners support this parameter.
true
XForwardedForProtoEnabledbooleanNo

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

  • true
  • false (default)
Note HTTP, HTTPS, and QUIC listeners support this parameter.
false
XForwardedForSLBIdEnabledbooleanNo

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

  • true
  • false (default)
Note HTTP, HTTPS, and QUIC listeners support this parameter.
false
XForwardedForSLBPortEnabledbooleanNo

Specifies whether to use the X-Forwarded-Port header to retrieve the listener port of the ALB instance. Valid values:

  • true
  • false (default)
Note HTTP, HTTPS, and QUIC listeners support this parameter.
false
XForwardedForClientSourceIpsEnabledbooleanNo

Specifies whether to allow the ALB instance to retrieve client IP addresses from the X-Forwarded-For header. Valid values:

  • true
  • false (default)
Note HTTP and HTTPS listeners support this parameter.
false
XForwardedForClientSourceIpsTrustedstringNo

The trusted proxy IP address.

ALB instances traverse the IP addresses in the X-Forwarded-For header from the rightmost IP address to the leftmost IP address. The first IP address that is not on the trusted IP address list is considered the client IP address. Requests from the client IP address are throttled.

10.1.1.0/24
QuicConfigobjectNo

Select a QUIC listener and associate it with the ALB instance.

QuicListenerIdstringNo

The ID of the QUIC listener that you want to associate with the ALB instance. This parameter is required if you set QuicUpgradeEnabled to true.

Note The original listener and the QUIC listener must belong to the same ALB instance.
lsr-bp1bpn0kn908w4nbw****
QuicUpgradeEnabledbooleanNo

Specifies whether to enable QUIC upgrade. Valid values:

  • true:
  • false (default)
Note Only HTTPS listeners support this parameter.
false
Certificatesarray<object>No

The details about each certificate.

objectNo

The configurations of the certificate.

CertificateIdstringNo

The ID of the certificate. Only server certificates are supported. You can specify at most 20 certificates IDs.

Note This parameter is required when you set ListenerProtocol to HTTPS or QUIC.
12315790212_166f8204689_1714763408_70998****
CaCertificatesarray<object>No

The certificate authority (CA) certificates. You can specify only one CA certificate.

objectNo

The CA hierarchy.

CertificateIdstringNo

The ID of the CA certificate.

Note This parameter is required if you set CaEnabled to true.
12315790212_166f8204689_1714763408_70998****
DefaultActionsarray<object>Yes

The actions of the forwarding rule.

objectYes
ForwardGroupConfigobjectYes

The configuration of the forwarding action. You can specify at most 20 actions.

ServerGroupTuplesarray<object>Yes

The destination server group to which requests are forwarded.

objectYes
ServerGroupIdstringYes

The ID of the server group to which requests are forwarded.

rsp-cige6j****
TypestringYes

The action. You can specify only one type. Valid value example:

ForwardGroup: forwards requests to multiple server groups.

ForwardGroup
Tagarray<object>No

The tags.

objectNo

The tags.

KeystringNo

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

env
ValuestringNo

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

product

Response parameters

ParameterTypeDescriptionExample
object

Creates a listener.

JobIdstring

The ID of the asynchronous task.

72dcd26b-f12d-4c27-b3af-18f6aed5****
ListenerIdstring

The listener ID.

lsr-bp1bpn0kn908w4nbw****
RequestIdstring

The request ID.

CEF72CEB-54B6-4AE8-B225-F876FF7BA984

Examples

Sample success responses

JSONformat

{
  "JobId": "72dcd26b-f12d-4c27-b3af-18f6aed5****",
  "ListenerId": "lsr-bp1bpn0kn908w4nbw****",
  "RequestId": "CEF72CEB-54B6-4AE8-B225-F876FF7BA984"
}

Error codes

HTTP status codeError codeError messageDescription
400ResourceAlreadyExist.ListenerThe specified resource %s is already exist.The specified resource %s already exists.
400IncorrectStatus.LoadBalancerThe status of %s [%s] is incorrect.The status of %s [%s] is incorrect.
400IncorrectBusinessStatus.LoadBalancerThe business status of %s [%s]  is incorrect.The business status of %s [%s]  is incorrect.
400ResourceQuotaExceeded.LoadBalancerListenersNumThe quota of %s is exceeded for resource %s, usage %s/%s.The quota of %s is exceeded for resource %s, usage %s/%s.
400OperationDenied.CrossLoadBalancerQUICListenerThe operation is not allowed because of %s.The operation is not allowed because of %s.
400ResourceAlreadyAssociated.ListenerThe specified resource %s is already associated.The specified resource %s is already associated.
400ResourceQuotaExceeded.SecurityPolicyAttachedNumThe quota of %s is exceeded for resource %s, usage %s/%s.The quota of %s is exceeded for resource %s. Usage: %s/%s.
400ResourceQuotaExceeded.ServerGroupAttachedNumThe quota of %s is exceeded for resource %s, usage %s/%s.The quota of %s is exceeded for resource %s, usage %s/%s.
400ResourceQuotaExceeded.LoadBalancerServersNumThe quota of %s is exceeded for resource %s, usage %s/%s.The quota of %s is exceeded for resource %s. Usage: %s/%s.
400ResourceQuotaExceeded.ServerAddedNumThe quota of %s is exceeded for resource %s, usage %s/%s.The quota of %s is exceeded for resource %s. Usage: %s/%s.
400Mismatch.VpcIdThe %s is mismatched for %s and %s.The %s is mismatched for %s and %s.
400OperationDenied.ServerGroupProtocolNotSupportThe operation is not allowed because of ServerGroupProtocolNotSupport.The operation is not allowed because the server group protocol is not supported.
400OperationDenied.GRPCServerGroupThe operation is not allowed because of %s.The operation is not allowed because of %s.
400Mismatch.LoadBalancerEditionAndConnectionDrainThe %s and %s are mismatched.The %s and %s are mismatched.
400Mismatch.LoadBalancerEditionAndSlowStartEnableThe %s and %s are mismatched.The %s and %s are mismatched.
400InvalidParameterInvalid parameter, please check the parameter input.Invalid parameter, please check the parameter input.
403Forbidden.SecurityPolicyAuthentication has failed for SecurityPolicy.-
403Forbidden.LoadBalancerAuthentication is failed for %s.Authentication is failed for %s.
403Forbidden.ListenerAuthentication is failed for %s.Authentication is failed for %s.
404ResourceNotFound.LoadBalancerThe specified resource %s is not found.The specified resource %s is not found.
404ResourceNotFound.ServerGroupThe specified resource %s is not found.The specified resource %s is not found.
404ResourceNotFound.SecurityPolicyThe specified resource %s is not found.The specified resource %s is not found.
404ResourceNotFound.ListenerThe specified resource %s is not found.The specified resource %s is not found.
404ResourceNotFound.CertificateThe specified resource %s is not found.The specified resource %s is not found.

For a list of error codes, visit the Service error codes.

Change history

Change timeSummary of changesOperation
2024-09-03The Error code has changedView Change Details
2024-01-29The Error code has changedView Change Details
2024-01-29The Error code has changedView Change Details
2024-01-18The Error code has changedView Change Details
2023-11-06The Error code has changedView Change Details