/v2/buckets/cdn/source/

创建/更新 CDN空间回源信息

请求地址

https://api.upyun.com/v2/buckets/cdn/source/

HTTP请求方法

POST

是否需要登陆授权

是,关于登录授权,参见授权机制

请求参数

必选 数据类型及范围 说明
bucket_name true string 空间名
domain false string 回源请求自定义域名,当关闭域名跟随时(domain_follow=disable) 必须设置该字段
cdn true json cdn 详细设置信息
source_type true enum('http', 'https', 'protocol_follow') 回源方式设置:http:http 协议回源;https:https 协议回源;protocol_follow:协议跟随,根据请求的实际协议类型进行回源
domain_follow true enum('enable', 'disable') 回源是否开启域名跟随

当开启 domain_follow 时(domain_follow=enable), 不需要传递 domain 字段,否则需要 domain

cdn 参数格式如下: (分两种情况,建议使用第一种)

1.新接口参数格式

{
  "servers": [
    { "host": "122.255.10.11", "port": 80, "weight": 2, "max_fails": 3, "fail_timeout": 30 },
    { "host": "122.255.10.12", "port": 81, "weight": 2, "max_fails": 3, "fail_timeout": 30 },
    { "host": "122.255.10.13", "port": 80, "weight": 5, "max_fails": 3, "fail_timeout": 30 },
    { "host": "122.255.10.14", "port": 81, "weight": 1, "max_fails": 3, "fail_timeout": 30, "backup": true },
    { "host": "122.255.10.15", "port": 80, "weight": 1, "max_fails": 3, "fail_timeout": 30, "backup": true }
  ]
}

返回结果

{
  "result": true,
  "data":{
    "bucket_name": "bucket",
    "domain": "http://www.example.com",
    "source_type": "protocol_follow",
    "domain_follow": "enable",
    "cdn": {
      "servers": [
        { "host": "122.255.10.11", "port": 80, "weight": 2, "max_fails": 3, "fail_timeout": 30 },
        { "host": "122.255.10.12", "port": 81, "weight": 2, "max_fails": 3, "fail_timeout": 30 },
        { "host": "122.255.10.13", "port": 80, "weight": 5, "max_fails": 3, "fail_timeout": 30 },
        { "host": "122.255.10.14", "port": 81, "weight": 1, "max_fails": 3, "fail_timeout": 30, "backup": true },
        { "host": "122.255.10.15", "port": 80, "weight": 1, "max_fails": 3, "fail_timeout": 30, "backup": true }
      ]
    }
  }
}

2: 老接口参数格式 (兼容老接口)

{
  ctn: {
    "servers": [
      { "host": "122.255.10.11", "port": 80, "weight": 2, "max_fails": 3, "fail_timeout": 30 },
      { "host": "122.255.10.12", "port": 81, "weight": 2, "max_fails": 3, "fail_timeout": 30 },
      { "host": "122.255.10.15", "port": 80, "weight": 1, "max_fails": 3, "fail_timeout": 30, "backup": true }
    ]
  },
  other: {
    "servers": [
      { "host": "122.255.10.11", "port": 80, "weight": 2, "max_fails": 3, "fail_timeout": 30 },
      { "host": "122.255.10.12", "port": 81, "weight": 2, "max_fails": 3, "fail_timeout": 30 },
    ]
  }
}

返回结果

{
  "result": true,
  "data":{
    "bucket_name": "bucket",
    "domain": "http://www.example.com",
    "source_type": "protocol_follow",
    "domain_follow": "enable",
    "cdn": {
      ctn: {
        "servers": [
          { "host": "122.255.10.11", "port": 80, "weight": 2, "max_fails": 3, "fail_timeout": 30 },
          { "host": "122.255.10.12", "port": 81, "weight": 2, "max_fails": 3, "fail_timeout": 30 },
          { "host": "122.255.10.15", "port": 80, "weight": 1, "max_fails": 3, "fail_timeout": 30, "backup": true }
        ]
    },
      other: {
        "servers": [
          { "host": "122.255.10.11", "port": 80, "weight": 2, "max_fails": 3, "fail_timeout": 30 },
          { "host": "122.255.10.12", "port": 81, "weight": 2, "max_fails": 3, "fail_timeout": 30 },
        ]
      }
    }
  }
}
Last edited by chiyu.zhong, 2016-09-19 13:31:56