You can call this operation to add a domain to WAF.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request Parameters

Parameter Type Required Example Description
Action String Yes CreateDomain

The operation that you want to perform. Set the value to CreateDomain.

Domain String Yes www.example.com

The domain that you want to add to WAF.

InstanceId String Yes waf_elasticity-cn-0xldbqtm005

The ID of the WAF instance.

Note You can call the DescribeInstanceInfo operation to query the ID of the WAF instance.
IsAccessProduct Integer Yes 0

Specifies whether to configure a Layer-7 proxy, such as Anti-DDoS Pro or CDN, to filter the inbound traffic before it is forwarded to WAF. Valid values:

  • 0: false
  • 1: true
SourceIps String Yes ["1.1.1.1", "2.2.2.2"]

The IP address or domain of the origin server to which the specified domain points.

Note You can add a maximum of 20 origin IP addresses to implement load balancing or specify only one origin domain. Separate origin IP addresses with commas (,). You can specify either IP addresses or a domain.
LoadBalancing Integer No 0

The load balancing algorithm that is used to forward requests to the origin. Valid values:

  • 0: IP hash
  • 1: Round robin
LogHeaders String No [{"k":"wafmark","v":"test"}]

The key-value pair that is used to mark the traffic that flows through WAF to the domain.

The style of the parameter value is[{"k":"_key_","v":"_value_"}]. Where, _Key_ represents the specified custom request header field,_Value_ indicates the value set for this field.

WAF automatically marks the requests that pass through WAF by adding the specified field and value to the headers of these requests.

Note If a request header contains the specified field, WAF overwrites the original field value with the specified value.
HttpPort String No [80]

The HTTP ports. Separate multiple ports with commas (,).

Note Set this parameter only if you want to use the HTTP protocol. You must set at least one of the HttpPort and HttpsPort parameters.
HttpsPort String No [443]

The HTTPS ports. Separate multiple HTTPS ports with commas (,).

Note Set this parameter only if you want to use the HTTPS protocol. You must set at least one of the HttpPort and HttpsPort parameters.
Http2Port String No [443]

The HTTP 2.0 ports. Separate multiple ports with commas (,).

HttpToUserIp Integer No 0

Specifies whether to enable the HTTP back-to-origin feature. After this feature is enabled, the WAF instance can use HTTP to forward HTTPS requests to the origin server. By default, port 80 is used to forward the requests to the origin server. Valid values:

  • 0: disables the feature (default)
  • 1: enables the feature
Note If your website does not support HTTPS access, you can enable the HTTP back-to-origin feature to enable HTTPS access through WAF.
HttpsRedirect Integer No 0

Specifies whether to redirect HTTP requests as HTTPS requests. Valid values:

  • 0: no (default)
  • 1: yes
Note This parameter is required only if the specified domain only accepts HTTPS requests. After you enable this feature, HTTP requests are redirected to HTTPS port 443.
ClusterType Integer No 0

The type of the WAF cluster. Valid values:

  • 0: shared cluster (default)
  • 1: exclusive cluster
ResourceGroupId String No rg-atstuj3rtoptyui

The ID of the resource group to which the queried domain belongs in Resource Management. By default, no value is specified, indicating that the domain belongs to the default resource group.

ConnectionTime Integer No 5

The connection timeout for WAF exclusive clusters. Unit: seconds.

Note You can specify this parameter when you use exclusive clusters.
ReadTime Integer No 120

The read timeout of a WAF exclusive cluster. Unit: seconds.

Note You can specify this parameter when you use exclusive clusters.
WriteTime Integer No 120

The timeout period for a WAF exclusive cluster write connection. Unit: seconds.

Note You can specify this parameter when you use exclusive clusters.

Response parameters

Parameter Type Example Description
Cname String xxxxxx.yundunwaf3.com

The CNAME record assigned by the WAF instance to the specified domain.

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

The ID of the request.

Examples

Sample requests

http(s)://[Endpoint]/? Action=CreateDomain
&Domain=www.example.com
&InstanceId=waf_elasticity-cn-0xldbqtm005
&IsAccessProduct=0
&SourceIps=["1.1.1.1", "2.2.2.2"]
&HttpPort=[80]
&<Common request parameters>

Sample success responses

XML format

<Cname>xxxxxx.yundunwaf3.com</Cname>
<RequestId>D7861F61-5B61-46CE-A47C-6B19160D5EB0</RequestId>

JSON format

{
    "Cname":"xxxxxx.yundunwaf3.com",
    "RequestId":"D7861F61-5B61-46CE-A47C-6B19160D5EB0"
}

Error code

For a list of error codes, visit the API Error Center.