2. Domain 域名相关 API 配置

URL: https://api-client.apeirocdn.com/api/v1

1. resources.domains.list 呈现当前的域名列表

Method : GET

① 示范 (curl 模式)

curl --location 'https://api-client.apeirocdn.com/api/v1/resources/domains?groupName=cdn-xxx&from=0&size=10&filters=servername:example.com' \
--header 'Cookie: access_token=my-token' \

Parameter :

栏位
类型
预设/填写范例
描述

groupName

required

string

groupName=cdn-xxx

项目的群组名称

from

integer

Default: 0

Example: from=0

从 n 开始检索

size

integer

Default: 10

Example: size=10

要检索的项目的数量

filters

string

Default: " "

filters=itemName:my_name Example: filters=servername:example.com

用于检索项目的过滤器。

  • 使用 +AND 来分隔过滤特征

  • 使用 * 作为通配符

  • itemName=栏位名称 my_name=该栏位后面的 value

2. resources.domains.create 添加域名

Method : POST

① 示范 (curl 模式)

curl --location --request POST \
  --url 'https://api-client.apeirocdn.com/api/v1/resources/domains?groupName=cdn-xxx' \
  --header 'content-type: application/json' \
  --header 'Cookie: access_token=my-token' \
  --data '{"servername":"example.com","serviceGroupName":"cdn-xxx-a01-ws","origins":["1.1.1.1","www.example.com"]}'

当域名是添加在 AppProfile 里时 (AppProfile 不为空值): serviceGroupName 和 origins 这两个参数就会是套用 AppProfile 的设定,因此可以不用填写 (非必填)。尽管域名可以从 AppProfile 套用大多数的参数,但 useSystemCert 和 keypairname 这两个参数仍需要个别填写。

Parameter :

栏位
类型
预设/填写范例
描述

groupName

required

string

groupName=cdn-xxx

项目的群组名称

Body :

栏位
类型
预设/填写范例
描述

description

string

Default: ""

注解字段

tags

Array of strings

unique

Default: [""]

标签内容

servername

required

string

^[a-z0-9-_.]*$

Example: "example.com"

接入 CDN 的域名,如有 IDN 域名请用 punycode 接入,例如使用 ".xn--fiqs8s" 代表 ".中国"

useSystemCert

boolean

Default: true

使用系统凭证

keypairname

string

Default: "self-sign"

填写凭证组名称,仅在 useSystemCert: false 时生效

appProfileName

string

<= 35 characters

^[a-z0-9-_.]*$

Default: "none"

指定 profile 名称,参见 resources.app-profiles.list

serviceGroupName

required if appProfileName is none

string

Example: "cdn-xxx-a01-ws"

指定 service group,参见 resources.servicegroups.list。当 appProfileName 为空值时,必填 body 值

useOriginPolicy

boolean

Default: false

是否使用回源策略

usedOriginPolicies

Array of objects

unique

Default: [] Example: {"regionName": ["default"],"originPolicyName": "testoriginpolicy"}

填写回源策略名称,仅在 useOriginPolicy: true 时生效。useOriginPolicy: true 时,必填 body 值。regionName 可填写国家代码,例如 China=CN, Hongkong=HK,default 必填

origins

required if appProfileName is none

Array of strings

>= 0 items unique

Example: ["1.1.1.1", "www.example.com"]

填写回源目标,支持公网 IP 和完全域名,仅在 useOriginPolicy: false 时生效。appProfileName 为空值时,必填 body 值

originscheme

string

Default: "http" Enum: "http", "https"

该域名的来源协议

portMappingType

string

Default: "default" Enum: "default", "static"

该域名的端口映射类型

originPort

integer

Default: 80

该域名的来源端口

scheme

Array of strings

non-empty unique

Default: ["http", "https"] Enum: "http", "https"

该域支持的访问模式

httpPort

Array of integers

non-empty unique

Default: [80]

http 监听端口。多选范围:80, 8080, 8880, 2052, 2082, 2086, 2095。预设为 [80]

httpsPort

Array of integers

non-empty unique

Default: [443]

https 监听端口。多选范围:443 及 1001-4999、6001-32767(除了 httpPort 和 9600 不可选)。预设为 [443]

redirecthttps

boolean

Default: false

是否将 HTTP 的访问跳转到 HTTPS

useHsts

boolean

Default: false

是否启用 HSTS

usedWafRules

Array of objects

unique

Default: [] Example: {"value": "ruleName", "isEnabled": true}

该域名的 WAF 规则。规则将按顺序检查并依次执行,例如第一条规则触发 "允许" 操作,则不会检查后续规则。

errorHtmlPageName

string

Default: "default"

当访问出现 5xx 错误时显示在客户端上的错误页面。参见 resources.htmlpages.list

upstreamTimeout

integer

Default: 60 Enum: 60, 120, 180

回源超时数值设定

isEnabledCompressionToOrigin

boolean

Default: true

是否启用源站压缩功能。预设开启。

isInsertRidHeaderToOrigin

boolean

Default: false

如果启用,CDN 将在客户访问时插入我们平台生成的 rid header

setCustomHostHeader

string

Default: "off" Enum: "on", "off"

如果启用,CDN 将在回源时透过指定的 host header 回源

customHostHeader

string

Example: "example.com"

当 setCustomHostHeader: "on" 时需填入指定回源 host header

websocketPath

string

Default: ""

多个路径,用 \n 分隔

proxyBufferSize

integer

Default: 4 Enum: 2, 4, 8, 16, 32, 64

设置客户端请求传递给 CDN 时使用的缓冲区大小

proxySetHeader

Array of strings

Default: [] Example: ["CDN-Request-ID","CDN-IP-Location","CDN-Internet-Service-Provider",”CDN-JA3”,” CDN-JA3-Hash”]

Edge 插入请求表头并回传到源站,若源站需抓取此表头 log,参考设置为以下 : http_cdn_request_id http_cdn_ip_location http_cdn_internet_service_provider http_cdn_ja3 http_cdn_ja3_hash ”custom_key” (詳請參考欄位customVariables)

isUpgradeInsecureRequest

boolean

Default: false

启用 UpgradeInsecureRequest header,用于尝试将 "http" 请求切换为 "https" 请求

maxUploadSize

integer

[1 .. 100]

Default: 1 (单位:MB)

客户端与 CDN 之间的最大上传大小限制

cusFollowCachePath

string

Default: ""

缓存遵循源站路径,多个路径,用 \n 分隔

cusFollowCacheFile

string

Default: ""

缓存遵循源站文件,多个路径,用 \n 分隔

cusCachepathExp

string

Default: "5"

浏览器上的缓存路径到期时间,预设为 5 分钟,设定范围:5-129600 分钟。

cusCachepathSrvexp

string

Default: "5"

CDN 上的缓存路径到期时间,预设为 5 分钟,设定范围:5-129600 分钟。

cusCachefileExp

string

Default: "5"

浏览器上的缓存文件到期时间,预设为 5 分钟,设定范围:5-129600 分钟。

cusCachefileSrvexp

string

Default: "5"

CDN 上的缓存文件到期时间,预设为 5 分钟,设定范围:5-129600 分钟。

defCachefileExp

string

Default: "5"

未指定时,浏览器上的默认缓存文件到期时间,预设为 5 分钟,设定范围:5-129600 分钟。

defCachefileSrvexp

string

Default: "5"

未指定时,CDN 上的默认缓存文件到期时间,预设为 5 分钟,设定范围:5-129600 分钟。

proxyCacheIgnoreArgs

boolean

Default: false

是否忽略参数的缓存键

cusCachepath

string

Default: ""

域名的缓存路径,多个路径用 \n 分隔

cusCachefile

string

Default: ""

域名的缓存文件,多个路径用 \n 分隔

forceCusCachePath

string

Default: ""

域名的强制缓存路径,多个路径用 \n 分隔

forceCusCacheFile

string

Default: ""

域名的强制缓存文件,多个路径用 \n 分隔

cusNoncachepath

string

Default: ""

域名的不缓存路径,多个路径用 \n 分隔

cusNoncachefile

string

Default: ""

域名的不缓存文件,多个路径用 \n 分隔

defNoncachepath

string

Default: "/"

域名的默认不缓存路径,多个路径用 \n 分隔

isAcceptHttpV1

boolean

Default: false

是否接受 HTTP v1 的访问形式

isEnabledUpstreamHttp11

boolean

Default: true

是否启用 HTTP 1.1 回源

redirectHttpCode

string

Default: "302"

重定向 HTTP 代码

cnameFormat

Array of strings

unique

Default: ["customize"] Enum: "customize", "system"

指定域名解析预设为自定义 CNAME 或随机生成的 CNAME

customVariables

Array of objects

Default: [] Example: {"key": "custom_key", "value": "custom_value"}

自訂變數選項,填寫後可將key用於proxySetHeader 欄位當中

3. resources.domains.get 获取域名信息

Method : GET

① 示范 (curl 模式)

Path :

栏位
类型
预设/填写范例
描述

servernameId

required

string

Example: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx

要检索的域名,必须以域名的物件 ID,(您可以点击「显示栏位 > ☑ 物件 ID」查看对应的物件 ID,或是在 api 回应中的"_id"栏位中,也能够找到对应 ID)

Parameter :

栏位
类型
预设/填写范例
描述

groupName

required

string

groupName=cdn-xxx

项目的群组名称

4. resources.domains.update 更新域名

Method : PATCH

① 示范 (curl 模式)

Path :

栏位
类型
预设/填写范例
描述

servernameId

required

string

Example: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx

要检索的域名,必须以域名的物件 ID,(您可以在 portal 点击「显示栏位 > ☑ 物件 ID」查看对应的物件 ID。)

Parameter :

栏位
类型
预设/填写范例
描述

groupName

required

string

groupName=cdn-xxx

项目的群组名称

Body :

栏位
类型
预设/填写范例
描述

description

string

Default: ""

注解字段

tags

Array of strings

unique

Default: [""]

标签内容

appProfileName

string

<= 35 characters

^[a-z0-9-_.]*$

Default: "none"

指定 profile 名称,参见 resources.app-profiles.list

useSystemCert

boolean

Default: true

使用系统凭证

keypairname

string

Default: "self-sign"

填写凭证组名称,仅在 useSystemCert: false 时生效

serviceGroupName

string

Example: "cdn-xxx-a01-ws"

指定 servicegroup,参见 resources.servicegroups.list

useOriginPolicy

boolean

Default: false

是否使用回源策略

usedOriginPolicies

Array of objects

unique

Default: [] Example: {"regionName":["default"],"originPolicyName":"testoriginpolicy"}

  • 填写回源策略名称,仅在 useOriginPolicy:true 时生效,useOriginPolicy:true 时必填 body 值

  • regionName 可以填写国家代码 ex: china=CN,Hongkong=HK,default 必填

origins

Array of strings

>= 0 items

unique

Example: ["1.1.1.1","www.example.com"]

填写回源目标,支持公网 IP 和 FQDN,仅在 useOriginPolicy:false 时生效

originscheme

string

Default: "http" Enum: "http" "https"

该域名的回源协议

portMappingType

string

Default: "default" Enum: "default" "static"

该域名的端口映射类型

originPort

integer

Default: 80

该域名的回源端口

scheme

Array of strings

non-empty

unique

Default: "http" "https" Enum: "http" "https"

该域支持的访问模式

httpPort

Array of integers

non-empty

unique

Default: [80]

http 监听端口。 多选,可选范围 80, 8080, 8880, 2052, 2082, 2086, 2095。 预设:[80]。

httpsPort

Array of integers

non-empty

unique

Default: [443]

https 监听端口。 多选,可选范围 443 及 1001-4999、6001-32767。除了 httpPort 和 9600 不可选。 预设:[443]

redirecthttps

boolean

Default: false

是否将 HTTP 的访问跳转到 HTTPS

useHsts

boolean

Default: false

是否启用 HSTS

usedWafRules

Array of objects

unique

Default: [] Example: {"value":"ruleName","isEnabled":true}

该域名的 WAF 规则,必填 body。规则将按顺序检查和依序执行下去。例如,如果第一条规则触发"允许"操作,则不会检查之后的规则。

errorHtmlPageName

string

Default: "default"

当访问出现 5xx 错误时显示在客户端上的错误页面 cresources.htmlpages.list

upstreamTimeout

integer

Default: 60 Enum: 60 120 180

回源超时数值设定

isEnabledCompressionToOrigin

boolean

Default: true

是否启用源站压缩功能。预设开启。

isInsertRidHeaderToOrigin

boolean

Default: false

如果启用,CDN 将在客户访问时插入我们平台生成的 rid header

setCustomHostHeader

string

Default: "off" Enum: "on" "off"

如果启用,CDN 将在回源时透过指定的 host header 回源

customHostHeader

string

Example: "example.com"

必填 body 值,当 setCustomHostHeader:"on" 时需填入指定回源

websocketPath

string

Default: ""

多个路径,用\n分隔

proxyBufferSize

integer

Default: 4 Enum: 2 4 8 16 32 64

设置客户端请求传递给 CDN 时使用的缓冲区大小

proxySetHeader

Array of strings

Default: [] Example: ["CDN-Request-ID","CDN-IP-Location","CDN-Internet-Service-Provider",”CDN-JA3”,” CDN-JA3-Hash”]

Edge 插入请求表头并回传到源站,若源站需抓取此表头 log,参考设置为以下 : http_cdn_request_id http_cdn_ip_location http_cdn_internet_service_provider http_cdn_ja3 http_cdn_ja3_hash ”custom_key” (詳請參考欄位customVariables)

isUpgradeInsecureRequest

boolean

Default: false

启用 UpgradeInsecureRequest header,该 header 可以尝试将"http"请求切换为"https"请求

maxUploadSize

integer

[ 1 .. 100 ]

Default: 1 Unit is MB

客户端和 CDN 之间的最大上传大小限制

cusFollowCachePath

string

Default: ""

缓存遵循源站路径,多个路径,用\n分隔

cusFollowCacheFile

string

Default: ""

缓存遵循源站档案,多个路径,用\n分隔

cusCachepathExp

string

Default: "5"

浏览器上的缓存路径到期时间。预设为 5 分钟,设定范围:5-129600 分钟。

cusCachepathSrvexp

string

Default: "5"

CDN 上的缓存路径到期时间。预设为 5 分钟,设定范围:5-129600 分钟。

cusCachefileExp

string

Default: "5"

浏览器上的缓存文件到期时间。预设为 5 分钟,设定范围:5-129600 分钟。

cusCachefileSrvexp

string

Default: "5"

CDN 上的缓存文件到期时间。预设为 5 分钟,设定范围:5-129600 分钟。

defCachefileExp

string

Default: "5"

未指定时,浏览器上的默认缓存文件到期时间。预设为 5 分钟,设定范围:5-129600 分钟。

defCachefileSrvexp

string

Default: "5"

未指定时,CDN 上的默认缓存文件到期时间。预设为 5 分钟,设定范围:5-129600 分钟。

proxyCacheIgnoreArgs

boolean

Default: false

是否忽略参数的缓存键

cusCachepath

string

Default: ""

域名的缓存路径,多个路径用\n分隔

cusCachefile

string

Default: ""

域名的缓存文件,多个路径用\n分隔

forceCusCachePath

string

Default: ""

域名的强制缓存路径,多个路径用\n分隔

forceCusCacheFile

string

Default: ""

域名的强制缓存文件,多个路径用\n分隔

cusNoncachepath

string

Default: ""

域名的不缓存路径,多个路径用\n分隔

cusNonachefile

string

Default: ""

域名的不缓存文件,多个路径用\n分隔

defNoncachepath

string

Default: "/"

域名的不缓存文件,多个路径用\n分隔

isAcceptHttpV1

boolean

Default: false

是否接受以 HTTP v1 的形式访问

isEnabledUpstreamHttp11

boolean

Default: true

是否启用 HTTP 1.1 回源

redirectHttpCode

string

Default: "302"

重定向 HTTP 代码

cnameFormat

Array of strings

unique

Enum: "customize" "system" Example:["customize"]

指定域名解析预设的 cname or 乱数 cname

customVariables

customVariables

Default: [] Example: {"key": "custom_key", "value": "custom_value"}

自訂變數選項,填寫後可將key用於proxySetHeader 欄位當中

5. resources.domains.delete 删除域名

Method : DELETE

① 示范 (curl 模式)

Path :

栏位
类型
预设/填写范例
描述

servernameId

required

string

Example: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx

要检索的域名,必须以域名的物件 ID,(您可以在 portal 点击「显示栏位 > ☑ 物件 ID」查看对应的物件 ID。)

Parameter :

栏位
类型
预设/填写范例
描述

groupName

required

string

groupName=cdn-xxx

项目的群组名称

6. purge cache of the domain 针对域名清除缓存

Method : POST

① 示范 (curl 模式)

Parameter :

栏位
类型
预设/填写范例
描述

groupName

required

string

groupName=cdn-xxx

项目的群组名称

Body :

栏位
类型
预设/填写范例
描述

domain

required

string

my-domain1.com

项目的域名名称

key

Array of objects

non-empty

/image

清除缓存路径/资源格式

7. OWASP 相关设定

Method : 添加域名 : POST

Method : 更新域名 : PATCH

① 示范 (curl 模式)

上述为添加域名 : POST 的代码,如要更新域名请将 "--request" 更改为 PATCH。

Parameter :

栏位
类型
预设/填写范例
描述

groupName

required

string

groupName=cdn-xxx

项目的群组名称

Body :

栏位
类型
预设/填写范例
描述

isUseOwasp

boolean

Default: false

使用 OWASP 开关

owaspRuleName

required if isUseOwasp is true

string

Example: "sys_default"

OWASP 规则,当 isUseOwasp 为 true 时必填

8. 回源 URL 改写设定

Method : 添加域名 : POST

Method : 更新域名 : PATCH

① 示范 (curl 模式)

上述为添加域名 : POST 的代码,如要更新域名请将 "--request" 更改为 PATCH。

Parameter :

栏位
类型
预设/填写范例
描述

groupName

required

string

groupName=cdn-xxx

项目的群组名称

Body :

栏位
类型
预设/填写范例
描述

rewriteUrlRules

Array of objects

Example: See below

改写回源 URL 的规则集合

rewriteUrlRules[].description

string

Default: ""

描述此改写规则的用途

rewriteUrlRules[].isRewriteUrlPath

boolean

Default: false

是否启用路径改写

rewriteUrlRules[].sourcePath

string

Default: ""

改写目标路径

rewriteUrlRules[].destPath

string

Default: ""

替换路径

rewriteUrlRules[].isReplaceAll

boolean

Default: false

是否开启全部替换

rewriteUrlRules[].isIteration

boolean

Default: false

是否开启迭代

rewriteUrlRules[].isRewriteUrlArgs

boolean

Default: false

是否启用 args 改写

rewriteUrlRules[].rewriteUrlArgsRules

Array of objects

Default: []

改写 args 的规则集合

rewriteUrlRules[].rewriteUrlArgsRules[].sourceArgs

string

Default: ""

改写目标 args

rewriteUrlRules[].rewriteUrlArgsRules[].destArgs

string

Default: ""

替换 args

rewriteUrlRules[].rewriteUrlArgsRules[].isReplaceAll

boolean

Default: false

是否开启全部替换

rewriteUrlRules[].rewriteUrlArgsRules[].isIteration

boolean

Default: false

是否开启迭代

9. 进阶缓存设定

Method : 添加域名时增加进阶缓存设定 : POST

Method : 更新进阶缓存设定 : PATCH

① 示范 (curl 模式)

上述为添加域名时增加进阶缓存设定 : POST 的代码,如要更新设定请将 "--request" 更改为 PATCH。

Parameter :

栏位
类型
预设/填写范例
描述

groupName

required

string

groupName=cdn-xxx

项目的群组名称

Body:

栏位
类型
预设/填写范例
描述

cacheUrlRules

Array of objects

Example: See below

进阶缓存规则集合,以 "{ }" 分开多条规则

cacheType

String

Default: "" Example: "cache"

缓存类型,栏位可套用唯一值如下: - followOrigin (遵循源站) - cache (缓存) - notCache (不缓存)

uriPath

String

Default: "" Example: "/rule1"

指定缓存路径

description

String

Default: "" Example: "this-is-rule1"

描述此缓存规则的用途

isSlice

Boolean

Default: false Example: "true"

是否开启拆分缓存大小功能

slice

Number

Default: Example: "5"

缓存文件拆分大小,单位 : MB

browserExp

Number

Default: Example: "5"

资源在浏览器过期时间,单位 : min

serverExp

Number

Default: Example: "5"

资源在服务器过期时间,单位 : min

argsType

Array of objects

Default: []

Args 缓存规则集合,栏位可套用唯一值如下: - keepAll (全部保留) - ignoreAll (全部忽略) - keepParams (保留指定参数,其余忽略) - ignoreParams (忽略指定参数,其余保留)

argsRules

Array of objects Key : string Value : string

Default: [] Example: [{"key": "456", "value":"789"}, "key": "123", "value":"321"}]

argsType 缓存规则的详细对象参数

proxyCacheLock

Boolean

Default: false Example: "true"

是否开启缓存鎖功能

Last updated