百度智能云

All Product Document

          CDN

          Update the Forward-to-origin Address of the Acceleration Domain Name

          Interface

          This interface is used to update the origin address of the specified accelerated domain name. The domain name shall belong to the user, otherwise it returns 403 failure.

          Method Path Description
          PUT /v2/domain/{domain}/config?origin Modify configuration of the accelerated domain name

          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
          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 Whether it is a standby origin server, true indicates it is the primary origin server, and false indicate it is the standby origin server; it defaults to false
          follow302 Optional Bool Enable origin-forwarded follow 302
          backup Optional Bool Whether it is a backup origin server. True means the backup origin server, false means the master origin server. It is false by the default
          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, there is 1 G origin traffic and 2 IPs. Weight of one IP is 80%, and the other is 20%, then one IP has about 800M origin and the other has about 200M origin.

          Response code (Http Status Code)

          HTTP Status Code Description
          200 Success

          Response body

          Parameter Type Description
          status String The status returned after it was just updated successfully is RUNNING.

          Request example

          The request below sets two original servers for the domain myself.baidu.com. Origin server 1 is HTTP protocol type, with the IP of 1.1.1.1 and port of 8888. CDN node forwarding to origin is provided with request header “Host: www.baiducdn.com”. No backup field is set, and it is taken as the default setting Yes, that is, false indicates that it is a primary origin server. The origin server 2 is an origin server in the type of HTTPS protocol, and the IP is 2.2.2.2. The port is 443 by default if not set, and the Host header is also www.baiducdn.com. It is a standby origin server.

          PUT /v2/domain/myself.baidu.com/config?origin HTTP/1.1 
          Host: cdn.baidubce.com 
          Content-Length: 178
          Content-Type: text/json;utf-8
           
          { 
              "origin":[ 
                  { 
                      "peer":"http://1.1.1.1:8888", 
                      "host":"www.baiducdn.com" 
                  }, 
                  { 
                      "peer":"https://2.2.2.2", 
                      "host":"www.baiducdn.com", 
                      "backup":true 
                  } 
              ], 
              "defaultHost":"www.baidu.com", 
              "follow302":true 
          } 

          Response example

          HTTP/1.1 200 OK 
          Server: nginx 
          Date: Thu, 20 Jun 2019 10:19:38 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: e38a0c7d-388e-ac0b-6238-b674b4ea7bfc
          
          {"status":"RUNNING"} 

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

          PUT /v2/domain/myself.baidu.com/config?origin 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 200 OK 
          Server: nginx 
          Date: Thu, 20 Jun 2019 10:19:38 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: e38a0c7d-388e-ac0b-6238-b674b4ea7bfc
          
          {"status":"RUNNING"} 
          Previous
          Set the Mobile Access Control
          Next
          Query and Get Real User IP