All Products
Search
Document Center

Server Load Balancer:CreateListener

Last Updated:Mar 01, 2024

Creates an HTTP, HTTPS, or QUIC listener in a region.

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

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer.

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:CreateListenerWrite
  • 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
XForwardedForClientCertClientVerifyAliasstringNo

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

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

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: uses the X-Forwarded-Clientcert-clientverify header.
  • false (default): does not use the X-Forwarded-Clientcert-clientverify header.
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 lowercase letters, hyphens (-), underscores (_), and digits.

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: uses the X-Forwarded-Clientcert-fingerprint header.
  • false (default): does not use the X-Forwarded-Clientcert-fingerprint header.
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 lowercase letters, hyphens (-), underscores (_), and digits.

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: uses the X-Forwarded-Clientcert-issuerdn header.
  • false (default): does not use the X-Forwarded-Clientcert-issuerdn header.
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 lowercase letters, hyphens (-), underscores (_), and digits.

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: uses the X-Forwarded-Clientcert-subjectdn header.
  • false (default): does not use the X-Forwarded-Clientcert-subjectdn header.
Note Only HTTPS listeners support this parameter.
true
XForwardedForClientSrcPortEnabledbooleanNo

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

  • true: uses the X-Forwarded-Client-Port header.
  • false (default): does not use the X-Forwarded-Client-Port header.
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): uses the X-Forwarded-For header.
  • false: does not use the X-Forwarded-For header.
Note HTTP and HTTPS listeners support this parameter.
true
XForwardedForProtoEnabledbooleanNo

Specifies whether to use the X-Forwarded-Proto header to retrieve the listening protocol of the ALB instance. Valid values:

  • true: uses the X-Forwarded-Proto header.
  • false (default): does not use the X-Forwarded-Proto header.
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: uses the SLB-ID header.
  • false (default): does not use the SLB-ID header.
Note HTTP, HTTPS, and QUIC listeners support this parameter.
false
XForwardedForSLBPortEnabledbooleanNo

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

  • true: uses the X-Forwarded-Port header.
  • false (default): does not use the X-Forwarded-Port header.
Note HTTP, HTTPS, and QUIC listeners support this parameter.
false
XForwardedForClientSourceIpsEnabledbooleanNo

Specifies whether to use the X-Forwarded-Client-Ip header to obtain the source IP address of the ALB instance. Valid values:

  • true: uses the X-Forwarded-Client-Ip header.
  • false (default): does not use the X-Forwarded-Client-Ip header.
Note HTTP, HTTPS, and QUIC listeners support this parameter. The feature corresponding to this parameter is not available by default. If you want to use this feature, submit a ticket.
false
XForwardedForClientSourceIpsTrustedstringNo

The trusted proxy IP address.

ALB traverses X-Forwarded-For backwards and selects the first IP address that is not in the trusted IP list as the originating IP address of the client, which will be throttled if source IP address throttling is enabled.

10.1.1.0/24
QuicConfigobjectNo
QuicListenerIdstringNo

The ID of the QUIC listener that you want to associate with the HTTPS listener. Only HTTPS listeners support this parameter. This parameter is required when QuicUpgradeEnabled is set to true.

Note The HTTPS listener and the QUIC listener must be added to the same ALB instance. Make sure that the QUIC listener is not associated with any other listeners.
lsr-bp1bpn0kn908w4nbw****
QuicUpgradeEnabledbooleanNo

Specifies whether to enable QUIC upgrade. Valid values:

  • true: enables QUIC upgrade.
  • false (default): disables QUIC upgrade.
Note Only HTTPS listeners support this parameter.
false
Certificatesobject []No
CertificateIdstringNo

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

12315790212_166f8204689_1714763408_70998****
DefaultActionsobject []Yes
ForwardGroupConfigobjectYes
ServerGroupTuplesobject []Yes
ServerGroupIdstringYes

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

rsp-cige6j****
TypestringYes

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

ForwardGroup: forwards requests to multiple vServer groups.

ForwardGroup
Tagobject []No

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
JobIdstring

The ID of the asynchronous task.

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

The ID of the listener.

lsr-bp1bpn0kn908w4nbw****
RequestIdstring

The ID of the request.

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.
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-01-29The Error code has changedsee changesets
Change itemChange content
Error CodesThe Error code has changed.
    Error Codes 400 change
    Error Codes 403 change
    delete Error Codes: 404
2024-01-29The Error code has changedsee changesets
Change itemChange content
Error CodesThe Error code has changed.
    Error Codes 403 change
    delete Error Codes: 400
    delete Error Codes: 404
2024-01-18The Error code has changedsee changesets
Change itemChange content
Error CodesThe Error code has changed.
    Error Codes 400 change
    delete Error Codes: 404
    Added Error Codes: 403
2023-11-06The Error code has changedsee changesets
Change itemChange content
Error CodesThe Error code has changed.
    delete Error Codes: 400
    delete Error Codes: 404