Baidu AI Cloud
中国站

百度智能云

CDN

Create the Acceleration Domain Name Interface

Interface

This interface is used to create a specified domain name.

Method Path Description
PUT /v2/domain/{domain} Create an accelerated domain name

domain: It represents the accelerated domain name in which CDN is to create.

Request body

Parameter Optional Type Description
origin Required List type, means OriginPeer. Origin server configuration
defaultHost Optional String Host header by default; when the origin server level host is inexistent, the default host of domain name level is used
form Optional Assign the domain name business type It is “default”, and other optional values are: “image” indicating small image file, “download” indicating a large file downloading, “media” indicating streaming media on demand and “dynamic” indicating dynamic and static acceleration.
follow302 Optional Bool Enable origin-forwarded follow 302

The OriginPeer types are as follows:

Parameter Optional Type Description
peer Required String The format is {protocol://}{address}{:port}, where protocol is optional, and it only supports https at present; port is optional, including http origin port and https origin port. When protocol is https, set it to https origin port, otherwise, set it to http origin port, and the default is http origin port; address shall be ip or domain name, and it already supports ipv6 address at present. ipv6 address shall be in '[ipv6]' format.
host Optional String The host value used when forwarding to origin. The host is a host on origin server level. Each origin server can be configured with one host.
backup Optional Bool Backup origin server
weight Optional int Origin server weight, an integer between 0-100, it indicates the origin weight of this origin server. The default is forwarding to origin in equal weights. Note Sum of weights of all origin servers cannot be greater than 100. When there is no default value, sum of weights of all origin servers shall be equal to 100. Origin servers in the DOMAIN type can only have one primary and one standby site. There is no practical significance in setting this parameter. For example: Allocate origin traffic based on weight. For example, 1G forward to origin, 2 ip addresses, in which, one ip weighs for 80%, and the other 20%, then one ip has a forward to origin of about 800M and the other has a forward to origin of about 200M.

Response code (Http Status Code)

HTTP Status Code Description
201 Created successfully
400 Domain name already exists, domain name check failed, lack necessary parameters, parameter value error and domain name blocked.

Response body

Parameter Type Description
insId String Corresponding instance ID of domain name
status String The status returned after it was just created successfully is OPERATING.
cname String The CNAME domain name generated is accelerated by the user through acceleration domain name CNAME to the domain name

Request example - specify the http origin port

PUT /v2/domain/1.test.com HTTP/1.1 
Host: cdn.baidubce.com 
Accept: */* 
Content-Length: 77
Content-Type: application/x-www-form-urlencoded
{ 
    "origin":[ 
        { 
            "peer":"http://129.226.184.12:8001", 
            "host":"myhost.com" 
        } 
    ] 
} 

Request example - use ipv4 origin server

PUT /v2/domain/1.test.com HTTP/1.1 
Host: cdn.baidubce.com 
Accept: */* 
Content-Length: 77
Content-Type: application/x-www-form-urlencoded
{ 
  "origin": 
  [ 
    {"peer": "http://origin.server.com", "host": "myhost.com"} 
  ], 
  "form":"image" 
} 

Request example - use ipv6 origin server

PUT /v2/domain/1.test.com HTTP/1.1 
Host: cdn.baidubce.com 
Accept: */* 
Content-Length: 77
Content-Type: application/x-www-form-urlencoded
{ 
    "origin": [ 
        { 
            "peer": "http://[2001:da8:20d:22::2]:80", 
            "host": "aonetest" 
        } 
    ] 
} 

Request example - configure ipv4 and ipv6 origin servers at the same time

PUT /v2/domain/1.test.com HTTP/1.1 
Host: cdn.baidubce.com 
Accept: */* 
Content-Length: 77
Content-Type: application/x-www-form-urlencoded
{ 
    "origin": [ 
        { 
            "peer": "http://[2001:250:3003:13::94]", 
            "host": "ipv6.stu.edu.cn" 
        }, 
        { 
            "peer": "http://129.226.184.12", 
            "host": "aonetest" 
        } 
    ] 
} 

Response example

HTTP/1.1 201 Created 
Server: nginx 
Date: Thu, 20 Jun 2019 09:34:05 GMT 
Content-Type: application/json; charset=utf-8 
Transfer-Encoding: chunked 
Connection: keep-alive 
X-Powered-By: PHP/7.1.5 
x-bce-request-id: e50749de-3e03-e9a8-6ed5-8d29b26730e9

{"insId":"xxx-xxx","status":"OPERATING","cname":"domain.a.bdydns.com"} 
Previous
Query all the Domain Names under the User name
Next
Enable the Acceleration Domain Name Interface