All Products
Search
Document Center

Web Application Firewall:CreateDomain

Last Updated:Jan 20, 2025

Adds a domain name to Web Application Firewall (WAF).

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:
    • For mandatory resource types, indicate with a prefix of * .
    • 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
yundun-waf:CreateDomaincreate
*All Resources
*
    none
none

Request parameters

ParameterTypeRequiredDescriptionExample
InstanceIdstringYes

The ID of the Web Application Firewall (WAF) instance.

Note You can call the DescribeInstance operation to obtain the ID of the WAF instance.
waf_cdnsdf3****
ResourceManagerResourceGroupIdstringNo

The ID of the resource group.

rg-acfm***q
DomainstringYes

The domain name that you want to add to WAF.

www.aliyundoc.com
ListenobjectYes

The listener configurations.

HttpsPortsarrayNo

The HTTPS listener ports.

integerNo

The HTTPS listener port. Specify the value in the [port1,port2,...,portN] format.

[443,8443]
HttpPortsarrayNo

The HTTP listener ports.

integerNo

The HTTP listener port. Specify the value in the [port1,port2,...] format.

[80,81]
Http2EnabledbooleanNo

Specifies whether to enable HTTP/2. This parameter is available only if you specify HttpsPorts. Valid values:

  • true
  • false (default)
true
CertIdstringNo

The ID of the certificate that you want to add. This parameter is available only if you specify HttpsPorts.

123
SM2EnabledbooleanNo

Specifies whether to add an SM certificate.

true
SM2CertIdstringNo

The ID of the SM certificate that you want to add. This parameter is available only if you set SM2Enabled to true.

123-cn-hangzhou
SM2AccessOnlybooleanNo

Specifies whether to allow access only from SM certificate-based clients. This parameter is available only if you set SM2Enabled to true.

  • true
  • false
true
TLSVersionstringNo

The Transport Layer Security (TLS) version that you want to add. This parameter is available only if you specify HttpsPorts. Valid values:

  • tlsv1
  • tlsv1.1
  • tlsv1.2
tlsv1
EnableTLSv3booleanNo

Specifies whether to support TLS 1.3. This parameter is available only if you specify HttpsPorts. Valid values:

  • true
  • false
true
CipherSuiteintegerNo

The type of the cipher suites that you want to add. This parameter is available only if you specify HttpsPorts. Valid values:

  • 1: all cipher suites.
  • 2: strong cipher suites. This value is available only if you set TLSVersion to tlsv1.2.
  • 99: custom cipher suites.
2
CustomCiphersarrayNo

The custom cipher suites that you want to add.

stringNo

The custom cipher suite that you want to add. This parameter is available only if you set CipherSuite to 99.

["xxx","ffas"]
FocusHttpsbooleanNo

Specifies whether to enable force redirect from HTTP to HTTPS for received requests. This parameter is available only if you specify HttpsPorts and leave HttpPorts empty. Valid values:

  • true
  • false
true
XffHeaderModeintegerNo

The method that is used to obtain the originating IP address of a client. Valid values:

  • 0 (default): Client traffic is not filtered by a Layer 7 proxy before the traffic reaches WAF.
  • 1: WAF reads the first value of the X-Forwarded-For (XFF) header field as the originating IP address of the client.
  • 2: WAF reads the value of a custom header field as the originating IP address of the client.
1
XffHeadersarrayNo

The custom header fields that are used to obtain the originating IP address of a client.

stringNo

The custom header field that is used to obtain the originating IP address of a client. Specify the value in the ["header1","header2",...] format.

Note This parameter is required only if you set XffHeaderMode to 2.
["Client-ip","cip"]
IPv6EnabledbooleanNo

Specifies whether to enable IPv6 protection. Valid values:

  • true
  • false (default)
true
ProtectionResourcestringNo

The type of the protection resource. Valid values:

  • share (default): a shared cluster.
  • gslb: shared cluster-based intelligent load balancing.
share
ExclusiveIpbooleanNo

Specifies whether to enable the exclusive IP address feature. This parameter is available only if you set IPv6Enabled to false and ProtectionResource to share. Valid values:

  • true
  • false (default)
true
RedirectobjectYes

The forwarding configurations.

BackendsarrayNo

The IP addresses or domain names of the origin server.

stringNo

The IP address or domain name of the origin server. You cannot specify both IP addresses and domain names. If you specify domain names, the domain names can be resolved only to IPv4 addresses.

  • If you specify IP addresses, specify the value in the ["ip1","ip2",...] format. You can enter up to 20 IP addresses.
  • If you specify domain names, specify the value in the ["domain"] format. You can enter up to 20 domain names.
[ "1.1.XX.XX", "2.2.XX.XX" ]
LoadbalancestringYes

The load balancing algorithm that you want to use to forward requests to the origin server. Valid values:

  • iphash
  • roundRobin
  • leastTime: This value is available only if you set ProtectionResource to gslb.
roundRobin
FocusHttpBackendbooleanNo

Specifies whether to enable force redirect from HTTPS to HTTP for back-to-origin requests. This parameter is available only if you specify HttpsPorts. Valid values:

  • true
  • false
true
SniEnabledbooleanNo

Specifies whether to enable the Server Name Indication (SNI) feature for back-to-origin requests. This parameter is available only if you specify HttpsPorts. Valid values:

  • true
  • false (default)
true
SniHoststringNo

The custom value of the SNI field. If you do not specify this parameter, the value of the Host header field is automatically used. In most cases, you do not need to specify a custom value for the SNI field. However, if you want WAF to use an SNI field whose value is different from the value of the Host header field in back-to-origin requests, you can specify a custom value for the SNI field.

Note This parameter is required only if you set SniEnabled to true.
www.aliyundoc.com
RequestHeadersarray<object>No

The custom header fields, which are key-value pairs. The fields are used to mark requests that pass through WAF.

When a request passes through WAF, WAF automatically adds the custom header fields to the request to mark the request. This way, the backend service can identify requests that are processed by WAF.

objectNo

The custom header field. Specify the value in the [{"k":"key","v":"value"}] format. key specifies the key of a custom header field. value specifies the value of a custom header field.

KeystringNo

The key of the custom header field.

aaa
ValuestringNo

The value of the custom header field.

bbb
ConnectTimeoutintegerNo

The timeout period of connections. Unit: seconds. Valid values: 1 to 3600.

120
ReadTimeoutintegerNo

The timeout period of read connections. Unit: seconds. Valid values: 1 to 3600.

200
WriteTimeoutintegerNo

The timeout period of write connections. Unit: seconds. Valid values: 1 to 3600.

200
CnameEnabledbooleanNo

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

  • true
  • false (default)
true
RoutingRulesstringNo

The forwarding rules for the hybrid cloud mode. The value is a string that consists of JSON arrays. Each element in a JSON array is a JSON struct that contains the following fields:

  • rs: the back-to-origin IP addresses or CNAMEs. Data type: array.
  • location: the name of the protection node. Data type: string.
  • locationId: the ID of the protection node. Data type: long.
[ { "rs": [ "1.1.XX.XX" ], "locationId": 535, "location": "test1111" } ]
KeepalivebooleanNo

Specifies whether to enable the persistent connection feature. Valid values:

  • true (default)
  • false
true
RetrybooleanNo

Specifies whether WAF retries if WAF fails to forward requests to the origin server. Valid values:

  • true (default)
  • false
true
KeepaliveRequestsintegerNo

The number of reused persistent connections. Valid values: 60 to 1000.

Note This parameter specifies the number of persistent connections that can be reused after you enable the persistent connection feature.
1000
KeepaliveTimeoutintegerNo

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

Note This parameter specifies the period of time after which an idle persistent connection is closed.
15
XffProtobooleanNo

Specifies whether to use the X-Forward-For-Proto header field to pass the protocol used by WAF to forward requests to the origin server. Valid values:

  • true (default)
  • false
true
BackupBackendsarrayNo

The secondary IP addresses or domain names of the origin server.

stringNo

The secondary IP address or domain name of the origin server. You cannot specify both IP addresses and domain names. If you specify domain names, the domain names can be resolved only to IPv4 addresses.

  • If you specify IP addresses, specify the value in the ["ip1","ip2",...] format. You can enter up to 20 IP addresses.
  • If you specify domain names, specify the value in the ["domain"] format. You can enter up to 20 domain names.
[ "1.1.XX.XX", "2.2.XX.XX" ]
RegionIdstringYes

The region where the WAF instance resides. Valid values:

  • cn-hangzhou: the Chinese mainland
  • ap-southeast-1: outside the Chinese mainland
cn-hangzhou
AccessTypestringNo

The mode in which you want to add the domain name to WAF. Valid values:

  • share: adds the domain name to WAF in CNAME record mode. This is the default value.
  • hybrid_cloud_cname: adds the domain name to WAF in hybrid cloud reverse proxy mode.
share
Tagarray<object>No

The tags. You can specify up to 20 tags.

objectNo

The tag. You can specify up to 20 tags.

KeystringNo

The key of the tag.

Tagkey1
ValuestringNo

The value of the tag.

TagValue1

Response parameters

ParameterTypeDescriptionExample
object

The response parameters.

RequestIdstring

The ID of the request.

D7861F61-5B61-46CE-A47C-6B19160D****
DomainInfoobject

The information about the domain name that is added.

Cnamestring

The CNAME that is assigned by WAF to the domain name.

xxxxxwww.****.com
Domainstring

The domain name that you added to WAF.

www.aliyundoc.com
DomainIdstring

The name of the protected object that is generated.

www.aliyundoc.com-waf

Examples

Sample success responses

JSONformat

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

Error codes

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

Change history

Change timeSummary of changesOperation
2024-12-12The request parameters of the API has changed. The response structure of the API has changedView Change Details
2024-11-28The internal configuration of the API is changed, but the call is not affectedView Change Details
2024-01-30The internal configuration of the API is changed, but the call is not affectedView Change Details
2023-04-27The request parameters of the API has changedView Change Details
2023-04-18The request parameters of the API has changedView Change Details
2023-03-31The request parameters of the API has changedView Change Details