网页加速、下载分发、动态加速、全站加速、点播分发、直播分发、上传加速、移动加速、上网加速、S-P2P、PCDN、应用性能管理、WEB应用防火墙、BotGuard爬虫管理、WSS、DMS、DDoS云清洗、IPv6一体化解决方案、电商安全加速解决方案、金融安全加速解决方案、政企安全加速解决方案、应用安全解决方案、区块链安全加速解决方案、IPv6安全加速解决方案
查看时间戳防盗链
Open API在线调试功能提供可视化界面在线调试API、支持生成代码示例、快速检索查看API文档等能力。前往调试
参数名称 | 类型 | 必填 | 描述 |
---|---|---|---|
domain-name | String | 是 | 域名名称或域名id,在请求的url后面 |
参数名称 | 类型 | 描述 |
---|---|---|
http status code | Integer | httpstatus=202; 表示成功调用新增域名接口,可使用header中的x-cnc-request-id查看当前新增域名的部署情况 |
x-cnc-request-id | String | 唯一标示的id,用于查询每次请求的任务 (适用全部接口) |
domain-id | String | 加速域名ID |
domain-name | String | 加速域名的名称 |
timestamp-visit-control-rule | QuerytimecontrolServiceResponseTimestampVisitControlRule | 时间戳防盗链设置
注意:
1、时间戳防盗链分为两部分,一部分是防盗链校验,一部分是时间有效性校验。二者都有效,则防盗链通过,否则不通过。
2、防盗链校验:加密算法为md5sum,按照参与MD5计算的参数及组合顺序进行防盗链加密串的计算,对匹配目录下所有文件的url进行防盗链校验,未匹配到的url,则拒绝访问。
3、时间有效性检验:按照年月日时分秒换算的当前时间,与请求url中所带的名文时间相减,判断是否超过设置的上下限(即前后60s内),时间差小于设置上下限的,系统才会给予正常的响应,否则拒绝请求,返回403
4、日志记录没有带加密串的url
6、需要清空时间戳防盗链规则时,可以只传入节点 |
path-pattern | String | 同缓存规则设置中的“path-pattern”,用于URL匹配。对于匹配到的URL进行时间戳防盗链验证;未匹配到的URL,则拒绝。 同缓存规则设置中的“path-pattern”,用于URL匹配。对于匹配到的URL进行时间戳防盗链验证;未匹配到的URL,则拒绝。 |
protocol-of-path-pattern | String | {"en":"Optional values are: http, https, http;https, noprefix, empty. If it is empty, it defaults to "http;https"; if it is noprefix, it means that the protocol prefix of url is not specified, and it only matches according to the regularity of path-pattern. This configuration item only matches with path-pattern. example: 1. Specify protocol-of-path-pattern=https and path-pattern=.* to match all https requests, but not http requests. 2. Specify protocol-of-path-pattern=http;https, path-pattern=.* to match all http and https requests. 3. Specify protocol-of-path-pattern=noprefix and path-pattern=^http://[^/]+/.* to match all http requests but not https requests.", "zh_CN":"可选值为: http、https、http;https、noprefix、空。为空默认为“http;https”;为noprefix表示不指定url的协议前缀,仅按path-pattern的正则匹配。本配置项只与path-pattern(url匹配模式)结合匹配。 例子: 1、指定protocol-of-path-pattern=https,path-pattern=.*,则匹配所有https的请求,不匹配http的请求。 2、指定protocol-of-path-pattern=http;https,path-pattern=.*,则匹配所有http和https的请求。 3、指定protocol-of-path-pattern=noprefix,path-pattern=^http://[^/]+/.*,则匹配所有http的请求,不匹配https的请求。"} |
directory | String | 目录,多个以英文分号隔开。对于匹配到的目录进行时间戳防盗链验证;未匹配到的则拒绝。和path-pattern互斥。 |
ignore-uri-slash | String | 防盗链中的$uri是否去掉/,可选值为true、false,默认为false,即包含/。 例如: http://www.test.com/1.flv,则$uri默认为/1.flv,若ignore-uri-slash为true,则$uri为1.flv |
ignore-key-and-time-position | String | {"en":"Whether key and time are allowed to be interchanged, the optional values are true and false, true is allowed, false is not allowed. By default, the order of key parameters and time parameters must strictly follow the order required by the authentication mode, that is, the default key and time cannot be interchanged. If "true" is selected, the key and time positions can be interchanged and the authentication succeeds.", "zh_CN":"key与time是否允许互换,可选值为true和false,true则允许,false则不允许。默认情况下,密钥参数和时间参数的顺序,必须严格参照鉴权模式要求的顺序,即,默认key和time不能互换位置。如选择“true”,key和time位置可以互换并鉴权成功。"} |
except-path-pattern | String | 例外的url匹配模式,某些URL除外:如abc.jpg,不做防盗链 例外的url匹配模式,某些URL除外:如abc.jpg,不做防盗链 |
allowed-ips | String | 例外的IP,支持输入IP或IP段,IP段之间用分号(;)隔开,如1.1.1.0/24;2.2.2.2,某些IP例外,不做防盗链 |
encrypt-method | String | 加密算法 当前支持入参:md5sum |
multiple-secret-keys | String | 防盗链加密串,支持多个加密串,多个加密串以分号(;)隔开
示例: |
time-format | String | 防盗链加密串时间格式,可多选,以分号(;)分隔
年|月|日|时|分|秒|UNIX时间戳|16进制时间戳:1Y;2m;3d;4H;5M;6S;7s;8x
示例: |
dst-style | String | 防盗链回源方式,可选值:1(使用未加密url回源)、2(使用客户请求带加密串url回源)
示例: |
log-format | String | 日志记录原始url,可选值:true(日志记录原始url)、false(不开启日志记录原始url) |
m3u8 | String | 该配置项用于通过匹配的才进行m3u8改写,可选值:false(不进行m3u8改写)、true(进行m3u8改写)
示例: |
url-key | String | 用于配置获取url中的key的名称
示例: |
timestamp-control-rules | List | 时间戳防盗链多条匹配模式
注意:多条配置项如下:
1、url匹配模式的协议:
2、url匹配模式
3、例外url匹配模式的协议
4、例外url匹配模式
5、防盗链生成方式
6、请求url格式
7、通用防盗链取uri对应第几个“/”
8、清空多条配置只传入节点: |
data-id | Long | 添加grid类型标识,表示客户多组配置时,具体某组配置 注意:添加grid类型标识:data-id,每一组配置对应一个data-id:a、如果客户有传data-id,说明指定修改其中一组配置项内容,不需求修改其他组配置内容不需要入参;b、如果客户入参多组配置,其中有些组配置有传data-id,有些没有传,则有传data-id的表示修改具体某组配置,没有传data-id的表示在原来基础上新增一组配置;c、如果客户入参都没有传data-id,表示用本次的配置全量覆盖原先配置;d、如果客户入参没有传任何配置项参数,只传了域名和二级标签,表示清空这个接口对应域名二级服务所有配置。(c、d内容和当前方案实现一致);e、一个gird标签下的入参不能为空,如果,没有具体的配置项,则data-id必填,且值为实际存在的data-id,表示清空这个data-id对应配置项的值; |
path-pattern | String | |
except-path-pattern | String | |
path-pattern-protocol | String | 协议,可选值:http|https|http;https|noprefix http:http协议 https:http协议 http;https:http和https协议 noprefix:不加前缀,按path-pattern设置的规则 用法示例: path-pattern:输入.*\jpg$ path-pattern-protocol:选择http,则表示^http://[^/]+/.*\jpg$ ; 选择https,则表示 ^https://[^/]+/ .*\jpg$; 选择http;https,则表示^https?://[^/]+/.*\jpg$; 选择noprefix,则表示.*\jpg$ 注意: 1、为空时,则默认“http和https协议” 2、只与url匹配模式匹配(path-pattern) 3、协议必须跟模式一起,但是模式可以单独存在 |
except-path-pattern-protocol | String | 协议,可选值:http|https|http;https|noprefix http:http协议 https:http协议 http;https:http和https协议 noprefix:不加前缀 用法示例: except-path-pattern:输入.*\jpg$ except-path-pattern-protocol:选择http,则表示^http://[^/]+/.*\jpg$ ; 选择https,则表示 ^https://[^/]+/ .*\jpg$; 选择http;https,则表示^https?://[^/]+/.*\jpg$; 选择noprefix,则表示.*\jpg$ 注意: 1、为空时,则默认“http和https协议” 2、只与例外url匹配模式匹配(except-path-pattern) 3、协议必须跟模式一起,但是模式可以单独存在 |
cipher-combination | String | 防盗链生成方式,参与MD5计算的参数及组合顺序,仅支持传入以下参数:
$uri:介于domain和问号之间的字符串,特殊取值在入参 |
secret-key | String | 防盗链加密串的秘钥,只允许传入一个秘钥
示例: |
cipher-param | String | 防盗链串的参数名称
示例: |
time-param | String | 时间串的参数名称
示例: |
lower-limit-expiry-time | String | 防盗链串的过期时间下限
示例:
|
upper-limit-expiry-time | String | 防盗链串的过期时间上限
示例:
|
request-url-style | String | 防盗链请求url格式,支持两种防盗链方式,即加密串和时间戳放到“?”后面或者是加密串和时间戳放到“host”后面,url格式支持的参数如下:
$domain:域名
$uri:不包含域名的url部分
$key:防盗链加密串的MD5值
$time:防盗链时间串
$args:问号后的QUERY_STRING参数
示例:支持以下请求url格式,可替换为https://,url请求协议根据实际使用,如不知道如何正确配置,请找客户技术支持协助;携带加密串和时间串两个值的参数名“keyname”和“tname”,可替换为实际使用的参数名
|
uri-select | String | 通用防盗链取uri对应第几个“/”,值为数字,多个值,以分号隔开。
配置通用防盗链取uri对应第几个“/”,从配置为0则为正向第一个,-1为逆向第一个,可分频道配置,默认空值。
比如http://a.com/b/c/d/e/f/1.html
那么0;3; 4;-1 就是取/b/e/f/1.html
注意:
1、取值范围:[-100,+100]
2、重复配置生效规则(建议不要配重复)
重复的将会跳过解析:
如http://cdn.example.com/e/0/e2/test.dat?k=v
可以配 |
错误代码(code) | 描述(message) | HTTP状态码 | 语义 |
---|---|---|---|
InternalError | We encountered an internal error. Please try again. | 500 | 内部错误 |
InvalidParameter | No domain was specified. | 400 | uri中没有指定域名或者域名ID |
NoSuchDomain | The specified domain does not exist. | 404 | 指定的域名不存在 |
NoSuchServiceTag | The specified service tag dose not exist, tag:{}. | 400 | 当前服务不支持查询 |
#!/bin/bash username="example_username" apiKey="example_apiKey" date=`env LANG="en_US.UTF-8" date -u "+%a, %d %b %Y %H:%M:%S GMT"` password=`echo -en "$date" | openssl dgst -sha1 -hmac $apiKey -binary | openssl enc -base64` curl -i --url "https://open.chinanetcenter.com/api/config/timecontrol/a.example.com" \ -X "GET" \ -u "$username:$password" \ -H "Date: $date" \ -H "Accept: application/json" \ -H "Content-Type: application/json" \
HTTP/1.1 202 Accepted Date: Fri, 17 May 2017 06:33:26 GMT Content-Type: application/xml;charset=utf-8 x-cnc-request-id:c54cbbb4-19fe-407a-930c-3988b62ed2fd { "domain-id":"3791876", "domain-name":"www.livestream.1558074757857625.com", "timestamp-visit-control-rule":{ "path-pattern":"/20/*", "except-path-pattern":"jhkh sdas", "allowed-ips":"1.1.1.0/24;2.2.2.2", "multiple-secret-keys":"key1;key2", "time-format":"1Y;2m;3d;4H;5M;6S;7s;8x", "dst-style":"1", "encrypt-method":"md5sum", "log-format":"true", "m3u8":"true", "url-key":"auth_key", "timestamp-control-rules":[ { "data-id":31462855, "path-pattern":"/*.jpg", "except-path-pattern":"/*.png", "cipher-combination":"$uri$ourkey$time$args{param1}", "secret-key":"abcdef", "cipher-param":"keyname", "time-param":"tname", "lower-limit-expiry-time":"200", "upper-limit-expiry-time":"5000", "request-url-style":"http://$domain/$uri?$args&keyname=$key&tname=$time", "uri-select":"1;-1" } ] } }