CreateDomain

Updated at:

Adds a website config to a WAF instance for protection.

Operation description

Before you call this operation, the domain name (Domain) must meet the following requirements:

  • Domain ownership authentication: If AccessType is set to share (CNAME access) or hybrid_cloud_cname (hybrid cloud CNAME access) and public cloud disaster recovery is enabled, you must authenticate the ownership of the domain name first. Invoke the DescribeVerifyContent operation to obtain the domain name authentication information, configure a DNS TXT record or upload an HTTP authentication file based on the returned content, and then invoke the VerifyDomainOwner operation to authenticate the domain name ownership. When you invoke the DescribeVerifyContent and VerifyDomainOwner operations, you must use the DomainName parameter to specify the domain name. For the DescribeVerifyContent operation, you must also use the AccessOrigin parameter to specify the access source. For more information about the valid values, see the metric description of the DescribeVerifyContent operation.

  • ICP filing: If AccessType is set to share (CNAME access) or hybrid_cloud_cname (hybrid cloud CNAME access) and public cloud disaster recovery is enabled, and the website config is added to a region in the Chinese mainland, the domain name must have an ICP filing.

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

yundun-waf:CreateDomain

create

*DefenseResource

acs:yundun-waf:{#regionId}:{#accountId}:defenseresource/*

None None

Request parameters

Parameter

Type

Required

Description

Example

InstanceId

string

Yes

The ID of the WAF instance.

Note

You can call the DescribeInstance operation to query the ID of the current WAF instance.

waf_cdnsdf3****

ResourceManagerResourceGroupId

string

No

The ID of the Alibaba Cloud resource group.

rg-acfm***q

Domain

string

Yes

The domain name to query.

www.aliyundoc.com

Listen

object

Yes

The listener configuration.

HttpsPorts

array

No

The listening ports for HTTPS.

integer

No

The listening ports for HTTPS. Use the [port1,port2,......,portN] format.

443

HttpPorts

array

No

The listening ports for HTTP.

integer

No

The listening ports for HTTP. Use the [port1,port2,...] format.

80

Http2Enabled

boolean

No

Specifies whether to enable HTTP/2. This parameter is used only when HttpsPorts is not empty, which indicates that the domain name uses HTTPS. Valid values:

  • true: enables HTTP/2.

  • false (default): disables HTTP/2.

true

CertId

string

No

The ID of the certificate to add. This parameter is used only when HttpsPorts is not empty, which indicates that the domain name uses HTTPS.

123

SM2Enabled

boolean

No

Specifies whether to enable the SM2 certificate.

true

SM2CertId

string

No

The ID of the SM2 certificate to add. This parameter is used only when SM2Enabled is set to true.

123-cn-hangzhou

SM2AccessOnly

boolean

No

Specifies whether to allow access only from SM2 clients. This parameter is used only when SM2Enabled is set to true. Valid values:

  • true: allows access only from SM2 clients.

  • false: allows access from both SM2 and non-SM2 clients.

true

TLSVersion

string

No

The TLS version to add. This parameter is used only when HttpsPorts is not empty, which indicates that the domain name uses HTTPS. Valid values:

  • tlsv1: supports TLS 1.0 and later versions. This value provides the highest compatibility but lower security.

  • tlsv1.1: supports TLS 1.1 and later versions. This value provides good compatibility and security.

  • tlsv1.2: supports TLS 1.2 and later versions. This value provides good compatibility and the highest security.

  • tlsv1.3: supports only TLS 1.3. This value provides the highest security but lower compatibility.

tlsv1

EnableTLSv3

boolean

No

Specifies whether to support TLS 1.3. Valid values:

  • true: supports TLS 1.3.

  • false: does not support TLS 1.3.

Note

This parameter is used only when HttpsPorts is not empty, which indicates that the domain name uses HTTPS. When TLSVersion is set to tlsv1.3, this parameter must be set to true.

true

CipherSuite

integer

No

The type of cipher suite to add. This parameter is used only when HttpsPorts is not empty, which indicates that the domain name uses HTTPS. Valid values:

  • 1: adds all cipher suites.

  • 2: adds strong cipher suites. This value is available only when TLSVersion is set to tlsv1.2.

  • 99: adds custom cipher suites. This value is available only when TLSVersion is not set to tlsv1.3.

2

CustomCiphers

array

No

The custom cipher suites to add.

string

No

The custom cipher suites to add. This parameter is used only when CipherSuite is set to 99.

ECDHE-ECDSA-AES256-SHA384

FocusHttps

boolean

No

Specifies whether to enable force redirect to HTTPS. This parameter is used only when HttpsPorts is not empty, which indicates that the domain name uses HTTPS, and HttpPorts is empty, which indicates that the domain name does not use HTTP. Valid values:

  • true: enables force redirect to HTTPS.

  • false: disables force redirect to HTTPS.

true

XffHeaderMode

integer

No

The method for WAF to obtain the actual IP address of the client. Valid values:

  • 0 (default): The client access traffic is not forwarded by other Layer 7 proxies before it reaches WAF.

  • 1: WAF reads the first value of the X-Forwarded-For (XFF) field in the request header as the client IP address.

  • 2: WAF reads the value of a custom field that you specified in the request header as the client IP address.

  • 3: WAF reads the Client IP field in the Proxy Protocol header as the client IP address.

1

XffHeaders

array

No

The list of custom fields used to obtain the client IP address.

string

No

The list of custom fields used to obtain the client IP address. Use the ["header1","header2",...] format.

Note

This parameter is required only when XffHeaderMode is set to 2, which indicates that WAF reads the value of a custom field that you specified in the request header as the client IP address.

Client-ip

IPv6Enabled

boolean

No

Specifies whether to enable IPv6. Valid values:

  • true: enables IPv6.

  • false (default): disables IPv6.

true

ProtectionResource

string

No

The type of protection resource to use. Valid values:

  • share (default): uses a shared cluster.

  • gslb: uses intelligent load balancing of a shared cluster.

share

ExclusiveIp

boolean

No

Specifies whether to enable an exclusive IP address. This parameter is used only when IPv6Enabled is set to false, which indicates that IPv6 is disabled, and ProtectionResource is set to share, which indicates that a shared cluster is used. Valid values:

  • true: enables an exclusive IP address.

  • false (default): disables an exclusive IP address.

true

HstsIncludeSubDomain

boolean

No

Specifies whether HTTP Strict Transport Security (HSTS) includes subdomains. Valid values:

  • true: enabled.

  • false: disabled.

true

HstsPreload

boolean

No

Specifies whether to enable HSTS preload. Default value: disabled. Valid values:

  • true: enabled.

  • false: disabled.

false

HstsMaxAge

integer

No

The HSTS expiration time. Unit: seconds.

365000

Redirect

object

Yes

The forwarding configuration.

Backends

array

No

The IP addresses of the origin servers or the back-to-origin domain names for the domain name.

string

No

The IP addresses of the origin servers or the back-to-origin domain names for the domain name. You can specify either IP addresses of origin servers or back-to-origin domain names. If the back-to-origin address is a domain name, only IPv4 is supported, and IPv6 is not supported.

  • To specify IP addresses of origin servers, use the ["ip1","ip2",...] format. You can add up to 20 IP addresses.

  • To specify back-to-origin domain names, use the ["domain"] format. You can add up to 20 domain names.

1.1.XX.XX

Loadbalance

string

Yes

The load balancing algorithm used for back-to-origin requests. Valid values:

  • iphash: the IP hash algorithm.

  • roundRobin: the round-robin algorithm.

  • leastTime: the least time algorithm. This value is available only when ProtectionResource is set to gslb, which indicates that intelligent load balancing of a shared cluster is used.

roundRobin

FocusHttpBackend

boolean

No

Specifies whether to enable force back-to-origin over HTTP. This parameter is used only when HttpsPorts is not empty, which indicates that the domain name uses HTTPS. Valid values:

  • true: enables force back-to-origin over HTTP.

  • false: disables force back-to-origin over HTTP.

true

SniEnabled

boolean

No

Specifies whether to enable back-to-origin Server Name Indication (SNI). This parameter is used only when HttpsPorts is not empty, which indicates that the domain name uses HTTPS. Valid values:

  • true: enables back-to-origin SNI.

  • false (default): disables back-to-origin SNI.

true

SniHost

string

No

The value of the custom SNI extension field. If you do not specify this parameter, the value of the Host field in the request header is used as the value of the SNI extension field by default. In most cases, you do not need to customize the SNI unless your business has special configuration requirements and you want WAF to use an SNI that is different from the actual request Host in back-to-origin requests.

Note

This parameter is required only when SniEnabled is set to true, which indicates that back-to-origin SNI is enabled.

www.aliyundoc.com

RequestHeaders

array<object>

No

The traffic marking fields and values for the domain name, which are used to mark the traffic processed by WAF.

By specifying custom request header fields and their corresponding values, WAF automatically adds the specified custom field values to the request headers as traffic marks when the access traffic of the domain name passes through WAF. This facilitates the collection of related information by backend services.

object

No

The value of this parameter is in the [{"k":"key","v":"value"}] format. key indicates the specified custom request header field, and value indicates the value set for the field.

Key

string

No

The specified custom request header field.

aaa

Value

string

No

The value set for the custom request header field.

bbb

ConnectTimeout

integer

No

The connection timeout period. Unit: seconds. Valid values: 1 to 3600. Default value: 5.

120

ReadTimeout

integer

No

The read timeout period. Unit: seconds. Valid values: 1 to 3600. Default value: 120.

200

WriteTimeout

integer

No

The write timeout period. Unit: seconds. Valid values: 1 to 3600. Default value: 120.

200

CnameEnabled

boolean

No

Specifies whether to enable public cloud disaster recovery. Valid values:

  • true: enables public cloud disaster recovery.

  • false (default): disables public cloud disaster recovery.

true

RoutingRules

string

No

The hybrid cloud forwarding rules. The value is a string transformed from a JSON array. Each element in the JSON array is a struct that contains the following fields:

  • rs: Array | The list of back-to-origin IP addresses or back-to-origin CNAMEs.

  • backupRs: Array | The list of secondary back-to-origin IP addresses or back-to-origin CNAMEs. This field is required. An empty array [] indicates that no secondary back-to-origin addresses are configured.

  • location: String | The name of the protection node.

  • locationId: Long | The ID of the protection node.

[ { "rs": [ "1.1.XX.XX" ], "backupRs": [ "2.2.XX.XX" ], "locationId": 535, "location": "test1111" } ]

Keepalive

boolean

No

Specifies whether to maintain persistent connections. Valid values:

  • true (default): maintains persistent connections.

  • false: does not maintain persistent connections.

true

Retry

boolean

No

Specifies whether to retry when WAF fails to forward requests to the origin server. Valid values:

  • true (default): retries.

  • false: does not retry.

true

KeepaliveRequests

integer

No

The number of requests that reuse a persistent connection. Valid values: 60 to 1000. Default value: 1000.

Note

The maximum number of requests that can be served over a single persistent connection after persistent connections are enabled.

1000

KeepaliveTimeout

integer

No

The timeout period for idle persistent connections. Valid values: 1 to 60. Default value: 15. Unit: seconds.

Note

The duration after which an idle persistent connection is released.

15

XffProto

boolean

No

Specifies whether to pass the WAF protocol in the X-Forwarded-Proto header. Valid values:

  • true (default): passes the WAF protocol.

  • false: does not pass the WAF protocol.

false

BackupBackends

array

No

The IP addresses of the secondary origin servers or the secondary back-to-origin domain names for the domain name.

string

No

The IP addresses of the secondary origin servers or the secondary back-to-origin domain names for the domain name. You can specify either IP addresses of secondary origin servers or secondary back-to-origin domain names. If the back-to-origin address is a domain name, only IPv4 is supported, and IPv6 is not supported.

  • To specify IP addresses of secondary origin servers, use the ["ip1","ip2",...] format. You can add up to 20 IP addresses.

  • To specify secondary back-to-origin domain names, use the ["domain"] format. You can add up to 20 domain names.

2.2.XX.XX

XClientIp

boolean

No

Specifies whether to allow WAF to overwrite the X-Client-IP header. Valid values:

  • true (default): allows WAF to overwrite the header.

  • false: does not allow WAF to overwrite the header.

true

XTrueIp

boolean

No

Specifies whether to allow WAF to overwrite the X-True-IP header. Valid values:

  • true (default): allows WAF to overwrite the header.

  • false: does not allow WAF to overwrite the header.

true

WebServerType

boolean

No

Specifies whether to allow WAF to overwrite the Web-Server-Type header. Valid values:

  • true (default): allows WAF to overwrite the header.

  • false: does not allow WAF to overwrite the header.

true

WLProxyClientIp

boolean

No

Specifies whether to allow WAF to overwrite the WL-Proxy-Client-IP header. Valid values:

  • true (default): allows WAF to overwrite the header.

  • false: does not allow WAF to overwrite the header.

true

MaxBodySize

integer

No

The maximum size of the request body. Valid values: 2 to 10. Default value: 2. Unit: GB.

Note

This parameter is supported only by the Ultimate Edition.

2

Http2Origin

boolean

No

Specifies whether to enable HTTP/2 back-to-origin. Valid values:

  • true: enables HTTP/2 back-to-origin.

  • false: disables HTTP/2 back-to-origin.

true

Http2OriginMaxConcurrency

integer

No

The maximum number of concurrent HTTP/2 back-to-origin connections. Valid values: 1 to 512. Default value: 128.

128

BackendPorts

array<object>

No

The custom port configuration.

object

No

The custom port configuration.

ListenPort

integer

No

The listening port.

80

BackendPort

integer

No

The back-to-origin port.

80

Protocol

string

No

The protocol of the listening port. Valid values:

  • http: The protocol of the listening port is HTTP.

  • https: The protocol of the listening port is HTTPS.

http

ProxyProtocol

boolean

No

Specifies whether the feature to preserve the client source IP address is enabled. Valid values:

  • true: The feature is enabled. After this feature is enabled, backend services can view the original IP address of the client.

  • false: The feature is disabled.

false

RegionId

string

Yes

The region where the WAF instance resides. Valid values:

  • cn-hangzhou: the Chinese mainland.

  • ap-southeast-1: outside the Chinese mainland.

cn-hangzhou

AccessType

string

No

The access type of the WAF instance. Valid values:

  • share (default): CNAME access.

  • hybrid_cloud_cname: hybrid cloud CNAME access.

Note

If the value is share, or the value is hybrid_cloud_cname and public cloud disaster recovery is enabled, you must invoke the DescribeVerifyContent and VerifyDomainOwner operations to authenticate the domain name ownership first. If the website config is added to a region in the Chinese mainland, it must also have an ICP filing.

If the value is hybrid_cloud_cname and public cloud disaster recovery is disabled, you do not need to authenticate the domain name ownership and can directly invoke this operation.

share

Tag

array<object>

No

The list of tags, which can contain up to 20 items.

object

No

The tags of the resource. Up to 20 tags are supported.

Key

string

No

The tag key.

Tagkey1

Value

string

No

The tag value.

TagValue1

Response elements

Element

Type

Description

Example

object

The response returned after a domain name is added.

RequestId

string

The request ID.

D7861F61-5B61-46CE-A47C-6B19160D5EB0

DomainInfo

object

The information about the added domain name.

Cname

string

The CNAME address assigned by WAF to the domain name.

xxxxxwww.****.com

Domain

string

The name of the added domain.

www.aliyundoc.com

DomainId

string

The domain name ID.

www.aliyundoc.com-waf

Examples

Success response

JSON format

{
  "RequestId": "D7861F61-5B61-46CE-A47C-6B19160D5EB0",
  "DomainInfo": {
    "Cname": "xxxxxwww.****.com",
    "Domain": "www.aliyundoc.com",
    "DomainId": "www.aliyundoc.com-waf"
  }
}

Error codes

HTTP status code

Error code

Error message

Description

400 Waf.Pullin.ResourceExsit Access resource already exists, resource:%s. Access resource already exists, existing resource:%s.
400 Waf.Pullin.BusinessViolation The web services are suspected of violating regulations. If you have any questions, please submit a work order. Violating resource: %s. The web services are suspected of violating regulations. If you have any questions, please submit a work order. Violating resource: %s.
400 Waf.Pullin.Http2OriginMustOnHttp2Enable When HTTP2 origin is enabled, HTTP2 listening must be enabled. When HTTP2 back-to-source is enabled, HTTP2 listening must be enabled.
400 Waf.Pullin.Http2OriginMustOnKeepaliveEnable When the HTTP2 origin is turned on, the keepalive must be turned on. When the HTTP2 origin is turned on, the keepalive must be turned on.
400 Waf.Pullin.Http2OriginEnabledFocusHttpBackendForbidden When HTTP2 origin is enabled, HTTP origin cannot be enabled. When HTTP2 origin is enabled, HTTP origin cannot be enabled.
400 Waf.Pullin.BatchDnsScheduleCheckFailed Batch dns scheduling is in progress, and access related operations are prohibited. batch dns scheduling is in progress, and access-related operations are prohibited.
400 Waf.Pullin.InvalidMaxAgeWithPreload HstsMaxAge the parameter is incorrect, when the HstsPreload is True, the HstsMaxAge must be greater than or equal to 31536000. HstsMaxAge the parameter is incorrect, when the HstsPreload is True, the HstsMaxAge must be greater than or equal to 31536000
400 Waf.Pullin.InvalidIncludeSubDomainWithPreload The parameter HstsIncludeSubDomain is invalid. When the parameter HstsPreload is true, the HstsIncludeSubDomain must be true. The parameter HstsIncludeSubDomain is invalid. When the parameter HstsPreload is true, the HstsIncludeSubDomain must be true.
400 Waf.Pullin.InvalidCustomCiphers Invalid custom cipher suite. Invalid custom cipher suite.
400 Waf.Pullin.InvalidHttp2OriginWithProxyProtocol http2Origin and proxyProtocol cannot be opened at the same time. http2Origin and proxyProtocol cannot be opened at the same time.

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.