文档首页/ 内容分发网络 CDN/ API参考/ API/ 域名配置/ 修改域名全量配置接口
更新时间:2025-08-22 GMT+08:00
分享

修改域名全量配置接口

功能介绍

修改域名配置接口,支持修改业务类型、服务范围、备注、IPv6开关、回源方式、回源URL改写、高级回源、Range回源、回源跟随、回源是否校验Etag、回源超时时间、回源请求头、HTTPS配置、TLS版本配置、强制跳转、HSTS、HTTP/2、OCSP Stapling、QUIC、缓存规则、状态码缓存时间、防盗链、IP黑白名单、Use-Agent黑白名单、URL鉴权配置、远程鉴权配置、IP访问限频、HTTP header配置、自定义错误页面配置、智能压缩、请求限速配置、WebSocket配置、视频拖拽、回源SNI、访问URL重写、浏览器缓存过期时间、区域访问控制、客户端证书配置。

  • 单租户调用频率:200次/min。

调用方法

请参见如何调用API

URI

PUT /v1.1/cdn/configuration/domains/{domain_name}/configs

表1 路径参数

参数

是否必选

参数类型

描述

domain_name

String

参数解释:

加速域名

约束限制:

不涉及

取值范围:

不涉及

默认取值:

不涉及

表2 Query参数

参数

是否必选

参数类型

描述

enterprise_project_id

String

参数解释:

企业项目id。您可以通过调用企业项目管理服务(EPS)的查询企业项目列表接口(ListEnterpriseProject)查询企业项目id

约束限制:

当用户开启企业项目功能时,该参数生效,表示查询资源所属项目,"all"表示所有项目

取值范围:

不涉及

默认取值:

不涉及

请求参数

表3 请求Header参数

参数

是否必选

参数类型

描述

X-Auth-Token

String

参数解释:

用户鉴权Token,通过调用IAM服务获取用户Token接口获取(响应消息头中X-Subject-Token的值)

约束限制:

不涉及

取值范围:

不涉及

默认取值:

不涉及

表4 请求Body参数

参数

是否必选

参数类型

描述

configs

Configs object

参数解释:

配置项

约束限制:

不涉及

表5 Configs

参数

是否必选

参数类型

描述

business_type

String

参数解释:

业务类型

约束限制:

暂不支持“全站加速”变更为其它业务类型

取值范围:

  • web: 网站加速

  • download: 文件下载加速

  • video: 点播加速

默认取值:

不涉及

service_area

String

参数解释:

加速域名的服务范围,客户端访问将会调度到服务范围内的CDN节点,可根据用户聚集区域选择合适的范围

约束限制:

  • 暂不支持“中国大陆”与“中国大陆境外”互相直接切换

  • 服务范围修改为中国大陆或全球时,加速域名需要到工信部备案

取值范围:

  • mainland_china:中国大陆

  • global:全球

  • outside_mainland_china:中国大陆境外

默认取值:

不涉及

remark

String

参数解释:

域名备注信息

约束限制:

不涉及

取值范围:

0-10000个字符

默认取值:

不涉及

origin_request_header

Array of OriginRequestHeader objects

参数解释:

回源请求头,CDN节点回源时,根据回源请求头配置操作请求的HTTP头部信息

约束限制:

  • 修改时该功能将覆盖原有配置(清空之前的配置),在使用此接口时,请上传全量头部信息

  • 如果域名在后台配置了特殊请求头,需要将对应的请求头一并传入

http_response_header

Array of HttpResponseHeader objects

参数解释:

HTTP响应头,CDN节点响应客户端时,根据HTTP响应头配置操作响应的HTTP头部信息

约束限制:

  • 修改时该功能将覆盖原有配置(清空之前的配置),在使用此接口时,请上传全量头部信息

  • 如果域名在后台配置了特殊响应头,需要将对应的响应头一并传入

url_auth

UrlAuth object

参数解释:

配置URL鉴权功能,通过计算出的鉴权URL访问用户站点资源,防止资源被用户恶意下载盗用

约束限制:

不涉及

https

HttpPutBody object

参数解释:

在CDN节点添加证书,支持客户端以HTTPS协议访问节点,实现HTTPS安全加速

约束限制:

不涉及

sources

Array of SourcesConfig objects

参数解释:

配置加速域名的源站,CDN通过加速域名将源站上需要加速的内容缓存到CDN节点,达到加速访问资源的效果

约束限制:

不涉及

origin_protocol

String

参数解释:

指定CDN回源时的请求协议

约束限制:

不涉及

取值范围:

  • follow: 协议跟随

  • http: http协议

  • https: https协议

默认取值:

http: http协议

origin_follow302_status

String

参数解释:

开启回源跟随,当源站地址因业务需求做了301/302 重定向,CDN节点会先跳转到301/302对应地址获取资源,缓存后再返回给用户

约束限制:

不涉及

取值范围:

  • on: 开启

  • off: 关闭

默认取值:

不涉及

cache_rules

Array of CacheRules objects

参数解释:

通过不同参数控制源站资源在CDN节点的缓存时长

约束限制:

必须存在一条所有文件类型的规则

ip_filter

IpFilter object

参数解释:

IP黑白名单,对用户的请求IP地址进行过滤,从而限制访问来源

约束限制:

不涉及

referer

RefererConfig object

参数解释:

referer黑白名单,对访问者身份进行识别和过滤,从而限制访问来源

约束限制:

不涉及

force_redirect

ForceRedirectConfig object

参数解释:

强制客户端使用HTTPS或HTTP协议访问CDN节点

约束限制:

不涉及

compress

Compress object

参数解释:

智能压缩,压缩网站的静态资源,缩小传输文件的大小,提升传输效率,减少带宽消耗

约束限制:

不涉及

cache_url_parameter_filter

CacheUrlParameterFilter object

参数解释:

缓存url参数配置

说明:
此参数作为旧参数,将于近期下线,建议使用CacheRules设置URL参数

约束限制:

不涉及

ipv6_accelerate

Integer

参数解释:

配置客户端用IPv6协议访问CDN节点

约束限制:

不涉及

取值范围:

  • 1: 开启

  • 0: 关闭

默认取值:

不涉及

error_code_cache

Array of ErrorCodeCache objects

参数解释:

将源站返回的错误状态码缓存到CDN节点,用户再次请求时由CDN直接响应给用户错误码

约束限制:

不涉及

origin_range_status

String

参数解释:

Range回源,开启后,源站在收到CDN节点回源请求时,根据HTTP请求头中的Range信息返回指定范围的数据给CDN节点

约束限制:

开启Range回源的前提是您的源站支持Range请求,即HTTP请求头中包含Range字段,否则可能导致回源失败

取值范围:

  • on: 开启

  • off: 关闭

默认取值:

不涉及

user_agent_filter

UserAgentFilter object

参数解释:

UA黑白名单,对用户请求使用的代理过滤,从而限制访问来源

约束限制:

不涉及

origin_request_url_rewrite

Array of OriginRequestUrlRewrite objects

参数解释:

回源URL改写,解决回源请求URL与源站URL不匹配的问题

约束限制:

最多配置20条

flexible_origin

Array of flexibleOrigins objects

参数解释:

高级回源,实现根据不同的资源类型或路径回源到不同源站

约束限制:

最多配置20条

slice_etag_status

String

参数解释:

回源是否校验ETag,开启此项配置后,当用户再次请求节点已缓存资源时,会将ETag的值加入到判断资源是否过期的逻辑

约束限制:

不涉及

取值范围:

  • on: 开启

  • off: 关闭

默认取值:

不涉及

origin_receive_timeout

Integer

参数解释:

自定义设置CDN节点回源时的超时时间,请求超时即表示此次回源失败

约束限制:

不涉及

取值范围:

5-300,单位:秒

默认取值:

不涉及

remote_auth

commonRemoteAuth object

参数解释:

配置远程鉴权,当用户向CDN节点请求资源时,CDN将用户请求转发到客户指定的鉴权服务器,CDN根据鉴权服务器返回的结果判断是否给用户返回资源

约束限制:

不涉及

websocket

webSocketSeek object

参数解释:

是否允许客户端使用websocket协议访问CDN节点

说明:
WebSocket功能仅对缓存规则配置为“缓存过期时间为0,缓存过期时间来源为CDN且开启强制缓存”的资源生效

约束限制:

  • 仅全站加速的域名支持该配置

  • WebSocket协议和配置HTTP/2功能不兼容,请勿同时开启

video_seek

videoSeek object

参数解释:

视频拖拽配置,用户可随意拖拽播放进度且不影响观看效果

约束限制:

  • 需同步开启FLV、MP4格式文件的URL参数功能,并选择“忽略参数”

  • 关闭视频拖拽功能时,FLV时间拖拽功能失效

request_limit_rules

Array of RequestLimitRules objects

参数解释:

请求限速,将用户请求速度限制在指定范围内,一定程度上减少突发高带宽风险,节省成本

约束限制:

不涉及

ip_frequency_limit

IpFrequencyLimit object

参数解释:

IP访问限频,通过对单IP每秒访问单个节点的次数限制,实现CC攻击防御及恶意盗刷防护

说明:
单IP的单URL每秒访问单节点的次数达到设置的访问阈值后,CDN节点将直接返回403状态码,10分钟后解除限制

约束限制:

不涉及

hsts

Hsts object

参数解释:

配置HSTS后,将强制客户端(如浏览器)使用 HTTPS 协议访问服务器,提升访问安全性

约束限制:

不涉及

quic

Quic object

参数解释:

QUIC协议,客户端使用QUIC协议访问CDN节点,提高了传输的安全性,减少传输和连接时的延时,避免网络拥塞

约束限制:

不涉及

error_code_redirect_rules

Array of ErrorCodeRedirectRules objects

参数解释:

自定义错误页面,当访问页面出错时,会给客户端返回指定的页面,优化用户体验

约束限制:

不涉及

sni

Sni object

参数解释:

回源SNI,如果源站IP绑定了多个域名,当CDN节点以HTTPS协议访问源站时,可以设置回源SNI,指定HTTPS协议握手时使用的SNI域名

约束限制:

不涉及

request_url_rewrite

Array of RequestUrlRewrite objects

参数解释:

访问URL重写,当用户请求URL与CDN节点缓存资源的URL不一致时,可以通过访问URL重写功能重定向到目标URL

约束限制:

不涉及

browser_cache_rules

Array of BrowserCacheRules objects

参数解释:

浏览器缓存过期时间,当终端用户请求资源时,如果浏览器有缓存,直接返回给用户

约束限制:

不涉及

access_area_filter

Array of AccessAreaFilter objects

参数解释:

区域访问控制,限制某些地理位置的用户访问

说明:
由于IP归属为运营商且不定期调整,华为云虽会定期更新IP地址库,也可能存在更新滞后的情况。因此可能导致部分访问控制功能偶尔误拦截或放行、客户端请求未调度到最佳节点等情况发生

约束限制:

不涉及

client_cert

ClientCert object

参数解释:

客户端证书配置,实现客户端与CDN节点的双向证书认证,提高网站通信安全性

约束限制:

不涉及

表6 OriginRequestHeader

参数

是否必选

参数类型

描述

name

String

参数解释:

设置回源请求头参数

约束限制:

不涉及

取值范围:

  • 1-100个字符

  • 由数字,大小写字母,中划线组成

  • 只能以字母开头

默认取值:

不涉及

value

String

参数解释:

设置回源请求头参数的值

约束限制:

不涉及

取值范围:

  • 1-1000个字符

  • 由数字0 - 9、字符a - z、A - Z,及特殊符“.”、“-”、“_”、“*”、“#”、“!”、“&”、“+”、“|”、“^”、“~”、“'”、“"”、“/”、“:”、“;”、“,”、“=”、“@”、“?”、“<”、“>”组成

  • 当为删除动作时,可不填

  • 不支持中文

  • 不支持变量配置,如:$client_ip,$remote_port等

默认取值:

不涉及

action

String

参数解释:

回源请求头设置类型

约束限制:

  • 同一个请求头字段只允许删除或者设置

  • action为set时,若原回源请求头参数不存在该字段,则执行新增动作。若存在,则执行修改动作

取值范围:

  • delete: 删除

  • set: 设置

默认取值:

不涉及

表7 HttpResponseHeader

参数

是否必选

参数类型

描述

name

String

参数解释:

设置HTTP响应头参数

约束限制:

不涉及

取值范围:

  • 1-100个字符

  • 由数字,大小写字母,中划线组成,只能以字母开头

默认取值:

不涉及

value

String

参数解释:

设置HTTP响应头参数的值

约束限制:

不涉及

取值范围:

  • 1-1000个字符

  • 支持字母、数字和特定字符,如:.-_*#!&+|^~'"/:;,=@?<> 等

  • 当为删除动作时,可不填

默认取值:

不涉及

action

String

参数解释:

设置HTTP响应头操作类型

约束限制:

  • 同一个响应头字段只允许删除或者设置

  • action为set时,若原HTTP响应头参数不存在该字段,则执行新增动作。若存在,则执行修改动作

取值范围:

  • set: 设置

  • delete: 删除

默认取值:

不涉及

表8 UrlAuth

参数

是否必选

参数类型

描述

status

String

参数解释:

是否开启URL鉴权

约束限制:

不涉及

取值范围:

  • on: 开启

  • off: 关闭

默认取值:

不涉及

type

String

参数解释:

鉴权方式

约束限制:

不涉及

取值范围:

  • type_a: 鉴权方式A

  • type_b: 鉴权方式B

  • type_c1: 鉴权方式C1

  • type_c2: 鉴权方式C2

默认取值:

不涉及

expire_time

Integer

参数解释:

鉴权URL的有效时间

约束限制:

不涉及

取值范围:

0-31536000,单位:秒

默认取值:

不涉及

sign_method

String

参数解释:

加密算法

约束限制:

不涉及

取值范围:

  • md5

  • sha256

默认取值:

不涉及

match_type

String

参数解释:

鉴权范围,指定哪些文件参与鉴权

约束限制:

不涉及

取值范围:

  • all: 所有文件

  • include_file_extension: 指定后缀文件参与鉴权

  • exclude_file_extension: 指定后缀文件不参与鉴权

默认取值:

不涉及

match_rule

String

参数解释:

鉴权文件匹配规则

约束限制:

不涉及

取值范围:

  • 当match_type为all时,置空

  • 当match_type为include_file_extension或exclude_file_extension时,输入文件后缀,后缀以“.”为首字符,多个后缀以“,”分隔,如.jpg,.zip,.exe

默认取值:

不涉及

inherit_config

InheritConfig object

参数解释:

鉴权继承,为M3U8/MPD索引文件下的TS/MP4文件添加鉴权参数,解决因鉴权不通过导致的TS/MP4文件无法播放的问题

约束限制:

不涉及

key

String

参数解释:

鉴权密钥

约束限制:

不涉及

取值范围:

  • 6-32个字符

  • 由大小写字母、数字构成

默认取值:

不涉及

backup_key

String

参数解释:

备选鉴权密钥,当需要替换密钥时,如果需要新旧密钥同时生效,可设置备KEY。主、备KEY之一鉴权通过即可正常访问

约束限制:

不涉及

取值范围:

  • 6-32个字符

  • 由大小写字母、数字构成

默认取值:

不涉及

sign_arg

String

参数解释:

用户url中携带的鉴权信息参数名

约束限制:

鉴权方式为A或C2时需配置该参数

取值范围:

  • 1-100个字符

  • 由大小写字母、数字、下划线构成(不能以数字开头)

默认取值:

auth_key

time_format

String

参数解释:

时间格式

约束限制:

  • 鉴权方式A: 只支持十进制

  • 鉴权方式B: 只支持十进制

  • 鉴权方式C1: 只支持十六进制

  • 鉴权方式C2: 支持十进制/十六进制

取值范围:

  • dec: 十进制

  • hex: 十六进制

默认取值:

不涉及

time_arg

String

参数解释:

时间参数名称

约束限制:

鉴权方式为C2时,该字段可选

取值范围:

  • 1-100个字符

  • 以字母开头,支持数字、字母和下划线,不允许出现其他特殊符号

默认取值:

timestamp

表9 InheritConfig

参数

是否必选

参数类型

描述

status

String

参数解释:

是否开启鉴权继承

约束限制:

不涉及

取值范围:

  • on: 开启

  • off: 关闭

默认取值:

不涉及

inherit_type

String

参数解释:

鉴权继承配置

约束限制:

  • 输入多个参数时用“,”分隔,例如“m3u8,mpd”

  • 开启鉴权继承时,该参数必填

取值范围:

  • m3u8

  • mpd

默认取值:

不涉及

inherit_time_type

String

参数解释:

鉴权继承开始时间

约束限制:

开启鉴权继承时,该参数必填

取值范围:

  • sys_time: 当前系统时间

  • parent_url_time: 与m3u8和mpd访问链接保持一致

默认取值:

不涉及

表10 HttpPutBody

参数

是否必选

参数类型

描述

https_status

String

参数解释:

证书配置开关

约束限制:

不涉及

取值范围:

  • on: 开启

  • off: 关闭

默认取值:

不涉及

certificate_type

String

参数解释:

证书类型

约束限制:

不涉及

取值范围:

  • server: 国际证书

  • server_sm: 国密证书

默认取值:

不涉及

certificate_source

Integer

参数解释:

证书来源

约束限制:

证书开启时必传

取值范围:

  • 0: 自有证书

  • 2: SCM证书

默认取值:

不涉及

scm_certificate_id

String

参数解释:

SCM证书ID,可使用云证书管理服务(CCM)的查询证书列表接口获取

约束限制:

配置SCM证书时必传

取值范围:

不涉及

默认取值:

不涉及

certificate_name

String

参数解释:

证书名称

约束限制:

  • 当证书开启时必传

  • 3-64个字符

取值范围:

不涉及

默认取值:

不涉及

certificate_value

String

参数解释:

HTTPS协议使用的证书内容

约束限制:

  • 仅支持PEM编码格式

  • 当证书开启时必传

  • 需要传入完整证书链

取值范围:

证书链长度不超过20KB

默认取值:

不涉及

private_key

String

参数解释:

HTTPS协议使用的私钥

约束限制:

  • 当证书开启时必传

  • 仅支持PEM编码格式

取值范围:

不涉及

默认取值:

不涉及

enc_certificate_value

String

参数解释:

加密证书内容

约束限制:

  • 证书类型为国密证书时必传

  • 仅支持PEM编码格式

取值范围:

不涉及

默认取值:

不涉及

enc_private_key

String

参数解释:

加密私钥内容

约束限制:

  • 证书类型为国密证书时必传

  • 仅支持PEM编码格式

取值范围:

不涉及

默认取值:

不涉及

certificates

Array of CertificatesPutBody objects

参数解释:

证书配置请求体

约束限制:

  • 配置双证书时必传

  • 不支持配置两个国际证书或两个国密证书

  • 如果certificates配置了证书(国际证书、国密证书或国际+国密双证书),外层证书配置将失效,仅保留当前参数传入的证书信息

http2_status

String

参数解释:

HTTP/2开关,支持客户端采用HTTP/2协议访问CDN节点

约束限制:

https_status=off时,该值不生效

取值范围:

  • on: 是

  • off: 否

默认取值:

off: 否

tls_version

String

参数解释:

传输层安全性协议,即TLS版本配置

约束限制:

  • 不可全部关闭

  • 需开启连续或单个版本号,例:不可仅开启TLS1.0/1.2而关闭TLS1.1

  • 多版本开启时,使用“,”拼接,例:TLSv1.1,TLSv1.2

  • 配置TLS版本需要先开启HTTPS国际证书

取值范围:

目前支持TLSv1.0/1.1/1.2/1.3四个版本的协议

默认取值:

TLS1.1/1.2/1.3

ocsp_stapling_status

String

参数解释:

是否开启ocsp stapling

约束限制:

不涉及

取值范围:

  • on: 是

  • off: 否

默认取值:

不涉及

表11 CertificatesPutBody

参数

是否必选

参数类型

描述

certificate_source

Integer

参数解释:

证书来源

约束限制:

不涉及

取值范围:

  • 0: 自有证书

  • 2: SCM证书

默认取值:

不涉及

scm_certificate_id

String

参数解释:

SCM证书ID,可使用云证书管理服务(CCM)的查询证书列表接口获取

约束限制:

配置SCM证书时必传

取值范围:

不涉及

默认取值:

不涉及

certificate_type

String

参数解释:

证书类型

约束限制:

不涉及

取值范围:

  • server: 国际证书

  • server_sm: 国密证书

默认取值:

不涉及

certificate_name

String

参数解释:

证书名字

约束限制:

不涉及

取值范围:

3-64个字符

默认取值:

不涉及

certificate_value

String

参数解释:

HTTPS协议使用的证书内容

约束限制:

仅支持PEM编码格式

取值范围:

不涉及

默认取值:

不涉及

private_key

String

参数解释:

HTTPS协议使用的私钥

约束限制:

仅支持PEM编码格式

取值范围:

不涉及

默认取值:

不涉及

enc_certificate_value

String

参数解释:

加密证书内容

约束限制:

  • 证书类型为国密证书时必传

  • 仅支持PEM编码格式

取值范围:

不涉及

默认取值:

不涉及

enc_private_key

String

参数解释:

加密私钥内容

约束限制:

  • 证书类型为国密证书时必传

  • 仅支持PEM编码格式

取值范围:

不涉及

默认取值:

不涉及

表12 SourcesConfig

参数

是否必选

参数类型

描述

origin_type

String

参数解释:

源站类型

约束限制:

不涉及

取值范围:

  • ipaddr: 源站IP

  • domain: 源站域名

  • obs_bucket: OBS桶域名

  • third_bucket: 第三方桶,使用该源站类型需要提交工单申请

默认取值:

不涉及

origin_addr

String

参数解释:

源站IP或者域名

约束限制:

不涉及

取值范围:

不涉及

默认取值:

不涉及

priority

Integer

参数解释:

源站优先级

约束限制:

不涉及

取值范围:

1-100

默认取值:

不涉及

weight

Integer

参数解释:

权重

约束限制:

不涉及

取值范围:

1-100

默认取值:

不涉及

obs_web_hosting_status

String

参数解释:

是否开启OBS静态网站托管

约束限制:

源站类型为obs_bucket时传递

取值范围:

  • on: 开启

  • off: 关闭

默认取值:

不涉及

http_port

Integer

参数解释:

HTTP端口

约束限制:

不涉及

取值范围:

1-65535

默认取值:

80

https_port

Integer

参数解释:

HTTPS端口

约束限制:

不涉及

取值范围:

1-65535

默认取值:

443

host_name

String

参数解释:

回源HOST

约束限制:

不涉及

取值范围:

不涉及

默认取值:

加速域名

obs_bucket_type

String

参数解释:

OBS回源鉴权开关,适用于OBS桶源站场景,如果桶需要带鉴权访问,则需要打开OBS回源鉴权开关。如此,CDN节点回源时会携带鉴权信息,鉴权信息与OBS桶不匹配时,回源失败,避免非授权的请求盗刷流量

约束限制:

源站类型是“OBS桶域名”时需要传该参数

取值范围:

  • private: 开启回源鉴权开关

  • public: 关闭回源鉴权开关

默认取值:

public: 关闭回源鉴权开关

bucket_access_key

String

参数解释:

第三方对象存储访问密钥ID,即AK

约束限制:

源站类型为第三方桶时必填

取值范围:

不涉及

默认取值:

不涉及

bucket_secret_key

String

参数解释:

第三方对象存储私密访问密钥,即SK

约束限制:

源站类型为第三方桶时必填

取值范围:

不涉及

默认取值:

不涉及

bucket_region

String

参数解释:

第三方对象存储区域

约束限制:

源站类型为第三方桶时必填

取值范围:

不涉及

默认取值:

不涉及

bucket_name

String

参数解释:

第三方对象存储名称

约束限制:

源站类型为第三方桶时必填

取值范围:

不涉及

默认取值:

不涉及

表13 CacheRules

参数

是否必选

参数类型

描述

match_type

String

参数解释:

匹配类型

约束限制:

不涉及

取值范围:

  • all: 匹配所有文件

  • file_extension: 按文件后缀匹配

  • catalog: 按目录匹配

  • full_path: 全路径匹配

  • home_page: 按首页匹配

默认取值:

不涉及

match_value

String

参数解释:

缓存规则匹配内容

约束限制:

  • 当match_type为all时,置空

  • 当match_type为file_extension时,为文件后缀,输入首字符为“.”,以“,”或“;”分隔,如.jpg,.zip,.exe,并且输入的文件名后缀总数不超过100个,总字符不超过1000

  • 当match_type为catalog时,为目录路径,输入要求以“/”作为首字符, 以“,”或“;”分隔,如/test/folder01,/test/folder02,并且输入的目录路径总数不超过20个,总字符不超过255

  • 当match_type为full_path时,为全路径,输入要求以“/”作为首字符,支持匹配指定目录下的具体文件,或者带通配符“*”的文件,单条全路径缓存规则里仅支持配置一个全路径,如/test/index.html或/test/*.jpg,不可配置/*

  • 当match_type为home_page时,置空

取值范围:

不涉及

默认取值:

不涉及

ttl

Integer

参数解释:

资源在CDN节点的缓存过期时间

约束限制:

最大支持365天

取值范围:

不涉及

默认取值:

0

ttl_unit

String

参数解释:

缓存过期时间单位

约束限制:

不涉及

取值范围:

  • s: 秒

  • m: 分

  • h: 小时

  • d: 天

默认取值:

不涉及

priority

Integer

参数解释:

缓存规则的优先级,数值越大,优先级越高

约束限制:

优先级不能相同

取值范围:

1-100

默认取值:

不涉及

follow_origin

String

参数解释:

缓存过期时间来源,设置CDN节点的缓存遵循源站还是CDN侧的配置

约束限制:

不涉及

取值范围:

  • on: CDN节点的缓存过期时间遵循源站的设置

  • off: CDN节点的缓存过期时间遵循“缓存规则”中的“缓存过期时间”

  • min_ttl: CDN节点的缓存过期时间取缓存规则和源站二者的最小值

默认取值:

off: CDN节点的缓存过期时间遵循“缓存规则”中的“缓存过期时间”

force_cache

String

参数解释:

强制缓存:CDN节点缓存过期时间是否忽略源站响应头Cache-Control中的no-cache、private、no-store字段

约束限制:

强制缓存与缓存过期时间来源功能配合使用,具体使用限制及配置效果请参考CDN用户指南的配置节点缓存规则章节

取值范围:

  • on: 打开强制缓存

  • off: 关闭强制缓存

默认取值:

off: 关闭强制缓存

url_parameter_type

String

参数解释:

URL参数

约束限制:

不涉及

取值范围:

  • del_params: 忽略指定URL参数

  • reserve_params: 保留指定URL参数

  • ignore_url_params: 忽略全部URL参数

  • full_url: 使用完整URL参数

默认取值:

full_url: 使用完整URL参数

url_parameter_value

String

参数解释:

URL参数值

约束限制:

  • 最多配置30条参数值

  • 以“,”或“;”分隔

  • 当url_parameter_type为del_params或reserve_params时必填

取值范围:

不涉及

默认取值:

不涉及

表14 IpFilter

参数

是否必选

参数类型

描述

type

String

参数解释:

IP黑白名单类型

约束限制:

不涉及

取值范围:

  • off: 关闭IP黑白名单

  • black: IP黑名单

  • white: IP白名单

默认取值:

不涉及

value

String

参数解释:

配置IP黑白名单

说明:
支持IPv6,支持配置IP地址和IP&掩码格式的网段

约束限制:

  • 当type=off时,非必传

  • 多条规则用“,”分隔

  • 最多支持配置500条规则

  • 多个完全重复的IP/IP段将合并为一条规则

  • 不支持带通配符的地址,如192.168.0.*

取值范围:

不涉及

默认取值:

不涉及

表15 RefererConfig

参数

是否必选

参数类型

描述

type

String

参数解释:

Referer黑白名单类型

约束限制:

不涉及

取值范围:

  • off: 关闭Referer黑白名单

  • black: Referer黑名单

  • white: Referer白名单

默认取值:

不涉及

value

String

参数解释:

域名或IP地址

说明:
域名、IP地址可以混合输入,支持泛域名和带端口的域名

约束限制:

  • 以“,”进行分隔

  • 域名、IP地址总数不超过1000个

  • 端口取值范围1-65535

取值范围:

不涉及

默认取值:

不涉及

include_empty

Boolean

参数解释:

是否包含空Referer

说明:
如果是黑名单并开启该选项,则表示无referer不允许访问

如果是白名单并开启该选项,则表示无referer允许访问

约束限制:

不涉及

取值范围:

  • true: 包含空

  • false: 不包含空

默认取值:

false: 不包含空

表16 ForceRedirectConfig

参数

是否必选

参数类型

描述

status

String

参数解释:

强制跳转开关

约束限制:

不涉及

取值范围:

  • on: 开启

  • off: 关闭

默认取值:

不涉及

type

String

参数解释:

强制跳转类型

约束限制:

如果开启强制跳转HTTPS,请先配置HTTPS证书,否则将导致访问失败

取值范围:

  • http: 强制跳转HTTP

  • https: 强制跳转HTTPS

默认取值:

不涉及

redirect_code

Integer

参数解释:

重定向跳转码

约束限制:

不涉及

取值范围:

  • 301

  • 302

  • 307

默认取值:

不涉及

表17 Compress

参数

是否必选

参数类型

描述

status

String

参数解释:

智能压缩开关

约束限制:

不涉及

取值范围:

  • on: 开启

  • off: 关闭

默认取值:

不涉及

type

String

参数解释:

智能压缩类型

约束限制:

当配置了多种智能压缩类型时,优先使用brotli压缩

取值范围:

多种智能压缩类型用“,”分隔,可选值如下:

  • gzip: gzip压缩

  • br: brotli压缩

默认取值:

不涉及

file_type

String

参数解释:

需要压缩的文件类型

约束限制:

不涉及

取值范围:

  • 内容总长度不可超过2000个字符

  • 单个格式不可超过50个字符

  • 多种格式用“,”分隔

默认取值:

开启状态下,首次传空时默认值为.js,.html,.css,.xml,.json,.shtml,.htm,否则为上次设置值

compress_min_length

Integer

参数解释:

压缩区间最小范围

约束限制:

如果未设置参与压缩的文件大小,默认大小为“0MB~30MB”的文件参与压缩。

取值范围:

  • 文件大小范围(0MB~30MB),单位为Byte

默认取值:

不涉及

compress_max_length

Integer

参数解释:

压缩区间最大范围

约束限制:

如果未设置参与压缩的文件大小,默认大小为“0MB~30MB”的文件参与压缩。

取值范围:

  • 文件大小范围(0MB~30MB),单位为Byte

默认取值:

不涉及

表18 CacheUrlParameterFilter

参数

是否必选

参数类型

描述

type

String

参数解释:

缓存URL参数操作类型,即资源缓存时,URL参数的缓存范围

约束限制:

不涉及

取值范围:

  • full_url: 缓存所有参数

  • ignore_url_params: 忽略所有参数

  • del_params: 忽略指定URL参数

  • reserve_params: 保留指定URL参数

说明:
本接口参数有调整,参数替换如下:

del_params替代del_args

reserve_params替代reserve_args

默认取值:

不涉及

value

String

参数解释:

URL参数的取值

约束限制:

多个参数使用“;”分隔

取值范围:

不涉及

默认取值:

不涉及

表19 ErrorCodeCache

参数

是否必选

参数类型

描述

code

Integer

参数解释:

需要缓存的错误码

约束限制:

不涉及

取值范围:

  • 3xx: 301, 302

  • 4xx: 400, 403, 404, 405, 407, 414, 416, 451

  • 5xx: 500, 501, 502, 503, 504, 509, 514

默认取值:

不涉及

ttl

Integer

参数解释:

错误码缓存时间

约束限制:

不涉及

取值范围:

0-31536000,单位:秒

说明:
3XX状态码缓存时间范围为0-20s

默认取值:

不涉及

表20 UserAgentFilter

参数

是否必选

参数类型

描述

type

String

参数解释:

UA黑白名单类型

约束限制:

不涉及

取值范围:

  • off: 关闭UA黑白名单

  • black: UA黑名单

  • white: UA白名单

默认取值:

不涉及

value

String

参数解释:

UA黑白名单内容

说明:
此参数作为旧参数,将于近期下线,建议使用ua_list字段设置UA黑白名单内容

约束限制:

  • 当type=off时,非必传

  • 最多配置50条规则

  • 多条规则用“,”分隔

取值范围:

  • 单条规则不超过200个字符

  • 支持数字0-9、字符a-z、A-Z,空格,及特殊符"*"、"."、"-"、"_"、"("、")"、";"、","、"/"、"'"、"#"、"!"、"@"、"$"、"^"、"&"、"+"、"="、"~"、"?"、"""、"["、"]"、"{"、"}"、""、":"、"%"

默认取值:

不涉及

include_empty

Boolean

参数解释:

是否包含空UA

说明:
如果黑名单并开启该选项,则表示无UA不允许访问

如果是白名单并开启该选项,则表示无UA允许访问

约束限制:

不涉及

取值范围:

true: 包含空

false:不包含空

默认取值:

  • 当UA为黑名单时该字段默认值为false

  • 当UA为白名单时该字段默认值为true

ua_list

Array of strings

参数解释:

配置UA黑白名单

约束限制:

  • 当type=off时,非必传

  • 最多配置50条规则

  • 单条规则不超过200个字符

  • 同时配置value和ua_list时,ua_list生效

表21 OriginRequestUrlRewrite

参数

是否必选

参数类型

描述

priority

Integer

参数解释:

回源URL改写规则的优先级

说明:
数值越大优先级越高,CDN按照优先级高的规则执行URL改写

约束限制:

  • 不支持多条回源URL改写规则设置同一优先级

  • 优先级不能输入为空

取值范围:

1-100

默认取值:

不涉及

match_type

String

参数解释:

匹配类型

约束限制:

不涉及

取值范围:

  • all: 所有文件

  • file_path: URI路径

  • wildcard: 通配符

  • full_path: 全路径

默认取值:

不涉及

source_url

String

参数解释:

需要替换的URI

约束限制:

匹配方式为“所有文件”时,不支持配置参数

取值范围:

  • 1-512个字符

  • 支持通配符*匹配,如:/test/*/*.mp4

  • 以正斜线(/)开头的URI,不含http(s)://头及域名

默认取值:

不涉及

target_url

String

参数解释:

替换后的URI

约束限制:

取值范围:

  • 1-256个字符

  • 以正斜线(/)开头的URI,不含http(s)://头及域名

说明:
通配符 * 可通过$n捕获(n=1,2,3...,例如:/newtest/$1/$2.jpg)

默认取值:

不涉及

表22 flexibleOrigins

参数

是否必选

参数类型

描述

match_type

String

参数解释:

URI的匹配方式

约束限制:

不涉及

取值范围:

  • file_extension: 文件后缀匹配

  • file_path: 目录路径

默认取值:

不涉及

match_pattern

String

参数解释:

URI的匹配规则

约束限制:

match_type为file_extension时:

  • 支持所有格式的文件类型

  • 输入首字符为“.”,以“;”进行分隔

  • 输入的文件后缀名总数不能超过20个

match_type为file_path时:

  • 要求以“/”作为首字符

  • 以“;”进行分隔

  • 输入的目录路径总数不能超过20个

说明:
文件名后缀英文字符大、小写代表不同资源

取值范围:

1-512个字符

默认取值:

不涉及

priority

Integer

参数解释:

优先级

说明:
数值越大优先级越高

约束限制:

不涉及

取值范围:

1-100

默认取值:

不涉及

back_sources

Array of backSources objects

参数解释:

配置客户端请求匹配当前规则时,CDN节点回源访问的源站

约束限制:

每条规则的回源源站数量不超过1个

取值范围:

不涉及

默认取值:

不涉及

表23 backSources

参数

是否必选

参数类型

描述

sources_type

String

参数解释:

源站类型

约束限制:

不涉及

取值范围:

  • ipaddr: 源站IP

  • domain: 源站域名

  • obs_bucket: OBS桶域名

默认取值:

不涉及

ip_or_domain

String

参数解释:

源站IP或者域名

约束限制:

不涉及

取值范围:

不涉及

默认取值:

不涉及

obs_bucket_type

String

参数解释:

OBS桶类型

约束限制:

不涉及

取值范围:

  • private: 私有桶

  • public: 公有桶

默认取值:

public: 公有桶

http_port

Integer

参数解释:

HTTP端口

约束限制:

不涉及

取值范围:

1-65535

默认取值:

80

https_port

Integer

参数解释:

HTTPS端口

约束限制:

不涉及

取值范围:

1-65535

默认取值:

443

表24 commonRemoteAuth

参数

是否必选

参数类型

描述

remote_authentication

String

参数解释:

是否开启远程鉴权

约束限制:

不涉及

取值范围:

  • on: 开启

  • off: 关闭

默认取值:

不涉及

remote_auth_rules

RemoteAuthRule object

参数解释:

远程鉴权配置

约束限制:

不涉及

表25 RemoteAuthRule

参数

是否必选

参数类型

描述

auth_server

String

参数解释:

可访问的鉴权服务器地址

约束限制:

  • 输入的URL必须有“http”或“https”

  • 不能是localhost或127.0.0.1这类本地地址

  • 不能是CDN的加速域名

取值范围:

不涉及

默认取值:

不涉及

request_method

String

参数解释:

鉴权服务器支持的请求方法

约束限制:

不涉及

取值范围:

  • GET

  • POST

  • HEAD

默认取值:

不涉及

file_type_setting

String

参数解释:

参与鉴权的文件类型

约束限制:

不涉及

取值范围:

  • all: 所有文件均参与鉴权

  • specific_file: 指定类型的文件参与鉴权。示例:jpg|MP4

说明:
文件类型不区分大小写,即:jpg和JPG代表同一种文件类型,多个文件类型用“|”分隔

默认取值:

不涉及

specified_file_type

String

参数解释:

参与鉴权的具体文件类型

约束限制:

  • 当file_type_setting等于specific_file时为必选,其余情况为空

  • 文件类型用竖线分隔,例如jpg|mp4

  • 只有在必选情况下才会对该字段做校验

取值范围:

  • 1-512个字符

  • 由大小写字母和数字构成

默认取值:

不涉及

reserve_args_setting

String

参数解释:

参加鉴权的参数

约束限制:

不涉及

取值范围:

  • reserve_all_args: 保留所有URL参数

  • reserve_specific_args: 保留指定URL参数

  • ignore_all_args: 忽略所有URL参数

默认取值:

不涉及

reserve_args

String

参数解释:

设置参数

约束限制:

  • 当reserve_args_setting为reserve_specific_args时为必选,其余情况为空

  • 多个参数用竖线分隔:key1|key2

取值范围:

不涉及

默认取值:

不涉及

add_custom_args_rules

Array of customArgs objects

参数解释:

设置CDN节点转发用户请求到远程鉴权服务器时需添加的参数

约束限制:

不涉及

取值范围:

不涉及

默认取值:

不涉及

reserve_headers_setting

String

参数解释:

设置CDN节点转发用户请求到远程鉴权服务器时需要添加的请求头

约束限制:

不涉及

取值范围:

  • reserve_all_headers: 保留所有请求头参数

  • reserve_specific_headers: 保留指定请求头参数

  • ignore_all_headers: 忽略所有请求头参数

默认取值:

不涉及

add_custom_headers_rules

Array of customArgs objects

参数解释:

请求头鉴权参数

约束限制:

不涉及

取值范围:

不涉及

默认取值:

不涉及

auth_success_status

String

参数解释:

设置鉴权成功时远程鉴权服务器返回给CDN节点的状态码

约束限制:

不涉及

取值范围:

  • 2xx

  • 3xx

默认取值:

不涉及

auth_failed_status

String

参数解释:

设置鉴权失败时远程鉴权服务器返回给CDN节点的状态码

约束限制:

不涉及

取值范围:

  • 4xx

  • 5xx

默认取值:

不涉及

response_status

String

参数解释:

设置鉴权失败时CDN节点返回给用户的状态码

约束限制:

不涉及

取值范围:

  • 2xx

  • 3xx

  • 4xx

  • 5xx

默认取值:

不涉及

timeout

Integer

参数解释:

设置鉴权超时时间,即从CDN转发鉴权请求开始,到CDN节点收到远程鉴权服务器返回的结果的时间

约束限制:

不涉及

取值范围:

0或50-3000,单位:毫秒

默认取值:

不涉及

timeout_action

String

参数解释:

设置鉴权超时后,CDN节点如何处理用户请求

约束限制:

不涉及

取值范围:

  • pass:鉴权超时后允许用户请求,返回对应的资源

  • forbid:鉴权超时后拒绝用户请求,返回配置的响应自定义状态码给用户

默认取值:

不涉及

reserve_headers

String

参数解释:

要保留的请求头

约束限制:

  • 当reserve_headers_setting为reserve_specific_headers时为必选,其余情况为空

  • 多个请求头用竖线分隔:key1|key2

取值范围:

不涉及

默认取值:

不涉及

表26 customArgs

参数

是否必选

参数类型

描述

type

String

参数解释:

参数类型

约束限制:

不涉及

取值范围:

  • custom_var: 自定义

  • nginx_preset_var: 预置的变量

默认取值:

不涉及

key

String

参数解释:

参数名

约束限制:

不涉及

取值范围:

  • 1-256个字符

  • 由数字0-9、字符a-z、A-Z,及特殊字符._-*#%|+^@?=组成

默认取值:

不涉及

value

String

参数解释:

参数值

约束限制:

不涉及

取值范围:

  • 当type为custom_var时支持1-256个字符,由数字0-9、字符a-z、A-Z,及特殊字符._-*#%|+^@?=组成

  • 当type为nginx_preset_var时,value只能输入$http_host、$http_user_agent、$http_referer、$http_x_forwarded_for、$http_content_type、$remote_addr、$scheme、$server_protocol、$request_uri、$uri、$args、$request_method

默认取值:

不涉及

表27 webSocketSeek

参数

是否必选

参数类型

描述

status

String

参数解释:

是否开启websocket协议

约束限制:

不涉及

取值范围:

  • on: 开启

  • off: 关闭

默认取值:

不涉及

timeout

Integer

参数解释:

请求建立连接后,会话的保持时间

约束限制:

不涉及

取值范围:

1-300,单位:秒,当status为on时必填

默认取值:

不涉及

表28 videoSeek

参数

是否必选

参数类型

描述

enable_video_seek

Boolean

参数解释:

视频拖拽开关

约束限制:

当本字段设置为“false”时,查询域名配置接口将不会返回视频拖拽配置信息

取值范围:

  • true: 开启

  • false: 关闭

默认取值:

不涉及

enable_flv_by_time_seek

Boolean

参数解释:

flv时间拖拽开关

约束限制:

不涉及

取值范围:

  • true: 开启

  • false: 关闭

默认取值:

不涉及

start_parameter

String

参数解释:

自定义用户请求URL中视频播放的开始参数

约束限制:

不涉及

取值范围:

  • 1-64个字符

  • 支持使用数字0-9、字符a-z、A-Z,及"_"

默认取值:

不涉及

end_parameter

String

参数解释:

自定义用户请求URL中视频播放的结束参数

约束限制:

不涉及

取值范围:

  • 1-64个字符

  • 支持使用数字0-9、字符a-z、A-Z,及"_"

默认取值:

不涉及

表29 RequestLimitRules

参数

是否必选

参数类型

描述

status

String

参数解释:

是否开启请求限速

说明:
  • 此为旧接口中的参数,后续将下线

  • 只支持on,off无效

约束限制:

request_limit_rules字段置空时代表关闭请求限速功能

取值范围:

on

默认取值:

不涉及

priority

Integer

参数解释:

优先级

说明:
数值越大优先级越高

约束限制:

优先级不能相同

取值范围:

1-100

默认取值:

不涉及

match_type

String

参数解释:

匹配类型

约束限制:

不涉及

取值范围:

  • all:所有文件

  • catalog:目录

默认取值:

不涉及

match_value

String

参数解释:

匹配类型值

约束限制:

  • 当match_type为all时传空值,例如:""

  • 当match_type为catalog时传目录地址,以“/”作为首字符,例如:"/test"

  • 值为catalog的时候必填

取值范围:

不涉及

默认取值:

不涉及

type

String

参数解释:

限速方式

约束限制:

当前仅支持按流量大小限速,取值为size

取值范围:

不涉及

默认取值:

不涉及

limit_rate_after

Long

参数解释:

限速条件

说明:
例如:type=size,limit_rate_after=50表示从传输50个字节后开始限速且限速值为limit_rate_value

约束限制:

不涉及

取值范围:

0-1073741824,单位:byte

默认取值:

不涉及

limit_rate_value

Integer

参数解释:

限速值,即达到限速条件后的最大访问速度

约束限制:

不涉及

取值范围:

0-104857600,单位:Bps

默认取值:

不涉及

limit_time

String

参数解释:

指明限速的时段

约束限制:

  • 按照每天24小时设置限速时段,格式为:HHMM-HHMM(HH为时,MM为分,时区为UTC+8)

  • 多个时段限速时用“,”分隔,例如:0100-0200,2200-2300

  • 最多可配置10个时段

取值范围:

不涉及

默认取值:

0000-2400

表30 IpFrequencyLimit

参数

是否必选

参数类型

描述

status

String

参数解释:

IP访问限频状态开关

约束限制:

不涉及

取值范围:

  • on: 开启

  • off: 关闭

默认取值:

不涉及

qps

Integer

参数解释:

访问阈值

约束限制:

当开启ip限频时,访问阈值必填

取值范围:

1-100000,单位:次/秒

默认取值:

不涉及

表31 Hsts

参数

是否必选

参数类型

描述

status

String

参数解释:

HSTS功能状态开关

约束限制:

不涉及

取值范围:

  • on: 开启

  • off: 关闭

默认取值:

不涉及

max_age

Integer

参数解释:

过期时间,即响应头“Strict-Transport-Security”在客户端的缓存时间

约束限制:

status参数为on时,必传

取值范围:

0-63072000,单位:秒

默认取值:

不涉及

include_subdomains

String

参数解释:

是否包含子域名

约束限制:

status参数为on时,必传

取值范围:

  • on: 包含

  • off: 不包含

默认取值:

不涉及

表32 Quic

参数

是否必选

参数类型

描述

status

String

参数解释:

QUIC功能状态开关

约束限制:

不涉及

取值范围:

  • on: 开启

  • off: 关闭

默认取值:

不涉及

表33 ErrorCodeRedirectRules

参数

是否必选

参数类型

描述

error_code

Integer

参数解释:

重定向的错误码

约束限制:

不涉及

取值范围:

  • 4xx: 400, 403, 404, 405, 414, 416, 451

  • 5xx: 500, 501, 502, 503, 504

默认取值:

不涉及

target_code

Integer

参数解释:

重定向状态码

约束限制:

不涉及

取值范围:

  • 301

  • 302

默认取值:

不涉及

target_link

String

参数解释:

重定向的目标链接

约束限制:

必须以http://或https://开头

取值范围:

不涉及

默认取值:

不涉及

表34 Sni

参数

是否必选

参数类型

描述

status

String

参数解释:

是否开启回源SNI

约束限制:

不涉及

取值范围:

  • on: 开启

  • off: 关闭

默认取值:

不涉及

server_name

String

参数解释:

CDN节点回源时使用HTTPS协议握手的sni域名

约束限制:

  • 开启回源SNI时必填

取值范围:

  • 仅支持输入数字、“-”、“.”、英文大小写字符

默认取值:

表35 RequestUrlRewrite

参数

是否必选

参数类型

描述

condition

UrlRewriteCondition object

参数解释:

匹配条件

约束限制:

不涉及

取值范围:

不涉及

默认取值:

不涉及

redirect_status_code

Integer

参数解释:

重定向状态码

约束限制:

不涉及

取值范围:

  • 301

  • 302

  • 303

  • 307

默认取值:

不涉及

redirect_url

String

参数解释:

重定向URL

约束限制:

  • 重定向后的URL,以正斜线(/)开头,不含http://头及域名,如:/test/index.html

  • 当匹配类型为全路径时,"*"可以用“$1”捕获,例如:匹配内容为/test/*.jpg,重定向URL配置为/newtest/$1.jpg,则用户请求/test/11.jpg时,$1捕获11,重定向后请求的URL为/newtest/11.jpg

取值范围:

不涉及

默认取值:

不涉及

redirect_host

String

参数解释:

支持将客户端请求重定向到其他域名

约束限制:

不涉及

取值范围:

  • 1-255个字符

  • 必须以http://或https://开头

默认取值:

不填时默认为当前域名

execution_mode

String

参数解释:

执行规则

约束限制:

不涉及

取值范围:

  • redirect: 如果请求的URL匹配了当前规则,该请求将被重定向到目标Path。执行完当前规则后,当存在其他配置规则时,会继续匹配剩余规则

  • break: 如果请求的URL匹配了当前规则,请求将被改写为目标Path。执行完当前规则后,当存在其他配置规则时,将不再匹配剩余规则,此时不支持配置重定向Host和重定向状态码,返回状态码200

默认取值:

不涉及

表36 UrlRewriteCondition

参数

是否必选

参数类型

描述

match_type

String

参数解释:

匹配类型

约束限制:

不涉及

取值范围:

  • catalog: 指定目录下的文件需执行访问URL重写规则

  • full_path: 某个完整路径下的文件需执行访问URL重写规则

默认取值:

不涉及

match_value

String

参数解释:

匹配内容

约束限制:

  • 当match_type为catalog时,为目录路径,输入要求以“/”作为首字符,以“,”进行分隔,如/test/folder01,/test/folder02,并且输入的目录路径总数不超过20个

  • 当match_type为full_path时,为全路径,输入要求以“/”作为首字符,支持匹配指定目录下的具体文件,或者带通配符“*”的文件,单条全路径缓存规则里仅支持配置一个全路径,如/test/index.html或/test/*.jpg

取值范围:

不涉及

默认取值:

不涉及

priority

Integer

参数解释:

访问URL重写规则的优先级

说明:
数值越大优先级越高

约束限制:

不支持多条规则设置同一优先级

取值范围:

1-100

默认取值:

不涉及

表37 BrowserCacheRules

参数

是否必选

参数类型

描述

condition

BrowserCacheRulesCondition object

参数解释:

匹配条件

约束限制:

不涉及

取值范围:

不涉及

默认取值:

不涉及

cache_type

String

参数解释:

缓存生效类型

约束限制:

不涉及

取值范围:

  • follow_origin: 遵循源站的缓存策略,即Cache-Control头部的设置

  • ttl: 浏览器缓存遵循当前规则设置的过期时间

  • never: 浏览器不缓存资源

默认取值:

不涉及

ttl

Integer

参数解释:

缓存过期时间

约束限制:

  • 最大支持365天

  • 当缓存生效类型为ttl时必填

取值范围:

不涉及

默认取值:

不涉及

ttl_unit

String

参数解释:

缓存过期时间单位

约束限制:

当缓存生效类型为ttl时必填

取值范围:

  • s:秒

  • m:分钟

  • h:小时

  • d:天

默认取值:

不涉及

表38 BrowserCacheRulesCondition

参数

是否必选

参数类型

描述

match_type

String

参数解释:

匹配类型

约束限制:

不涉及

取值范围:

  • all: 匹配所有文件

  • file_extension: 按文件后缀匹配

  • catalog: 按目录匹配

  • full_path: 全路径匹配

  • home_page: 按首页匹配

默认取值:

不涉及

match_value

String

参数解释:

缓存匹配设置

约束限制:

  • 当match_type为all时,置空

  • 当match_type为file_extension时,为文件后缀,输入首字符为“.”,以“,”进行分隔, 如.jpg,.zip,.exe,并且输入的文 件名后缀总数不超过20个

  • 当match_type为catalog时,为目录,输入要求以“/”作为首字符, 以“,”进行分隔,如/test/folder01,/test/folder02,并且输入的目录路径总数不超过20个

  • 当match_type为full_path时,为全路径,输入要求以“/”作为首字符,支持匹配指定目录下的具体文件,或者带通配符“*”的文件, “*”的位置必须在最后一个“/”的后一位,且不能以“*”结尾,单条全路径缓存规则里仅支持配置一个全路径,如/test/index.html或/test/*.jpg

  • 当match_type为home_page时,置空

取值范围:

不涉及

默认取值:

不涉及

priority

Integer

参数解释:

浏览器缓存的优先级, 数值越大优先级越高

约束限制:

不支持多条规则设置同一优先级

取值范围:

不涉及

默认取值:

1-100

表39 AccessAreaFilter

参数

是否必选

参数类型

描述

type

String

参数解释:

规则类型

约束限制:

不涉及

取值范围:

  • black: 黑名单,如果匹配到黑名单规则,则黑名单所选区域内的用户将无法访问当前资源,返回403状态码

  • white: 白名单,白名单所选区域以外的用户均无法访问当前资源,返回403状态码

默认取值:

不涉及

content_type

String

参数解释:

生效类型

约束限制:

不涉及

取值范围:

  • all: 所有文件,所有文件均遵循配置的规则

  • file_directory: 目录路径,指定目录路径的资源遵循配置的规则

  • file_path: 全路径,指定路径的资源遵循配置的规则

默认取值:

不涉及

content_value

String

参数解释:

生效规则

约束限制:

  • 当content_type为all时,置空或不传

  • 当content_type为file_directory时,输入要求以“/”作为首字符,多个目录以“,”进行分隔,如/test/folder01,/test/folder02,并且输入的目录路径总数不超过100个

  • 当content_type为file_path时,输入要求以“/”或“*”作为首字符,支持配置通配符“*”,通配符不能连续出现且不能超过两个。多个路径以“,”进行分隔,如/test/a.txt,/test/b.txt,并且输出的总数不能超过100个

  • 不允许配置两条完全一样的白名单或黑名单规则

  • 仅允许配置一条生效类型为“所有文件”的规则

取值范围:

不涉及

默认取值:

不涉及

area

String

参数解释:

配置规则适用的区域

约束限制:

  • 多个区域以“,”进行分隔

  • 支持的区域如:CN_IN:中国大陆,AF:阿富汗,IE:爱尔兰,EG:埃及,AU:澳大利亚等。具体的位置编码参见《附录-地理位置编码》查询

取值范围:

不涉及

默认取值:

不涉及

exception_ip

String

参数解释:

例外IP,配置指定IP不执行当前规则

约束限制:

不涉及

取值范围:

不涉及

默认取值:

不涉及

表40 ClientCert

参数

是否必选

参数类型

描述

status

String

参数解释:

客户端证书配置开关

约束限制:

不涉及

取值范围:

  • on: 开启

  • off: 关闭

默认取值:

不涉及

trusted_cert

String

参数解释:

客户端CA证书的内容

约束限制:

仅支持PEM格式

取值范围:

不涉及

默认取值:

不涉及

hosts

String

参数解释:

客户端CA证书指定的域名

约束限制:

  • 如果不配置域名,则CDN会放行所有持有该CA证书的客户端请求

  • 最多可配置100个域名

  • 多个域名用“,”或“|”分隔

取值范围:

不涉及

默认取值:

不涉及

响应参数

状态码:204

请求成功。

请求示例

PUT https://cdn.myhuaweicloud.com/v1.1/cdn/configuration/domains/www.example.com/configs

{
  "configs" : {
    "origin_request_header" : [ {
      "name" : "test-name",
      "value" : "test_value",
      "action" : "set"
    } ],
    "http_response_header" : [ {
      "name" : "test-name",
      "value" : "test_value",
      "action" : "set"
    } ],
    "url_auth" : {
      "status" : "off"
    },
    "compress" : {
      "status" : "off"
    },
    "force_redirect" : {
      "status" : "on",
      "type" : "http",
      "redirect_code" : 301
    },
    "origin_protocol" : "follow",
    "referer" : {
      "type" : "black",
      "value" : "192.168.0.0",
      "include_empty" : true
    },
    "ip_filter" : {
      "type" : "black",
      "value" : "192.168.0.0"
    },
    "origin_follow302_status" : "off",
    "cache_rules" : [ {
      "match_type" : "file_extension",
      "match_value" : ".zip",
      "ttl" : 0,
      "ttl_unit" : "h",
      "priority" : 10,
      "follow_origin" : "off",
      "url_parameter_type" : "del_params",
      "url_parameter_value" : "test_param"
    } ],
    "sources" : [ {
      "origin_addr" : "www.example.com",
      "origin_type" : "domain",
      "priority" : 70,
      "http_port" : 80,
      "https_port" : 443
    } ],
    "flexible_origin" : [ {
      "priority" : 1,
      "match_type" : "file_path",
      "match_pattern" : "/test",
      "back_sources" : [ {
        "sources_type" : "domain",
        "ip_or_domain" : "www.back.example.com"
      } ]
    } ],
    "slice_etag_status" : "off",
    "ipv6_accelerate" : 1,
    "origin_receive_timeout" : 30,
    "remote_auth" : {
      "remote_authentication" : "on",
      "remote_auth_rules" : {
        "auth_server" : "https://192.168.0.0",
        "request_method" : "GET",
        "file_type_setting" : "all",
        "reserve_args_setting" : "reserve_all_args",
        "reserve_headers_setting" : "reserve_specific_headers",
        "auth_success_status" : "200",
        "auth_failed_status" : "403",
        "response_status" : "403",
        "timeout" : 500,
        "timeout_action" : "pass",
        "reserve_headers" : "sf",
        "add_custom_args_rules" : [ {
          "type" : "nginx_preset_var",
          "key" : "http_host",
          "value" : "$http_host"
        } ],
        "add_custom_headers_rules" : [ {
          "type" : "nginx_preset_var",
          "key" : "http_host",
          "value" : "$http_host"
        } ]
      }
    },
    "websocket" : {
      "status" : "on",
      "timeout" : 60
    },
    "video_seek" : {
      "enable_video_seek" : true,
      "enable_flv_by_time_seek" : true,
      "start_parameter" : "start",
      "end_parameter" : "end"
    },
    "request_limit_rules" : [ {
      "status" : "on",
      "match_type" : "catalog",
      "match_value" : "/test",
      "type" : "size",
      "limit_rate_after" : 1024,
      "limit_rate_value" : 50,
      "priority" : 88
    } ],
    "sni" : {
      "status" : "on",
      "server_name" : "test.example.com"
    },
    "request_url_rewrite" : [ {
      "condition" : {
        "match_type" : "full_path",
        "match_value" : "/test/*.jpg",
        "priority" : 10
      },
      "redirect_status_code" : 301,
      "redirect_url" : "/test/index.html",
      "redirect_host" : "http://www.example.com",
      "execution_mode" : "redirect"
    } ],
    "browser_cache_rules" : [ {
      "condition" : {
        "match_type" : "full_path",
        "match_value" : "/test/*.jpg",
        "priority" : 10
      },
      "cache_type" : "ttl",
      "ttl" : 20,
      "ttl_unit" : "h"
    } ],
    "access_area_filter" : [ {
      "type" : "black",
      "content_type" : "all",
      "area" : "CN_IN,AU",
      "exception_ip" : "0.0.0.0"
    } ],
    "client_cert" : {
      "status" : "on",
      "trusted_cert" : "certificate_example",
      "hosts" : "www.example.com"
    }
  }
}

响应示例

SDK代码示例

SDK代码示例如下。

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
package com.huaweicloud.sdk.test;

import com.huaweicloud.sdk.core.auth.ICredential;
import com.huaweicloud.sdk.core.auth.GlobalCredentials;
import com.huaweicloud.sdk.core.exception.ConnectionException;
import com.huaweicloud.sdk.core.exception.RequestTimeoutException;
import com.huaweicloud.sdk.core.exception.ServiceResponseException;
import com.huaweicloud.sdk.cdn.v2.region.CdnRegion;
import com.huaweicloud.sdk.cdn.v2.*;
import com.huaweicloud.sdk.cdn.v2.model.*;

import java.util.List;
import java.util.ArrayList;

public class UpdateDomainFullConfigSolution {

    public static void main(String[] args) {
        // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
        // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
        String ak = System.getenv("CLOUD_SDK_AK");
        String sk = System.getenv("CLOUD_SDK_SK");

        ICredential auth = new GlobalCredentials()
                .withAk(ak)
                .withSk(sk);

        CdnClient client = CdnClient.newBuilder()
                .withCredential(auth)
                .withRegion(CdnRegion.valueOf("<YOUR REGION>"))
                .build();
        UpdateDomainFullConfigRequest request = new UpdateDomainFullConfigRequest();
        request.withDomainName("{domain_name}");
        ModifyDomainConfigRequestBody body = new ModifyDomainConfigRequestBody();
        ClientCert clientCertConfigs = new ClientCert();
        clientCertConfigs.withStatus("on")
            .withTrustedCert("certificate_example")
            .withHosts("www.example.com");
        List<AccessAreaFilter> listConfigsAccessAreaFilter = new ArrayList<>();
        listConfigsAccessAreaFilter.add(
            new AccessAreaFilter()
                .withType("black")
                .withContentType("all")
                .withArea("CN_IN,AU")
                .withExceptionIp("0.0.0.0")
        );
        BrowserCacheRulesCondition conditionBrowserCacheRules = new BrowserCacheRulesCondition();
        conditionBrowserCacheRules.withMatchType("full_path")
            .withMatchValue("/test/*.jpg")
            .withPriority(10);
        List<BrowserCacheRules> listConfigsBrowserCacheRules = new ArrayList<>();
        listConfigsBrowserCacheRules.add(
            new BrowserCacheRules()
                .withCondition(conditionBrowserCacheRules)
                .withCacheType("ttl")
                .withTtl(20)
                .withTtlUnit("h")
        );
        UrlRewriteCondition conditionRequestUrlRewrite = new UrlRewriteCondition();
        conditionRequestUrlRewrite.withMatchType("full_path")
            .withMatchValue("/test/*.jpg")
            .withPriority(10);
        List<RequestUrlRewrite> listConfigsRequestUrlRewrite = new ArrayList<>();
        listConfigsRequestUrlRewrite.add(
            new RequestUrlRewrite()
                .withCondition(conditionRequestUrlRewrite)
                .withRedirectStatusCode(301)
                .withRedirectUrl("/test/index.html")
                .withRedirectHost("http://www.example.com")
                .withExecutionMode("redirect")
        );
        Sni sniConfigs = new Sni();
        sniConfigs.withStatus("on")
            .withServerName("test.example.com");
        List<RequestLimitRules> listConfigsRequestLimitRules = new ArrayList<>();
        listConfigsRequestLimitRules.add(
            new RequestLimitRules()
                .withStatus("on")
                .withPriority(88)
                .withMatchType("catalog")
                .withMatchValue("/test")
                .withType("size")
                .withLimitRateAfter(1024L)
                .withLimitRateValue(50)
        );
        VideoSeek videoSeekConfigs = new VideoSeek();
        videoSeekConfigs.withEnableVideoSeek(true)
            .withEnableFlvByTimeSeek(true)
            .withStartParameter("start")
            .withEndParameter("end");
        WebSocketSeek websocketConfigs = new WebSocketSeek();
        websocketConfigs.withStatus("on")
            .withTimeout(60);
        List<CustomArgs> listRemoteAuthRulesAddCustomHeadersRules = new ArrayList<>();
        listRemoteAuthRulesAddCustomHeadersRules.add(
            new CustomArgs()
                .withType("nginx_preset_var")
                .withKey("http_host")
                .withValue("$http_host")
        );
        List<CustomArgs> listRemoteAuthRulesAddCustomArgsRules = new ArrayList<>();
        listRemoteAuthRulesAddCustomArgsRules.add(
            new CustomArgs()
                .withType("nginx_preset_var")
                .withKey("http_host")
                .withValue("$http_host")
        );
        RemoteAuthRule remoteAuthRulesRemoteAuth = new RemoteAuthRule();
        remoteAuthRulesRemoteAuth.withAuthServer("https://192.168.0.0")
            .withRequestMethod("GET")
            .withFileTypeSetting("all")
            .withReserveArgsSetting("reserve_all_args")
            .withAddCustomArgsRules(listRemoteAuthRulesAddCustomArgsRules)
            .withReserveHeadersSetting("reserve_specific_headers")
            .withAddCustomHeadersRules(listRemoteAuthRulesAddCustomHeadersRules)
            .withAuthSuccessStatus("200")
            .withAuthFailedStatus("403")
            .withResponseStatus("403")
            .withTimeout(500)
            .withTimeoutAction("pass")
            .withReserveHeaders("sf");
        CommonRemoteAuth remoteAuthConfigs = new CommonRemoteAuth();
        remoteAuthConfigs.withRemoteAuthentication("on")
            .withRemoteAuthRules(remoteAuthRulesRemoteAuth);
        List<BackSources> listFlexibleOriginBackSources = new ArrayList<>();
        listFlexibleOriginBackSources.add(
            new BackSources()
                .withSourcesType("domain")
                .withIpOrDomain("www.back.example.com")
        );
        List<FlexibleOrigins> listConfigsFlexibleOrigin = new ArrayList<>();
        listConfigsFlexibleOrigin.add(
            new FlexibleOrigins()
                .withMatchType("file_path")
                .withMatchPattern("/test")
                .withPriority(1)
                .withBackSources(listFlexibleOriginBackSources)
        );
        Compress compressConfigs = new Compress();
        compressConfigs.withStatus("off");
        ForceRedirectConfig forceRedirectConfigs = new ForceRedirectConfig();
        forceRedirectConfigs.withStatus("on")
            .withType("http")
            .withRedirectCode(301);
        RefererConfig refererConfigs = new RefererConfig();
        refererConfigs.withType("black")
            .withValue("192.168.0.0")
            .withIncludeEmpty(true);
        IpFilter ipFilterConfigs = new IpFilter();
        ipFilterConfigs.withType("black")
            .withValue("192.168.0.0");
        List<CacheRules> listConfigsCacheRules = new ArrayList<>();
        listConfigsCacheRules.add(
            new CacheRules()
                .withMatchType("file_extension")
                .withMatchValue(".zip")
                .withTtl(0)
                .withTtlUnit("h")
                .withPriority(10)
                .withFollowOrigin("off")
                .withUrlParameterType("del_params")
                .withUrlParameterValue("test_param")
        );
        List<SourcesConfig> listConfigsSources = new ArrayList<>();
        listConfigsSources.add(
            new SourcesConfig()
                .withOriginType("domain")
                .withOriginAddr("www.example.com")
                .withPriority(70)
                .withHttpPort(80)
                .withHttpsPort(443)
        );
        UrlAuth urlAuthConfigs = new UrlAuth();
        urlAuthConfigs.withStatus("off");
        List<HttpResponseHeader> listConfigsHttpResponseHeader = new ArrayList<>();
        listConfigsHttpResponseHeader.add(
            new HttpResponseHeader()
                .withName("test-name")
                .withValue("test_value")
                .withAction("set")
        );
        List<OriginRequestHeader> listConfigsOriginRequestHeader = new ArrayList<>();
        listConfigsOriginRequestHeader.add(
            new OriginRequestHeader()
                .withName("test-name")
                .withValue("test_value")
                .withAction("set")
        );
        Configs configsbody = new Configs();
        configsbody.withOriginRequestHeader(listConfigsOriginRequestHeader)
            .withHttpResponseHeader(listConfigsHttpResponseHeader)
            .withUrlAuth(urlAuthConfigs)
            .withSources(listConfigsSources)
            .withOriginProtocol("follow")
            .withOriginFollow302Status("off")
            .withCacheRules(listConfigsCacheRules)
            .withIpFilter(ipFilterConfigs)
            .withReferer(refererConfigs)
            .withForceRedirect(forceRedirectConfigs)
            .withCompress(compressConfigs)
            .withIpv6Accelerate(1)
            .withFlexibleOrigin(listConfigsFlexibleOrigin)
            .withSliceEtagStatus("off")
            .withOriginReceiveTimeout(30)
            .withRemoteAuth(remoteAuthConfigs)
            .withWebsocket(websocketConfigs)
            .withVideoSeek(videoSeekConfigs)
            .withRequestLimitRules(listConfigsRequestLimitRules)
            .withSni(sniConfigs)
            .withRequestUrlRewrite(listConfigsRequestUrlRewrite)
            .withBrowserCacheRules(listConfigsBrowserCacheRules)
            .withAccessAreaFilter(listConfigsAccessAreaFilter)
            .withClientCert(clientCertConfigs);
        body.withConfigs(configsbody);
        request.withBody(body);
        try {
            UpdateDomainFullConfigResponse response = client.updateDomainFullConfig(request);
            System.out.println(response.toString());
        } catch (ConnectionException e) {
            e.printStackTrace();
        } catch (RequestTimeoutException e) {
            e.printStackTrace();
        } catch (ServiceResponseException e) {
            e.printStackTrace();
            System.out.println(e.getHttpStatusCode());
            System.out.println(e.getRequestId());
            System.out.println(e.getErrorCode());
            System.out.println(e.getErrorMsg());
        }
    }
}
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
# coding: utf-8

import os
from huaweicloudsdkcore.auth.credentials import GlobalCredentials
from huaweicloudsdkcdn.v2.region.cdn_region import CdnRegion
from huaweicloudsdkcore.exceptions import exceptions
from huaweicloudsdkcdn.v2 import *

if __name__ == "__main__":
    # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
    # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
    ak = os.environ["CLOUD_SDK_AK"]
    sk = os.environ["CLOUD_SDK_SK"]

    credentials = GlobalCredentials(ak, sk)

    client = CdnClient.new_builder() \
        .with_credentials(credentials) \
        .with_region(CdnRegion.value_of("<YOUR REGION>")) \
        .build()

    try:
        request = UpdateDomainFullConfigRequest()
        request.domain_name = "{domain_name}"
        clientCertConfigs = ClientCert(
            status="on",
            trusted_cert="certificate_example",
            hosts="www.example.com"
        )
        listAccessAreaFilterConfigs = [
            AccessAreaFilter(
                type="black",
                content_type="all",
                area="CN_IN,AU",
                exception_ip="0.0.0.0"
            )
        ]
        conditionBrowserCacheRules = BrowserCacheRulesCondition(
            match_type="full_path",
            match_value="/test/*.jpg",
            priority=10
        )
        listBrowserCacheRulesConfigs = [
            BrowserCacheRules(
                condition=conditionBrowserCacheRules,
                cache_type="ttl",
                ttl=20,
                ttl_unit="h"
            )
        ]
        conditionRequestUrlRewrite = UrlRewriteCondition(
            match_type="full_path",
            match_value="/test/*.jpg",
            priority=10
        )
        listRequestUrlRewriteConfigs = [
            RequestUrlRewrite(
                condition=conditionRequestUrlRewrite,
                redirect_status_code=301,
                redirect_url="/test/index.html",
                redirect_host="http://www.example.com",
                execution_mode="redirect"
            )
        ]
        sniConfigs = Sni(
            status="on",
            server_name="test.example.com"
        )
        listRequestLimitRulesConfigs = [
            RequestLimitRules(
                status="on",
                priority=88,
                match_type="catalog",
                match_value="/test",
                type="size",
                limit_rate_after=1024,
                limit_rate_value=50
            )
        ]
        videoSeekConfigs = VideoSeek(
            enable_video_seek=True,
            enable_flv_by_time_seek=True,
            start_parameter="start",
            end_parameter="end"
        )
        websocketConfigs = WebSocketSeek(
            status="on",
            timeout=60
        )
        listAddCustomHeadersRulesRemoteAuthRules = [
            CustomArgs(
                type="nginx_preset_var",
                key="http_host",
                value="$http_host"
            )
        ]
        listAddCustomArgsRulesRemoteAuthRules = [
            CustomArgs(
                type="nginx_preset_var",
                key="http_host",
                value="$http_host"
            )
        ]
        remoteAuthRulesRemoteAuth = RemoteAuthRule(
            auth_server="https://192.168.0.0",
            request_method="GET",
            file_type_setting="all",
            reserve_args_setting="reserve_all_args",
            add_custom_args_rules=listAddCustomArgsRulesRemoteAuthRules,
            reserve_headers_setting="reserve_specific_headers",
            add_custom_headers_rules=listAddCustomHeadersRulesRemoteAuthRules,
            auth_success_status="200",
            auth_failed_status="403",
            response_status="403",
            timeout=500,
            timeout_action="pass",
            reserve_headers="sf"
        )
        remoteAuthConfigs = CommonRemoteAuth(
            remote_authentication="on",
            remote_auth_rules=remoteAuthRulesRemoteAuth
        )
        listBackSourcesFlexibleOrigin = [
            BackSources(
                sources_type="domain",
                ip_or_domain="www.back.example.com"
            )
        ]
        listFlexibleOriginConfigs = [
            FlexibleOrigins(
                match_type="file_path",
                match_pattern="/test",
                priority=1,
                back_sources=listBackSourcesFlexibleOrigin
            )
        ]
        compressConfigs = Compress(
            status="off"
        )
        forceRedirectConfigs = ForceRedirectConfig(
            status="on",
            type="http",
            redirect_code=301
        )
        refererConfigs = RefererConfig(
            type="black",
            value="192.168.0.0",
            include_empty=True
        )
        ipFilterConfigs = IpFilter(
            type="black",
            value="192.168.0.0"
        )
        listCacheRulesConfigs = [
            CacheRules(
                match_type="file_extension",
                match_value=".zip",
                ttl=0,
                ttl_unit="h",
                priority=10,
                follow_origin="off",
                url_parameter_type="del_params",
                url_parameter_value="test_param"
            )
        ]
        listSourcesConfigs = [
            SourcesConfig(
                origin_type="domain",
                origin_addr="www.example.com",
                priority=70,
                http_port=80,
                https_port=443
            )
        ]
        urlAuthConfigs = UrlAuth(
            status="off"
        )
        listHttpResponseHeaderConfigs = [
            HttpResponseHeader(
                name="test-name",
                value="test_value",
                action="set"
            )
        ]
        listOriginRequestHeaderConfigs = [
            OriginRequestHeader(
                name="test-name",
                value="test_value",
                action="set"
            )
        ]
        configsbody = Configs(
            origin_request_header=listOriginRequestHeaderConfigs,
            http_response_header=listHttpResponseHeaderConfigs,
            url_auth=urlAuthConfigs,
            sources=listSourcesConfigs,
            origin_protocol="follow",
            origin_follow302_status="off",
            cache_rules=listCacheRulesConfigs,
            ip_filter=ipFilterConfigs,
            referer=refererConfigs,
            force_redirect=forceRedirectConfigs,
            compress=compressConfigs,
            ipv6_accelerate=1,
            flexible_origin=listFlexibleOriginConfigs,
            slice_etag_status="off",
            origin_receive_timeout=30,
            remote_auth=remoteAuthConfigs,
            websocket=websocketConfigs,
            video_seek=videoSeekConfigs,
            request_limit_rules=listRequestLimitRulesConfigs,
            sni=sniConfigs,
            request_url_rewrite=listRequestUrlRewriteConfigs,
            browser_cache_rules=listBrowserCacheRulesConfigs,
            access_area_filter=listAccessAreaFilterConfigs,
            client_cert=clientCertConfigs
        )
        request.body = ModifyDomainConfigRequestBody(
            configs=configsbody
        )
        response = client.update_domain_full_config(request)
        print(response)
    except exceptions.ClientRequestException as e:
        print(e.status_code)
        print(e.request_id)
        print(e.error_code)
        print(e.error_msg)
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
package main

import (
	"fmt"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/global"
    cdn "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cdn/v2"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cdn/v2/model"
    region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cdn/v2/region"
)

func main() {
    // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
    // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
    ak := os.Getenv("CLOUD_SDK_AK")
    sk := os.Getenv("CLOUD_SDK_SK")

    auth := global.NewCredentialsBuilder().
        WithAk(ak).
        WithSk(sk).
        Build()

    client := cdn.NewCdnClient(
        cdn.CdnClientBuilder().
            WithRegion(region.ValueOf("<YOUR REGION>")).
            WithCredential(auth).
            Build())

    request := &model.UpdateDomainFullConfigRequest{}
	request.DomainName = "{domain_name}"
	hostsClientCert:= "www.example.com"
	clientCertConfigs := &model.ClientCert{
		Status: "on",
		TrustedCert: "certificate_example",
		Hosts: &hostsClientCert,
	}
	typeAccessAreaFilter:= "black"
	contentTypeAccessAreaFilter:= "all"
	areaAccessAreaFilter:= "CN_IN,AU"
	exceptionIpAccessAreaFilter:= "0.0.0.0"
	var listAccessAreaFilterConfigs = []model.AccessAreaFilter{
        {
            Type: &typeAccessAreaFilter,
            ContentType: &contentTypeAccessAreaFilter,
            Area: &areaAccessAreaFilter,
            ExceptionIp: &exceptionIpAccessAreaFilter,
        },
    }
	matchValueCondition:= "/test/*.jpg"
	conditionBrowserCacheRules := &model.BrowserCacheRulesCondition{
		MatchType: "full_path",
		MatchValue: &matchValueCondition,
		Priority: int32(10),
	}
	ttlBrowserCacheRules:= int32(20)
	ttlUnitBrowserCacheRules:= "h"
	var listBrowserCacheRulesConfigs = []model.BrowserCacheRules{
        {
            Condition: conditionBrowserCacheRules,
            CacheType: "ttl",
            Ttl: &ttlBrowserCacheRules,
            TtlUnit: &ttlUnitBrowserCacheRules,
        },
    }
	conditionRequestUrlRewrite := &model.UrlRewriteCondition{
		MatchType: "full_path",
		MatchValue: "/test/*.jpg",
		Priority: int32(10),
	}
	redirectStatusCodeRequestUrlRewrite:= int32(301)
	redirectHostRequestUrlRewrite:= "http://www.example.com"
	var listRequestUrlRewriteConfigs = []model.RequestUrlRewrite{
        {
            Condition: conditionRequestUrlRewrite,
            RedirectStatusCode: &redirectStatusCodeRequestUrlRewrite,
            RedirectUrl: "/test/index.html",
            RedirectHost: &redirectHostRequestUrlRewrite,
            ExecutionMode: "redirect",
        },
    }
	serverNameSni:= "test.example.com"
	sniConfigs := &model.Sni{
		Status: "on",
		ServerName: &serverNameSni,
	}
	statusRequestLimitRules:= "on"
	matchValueRequestLimitRules:= "/test"
	var listRequestLimitRulesConfigs = []model.RequestLimitRules{
        {
            Status: &statusRequestLimitRules,
            Priority: int32(88),
            MatchType: "catalog",
            MatchValue: &matchValueRequestLimitRules,
            Type: "size",
            LimitRateAfter: int64(1024),
            LimitRateValue: int32(50),
        },
    }
	enableFlvByTimeSeekVideoSeek:= true
	startParameterVideoSeek:= "start"
	endParameterVideoSeek:= "end"
	videoSeekConfigs := &model.VideoSeek{
		EnableVideoSeek: true,
		EnableFlvByTimeSeek: &enableFlvByTimeSeekVideoSeek,
		StartParameter: &startParameterVideoSeek,
		EndParameter: &endParameterVideoSeek,
	}
	websocketConfigs := &model.WebSocketSeek{
		Status: "on",
		Timeout: int32(60),
	}
	var listAddCustomHeadersRulesRemoteAuthRules = []model.CustomArgs{
        {
            Type: "nginx_preset_var",
            Key: "http_host",
            Value: "$http_host",
        },
    }
	var listAddCustomArgsRulesRemoteAuthRules = []model.CustomArgs{
        {
            Type: "nginx_preset_var",
            Key: "http_host",
            Value: "$http_host",
        },
    }
	reserveHeadersRemoteAuthRules:= "sf"
	remoteAuthRulesRemoteAuth := &model.RemoteAuthRule{
		AuthServer: "https://192.168.0.0",
		RequestMethod: "GET",
		FileTypeSetting: "all",
		ReserveArgsSetting: "reserve_all_args",
		AddCustomArgsRules: &listAddCustomArgsRulesRemoteAuthRules,
		ReserveHeadersSetting: "reserve_specific_headers",
		AddCustomHeadersRules: &listAddCustomHeadersRulesRemoteAuthRules,
		AuthSuccessStatus: "200",
		AuthFailedStatus: "403",
		ResponseStatus: "403",
		Timeout: int32(500),
		TimeoutAction: "pass",
		ReserveHeaders: &reserveHeadersRemoteAuthRules,
	}
	remoteAuthConfigs := &model.CommonRemoteAuth{
		RemoteAuthentication: "on",
		RemoteAuthRules: remoteAuthRulesRemoteAuth,
	}
	var listBackSourcesFlexibleOrigin = []model.BackSources{
        {
            SourcesType: "domain",
            IpOrDomain: "www.back.example.com",
        },
    }
	var listFlexibleOriginConfigs = []model.FlexibleOrigins{
        {
            MatchType: "file_path",
            MatchPattern: "/test",
            Priority: int32(1),
            BackSources: listBackSourcesFlexibleOrigin,
        },
    }
	compressConfigs := &model.Compress{
		Status: "off",
	}
	typeForceRedirect:= "http"
	redirectCodeForceRedirect:= int32(301)
	forceRedirectConfigs := &model.ForceRedirectConfig{
		Status: "on",
		Type: &typeForceRedirect,
		RedirectCode: &redirectCodeForceRedirect,
	}
	valueReferer:= "192.168.0.0"
	includeEmptyReferer:= true
	refererConfigs := &model.RefererConfig{
		Type: "black",
		Value: &valueReferer,
		IncludeEmpty: &includeEmptyReferer,
	}
	valueIpFilter:= "192.168.0.0"
	ipFilterConfigs := &model.IpFilter{
		Type: "black",
		Value: &valueIpFilter,
	}
	matchTypeCacheRules:= "file_extension"
	matchValueCacheRules:= ".zip"
	ttlCacheRules:= int32(0)
	followOriginCacheRules:= "off"
	urlParameterTypeCacheRules:= "del_params"
	urlParameterValueCacheRules:= "test_param"
	var listCacheRulesConfigs = []model.CacheRules{
        {
            MatchType: &matchTypeCacheRules,
            MatchValue: &matchValueCacheRules,
            Ttl: &ttlCacheRules,
            TtlUnit: "h",
            Priority: int32(10),
            FollowOrigin: &followOriginCacheRules,
            UrlParameterType: &urlParameterTypeCacheRules,
            UrlParameterValue: &urlParameterValueCacheRules,
        },
    }
	httpPortSources:= int32(80)
	httpsPortSources:= int32(443)
	var listSourcesConfigs = []model.SourcesConfig{
        {
            OriginType: "domain",
            OriginAddr: "www.example.com",
            Priority: int32(70),
            HttpPort: &httpPortSources,
            HttpsPort: &httpsPortSources,
        },
    }
	urlAuthConfigs := &model.UrlAuth{
		Status: "off",
	}
	valueHttpResponseHeader:= "test_value"
	var listHttpResponseHeaderConfigs = []model.HttpResponseHeader{
        {
            Name: "test-name",
            Value: &valueHttpResponseHeader,
            Action: "set",
        },
    }
	valueOriginRequestHeader:= "test_value"
	var listOriginRequestHeaderConfigs = []model.OriginRequestHeader{
        {
            Name: "test-name",
            Value: &valueOriginRequestHeader,
            Action: "set",
        },
    }
	originProtocolConfigs:= "follow"
	originFollow302StatusConfigs:= "off"
	ipv6AccelerateConfigs:= int32(1)
	sliceEtagStatusConfigs:= "off"
	originReceiveTimeoutConfigs:= int32(30)
	configsbody := &model.Configs{
		OriginRequestHeader: &listOriginRequestHeaderConfigs,
		HttpResponseHeader: &listHttpResponseHeaderConfigs,
		UrlAuth: urlAuthConfigs,
		Sources: &listSourcesConfigs,
		OriginProtocol: &originProtocolConfigs,
		OriginFollow302Status: &originFollow302StatusConfigs,
		CacheRules: &listCacheRulesConfigs,
		IpFilter: ipFilterConfigs,
		Referer: refererConfigs,
		ForceRedirect: forceRedirectConfigs,
		Compress: compressConfigs,
		Ipv6Accelerate: &ipv6AccelerateConfigs,
		FlexibleOrigin: &listFlexibleOriginConfigs,
		SliceEtagStatus: &sliceEtagStatusConfigs,
		OriginReceiveTimeout: &originReceiveTimeoutConfigs,
		RemoteAuth: remoteAuthConfigs,
		Websocket: websocketConfigs,
		VideoSeek: videoSeekConfigs,
		RequestLimitRules: &listRequestLimitRulesConfigs,
		Sni: sniConfigs,
		RequestUrlRewrite: &listRequestUrlRewriteConfigs,
		BrowserCacheRules: &listBrowserCacheRulesConfigs,
		AccessAreaFilter: &listAccessAreaFilterConfigs,
		ClientCert: clientCertConfigs,
	}
	request.Body = &model.ModifyDomainConfigRequestBody{
		Configs: configsbody,
	}
	response, err := client.UpdateDomainFullConfig(request)
	if err == nil {
        fmt.Printf("%+v\n", response)
    } else {
        fmt.Println(err)
    }
}

更多编程语言的SDK代码示例,请参见API Explorer的代码示例页签,可生成自动对应的SDK代码示例。

状态码

状态码

描述

204

请求成功。

错误码

请参见错误码

相关文档