修改域名全量配置接口
功能介绍
修改域名配置接口,支持修改业务类型、服务范围、备注、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
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
domain_name |
是 |
String |
参数解释: 加速域名 约束限制: 不涉及 取值范围: 不涉及 默认取值: 不涉及 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
enterprise_project_id |
否 |
String |
参数解释: 企业项目id。您可以通过调用企业项目管理服务(EPS)的查询企业项目列表接口(ListEnterpriseProject)查询企业项目id 约束限制: 当用户开启企业项目功能时,该参数生效,表示查询资源所属项目,"all"表示所有项目 取值范围: 不涉及 默认取值: 不涉及 |
请求参数
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
X-Auth-Token |
是 |
String |
参数解释: 用户鉴权Token,通过调用IAM服务获取用户Token接口获取(响应消息头中X-Subject-Token的值) 约束限制: 不涉及 取值范围: 不涉及 默认取值: 不涉及 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
configs |
否 |
Configs object |
参数解释: 配置项 约束限制: 不涉及 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
business_type |
否 |
String |
参数解释: 业务类型 约束限制: 暂不支持“全站加速”变更为其它业务类型 取值范围:
默认取值: 不涉及 |
service_area |
否 |
String |
参数解释: 加速域名的服务范围,客户端访问将会调度到服务范围内的CDN节点,可根据用户聚集区域选择合适的范围 约束限制:
取值范围:
默认取值: 不涉及 |
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回源时的请求协议 约束限制: 不涉及 取值范围:
默认取值: http: http协议 |
origin_follow302_status |
否 |
String |
参数解释: 开启回源跟随,当源站地址因业务需求做了301/302 重定向,CDN节点会先跳转到301/302对应地址获取资源,缓存后再返回给用户 约束限制: 不涉及 取值范围:
默认取值: 不涉及 |
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节点 约束限制: 不涉及 取值范围:
默认取值: 不涉及 |
error_code_cache |
否 |
Array of ErrorCodeCache objects |
参数解释: 将源站返回的错误状态码缓存到CDN节点,用户再次请求时由CDN直接响应给用户错误码 约束限制: 不涉及 |
origin_range_status |
否 |
String |
参数解释: Range回源,开启后,源站在收到CDN节点回源请求时,根据HTTP请求头中的Range信息返回指定范围的数据给CDN节点 约束限制: 开启Range回源的前提是您的源站支持Range请求,即HTTP请求头中包含Range字段,否则可能导致回源失败 取值范围:
默认取值: 不涉及 |
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的值加入到判断资源是否过期的逻辑 约束限制: 不涉及 取值范围:
默认取值: 不涉及 |
origin_receive_timeout |
否 |
Integer |
参数解释: 自定义设置CDN节点回源时的超时时间,请求超时即表示此次回源失败 约束限制: 不涉及 取值范围: 5-300,单位:秒 默认取值: 不涉及 |
remote_auth |
否 |
commonRemoteAuth object |
参数解释: 配置远程鉴权,当用户向CDN节点请求资源时,CDN将用户请求转发到客户指定的鉴权服务器,CDN根据鉴权服务器返回的结果判断是否给用户返回资源 约束限制: 不涉及 |
websocket |
否 |
webSocketSeek object |
参数解释: 是否允许客户端使用websocket协议访问CDN节点
说明:
WebSocket功能仅对缓存规则配置为“缓存过期时间为0,缓存过期时间来源为CDN且开启强制缓存”的资源生效
约束限制:
|
video_seek |
否 |
videoSeek object |
参数解释: 视频拖拽配置,用户可随意拖拽播放进度且不影响观看效果 约束限制:
|
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节点的双向证书认证,提高网站通信安全性 约束限制: 不涉及 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
name |
是 |
String |
参数解释: 设置回源请求头参数 约束限制: 不涉及 取值范围:
默认取值: 不涉及 |
value |
否 |
String |
参数解释: 设置回源请求头参数的值 约束限制: 不涉及 取值范围:
默认取值: 不涉及 |
action |
是 |
String |
参数解释: 回源请求头设置类型 约束限制:
取值范围:
默认取值: 不涉及 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
name |
是 |
String |
参数解释: 设置HTTP响应头参数 约束限制: 不涉及 取值范围:
默认取值: 不涉及 |
value |
否 |
String |
参数解释: 设置HTTP响应头参数的值 约束限制: 不涉及 取值范围:
默认取值: 不涉及 |
action |
是 |
String |
参数解释: 设置HTTP响应头操作类型 约束限制:
取值范围:
默认取值: 不涉及 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
status |
是 |
String |
参数解释: 是否开启URL鉴权 约束限制: 不涉及 取值范围:
默认取值: 不涉及 |
type |
否 |
String |
参数解释: 鉴权方式 约束限制: 不涉及 取值范围:
默认取值: 不涉及 |
expire_time |
否 |
Integer |
参数解释: 鉴权URL的有效时间 约束限制: 不涉及 取值范围: 0-31536000,单位:秒 默认取值: 不涉及 |
sign_method |
否 |
String |
参数解释: 加密算法 约束限制: 不涉及 取值范围:
默认取值: 不涉及 |
match_type |
否 |
String |
参数解释: 鉴权范围,指定哪些文件参与鉴权 约束限制: 不涉及 取值范围:
默认取值: 不涉及 |
match_rule |
否 |
String |
参数解释: 鉴权文件匹配规则 约束限制: 不涉及 取值范围:
默认取值: 不涉及 |
inherit_config |
否 |
InheritConfig object |
参数解释: 鉴权继承,为M3U8/MPD索引文件下的TS/MP4文件添加鉴权参数,解决因鉴权不通过导致的TS/MP4文件无法播放的问题 约束限制: 不涉及 |
key |
否 |
String |
参数解释: 鉴权密钥 约束限制: 不涉及 取值范围:
默认取值: 不涉及 |
backup_key |
否 |
String |
参数解释: 备选鉴权密钥,当需要替换密钥时,如果需要新旧密钥同时生效,可设置备KEY。主、备KEY之一鉴权通过即可正常访问 约束限制: 不涉及 取值范围:
默认取值: 不涉及 |
sign_arg |
否 |
String |
参数解释: 用户url中携带的鉴权信息参数名 约束限制: 鉴权方式为A或C2时需配置该参数 取值范围:
默认取值: auth_key |
time_format |
否 |
String |
参数解释: 时间格式 约束限制:
取值范围:
默认取值: 不涉及 |
time_arg |
否 |
String |
参数解释: 时间参数名称 约束限制: 鉴权方式为C2时,该字段可选 取值范围:
默认取值: timestamp |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
status |
是 |
String |
参数解释: 是否开启鉴权继承 约束限制: 不涉及 取值范围:
默认取值: 不涉及 |
inherit_type |
否 |
String |
参数解释: 鉴权继承配置 约束限制:
取值范围:
默认取值: 不涉及 |
inherit_time_type |
否 |
String |
参数解释: 鉴权继承开始时间 约束限制: 开启鉴权继承时,该参数必填 取值范围:
默认取值: 不涉及 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
https_status |
否 |
String |
参数解释: 证书配置开关 约束限制: 不涉及 取值范围:
默认取值: 不涉及 |
certificate_type |
否 |
String |
参数解释: 证书类型 约束限制: 不涉及 取值范围:
默认取值: 不涉及 |
certificate_source |
否 |
Integer |
参数解释: 证书来源 约束限制: 证书开启时必传 取值范围:
默认取值: 不涉及 |
scm_certificate_id |
否 |
String |
参数解释: SCM证书ID,可使用云证书管理服务(CCM)的查询证书列表接口获取 约束限制: 配置SCM证书时必传 取值范围: 不涉及 默认取值: 不涉及 |
certificate_name |
否 |
String |
参数解释: 证书名称 约束限制:
取值范围: 不涉及 默认取值: 不涉及 |
certificate_value |
否 |
String |
参数解释: HTTPS协议使用的证书内容 约束限制:
取值范围: 证书链长度不超过20KB 默认取值: 不涉及 |
private_key |
否 |
String |
参数解释: HTTPS协议使用的私钥 约束限制:
取值范围: 不涉及 默认取值: 不涉及 |
enc_certificate_value |
否 |
String |
参数解释: 加密证书内容 约束限制:
取值范围: 不涉及 默认取值: 不涉及 |
enc_private_key |
否 |
String |
参数解释: 加密私钥内容 约束限制:
取值范围: 不涉及 默认取值: 不涉及 |
certificates |
否 |
Array of CertificatesPutBody objects |
参数解释: 证书配置请求体 约束限制:
|
http2_status |
否 |
String |
参数解释: HTTP/2开关,支持客户端采用HTTP/2协议访问CDN节点 约束限制: https_status=off时,该值不生效 取值范围:
默认取值: off: 否 |
tls_version |
否 |
String |
参数解释: 传输层安全性协议,即TLS版本配置 约束限制:
取值范围: 目前支持TLSv1.0/1.1/1.2/1.3四个版本的协议 默认取值: TLS1.1/1.2/1.3 |
ocsp_stapling_status |
否 |
String |
参数解释: 是否开启ocsp stapling 约束限制: 不涉及 取值范围:
默认取值: 不涉及 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
certificate_source |
否 |
Integer |
参数解释: 证书来源 约束限制: 不涉及 取值范围:
默认取值: 不涉及 |
scm_certificate_id |
否 |
String |
参数解释: SCM证书ID,可使用云证书管理服务(CCM)的查询证书列表接口获取 约束限制: 配置SCM证书时必传 取值范围: 不涉及 默认取值: 不涉及 |
certificate_type |
是 |
String |
参数解释: 证书类型 约束限制: 不涉及 取值范围:
默认取值: 不涉及 |
certificate_name |
是 |
String |
参数解释: 证书名字 约束限制: 不涉及 取值范围: 3-64个字符 默认取值: 不涉及 |
certificate_value |
是 |
String |
参数解释: HTTPS协议使用的证书内容 约束限制: 仅支持PEM编码格式 取值范围: 不涉及 默认取值: 不涉及 |
private_key |
是 |
String |
参数解释: HTTPS协议使用的私钥 约束限制: 仅支持PEM编码格式 取值范围: 不涉及 默认取值: 不涉及 |
enc_certificate_value |
否 |
String |
参数解释: 加密证书内容 约束限制:
取值范围: 不涉及 默认取值: 不涉及 |
enc_private_key |
否 |
String |
参数解释: 加密私钥内容 约束限制:
取值范围: 不涉及 默认取值: 不涉及 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
origin_type |
是 |
String |
参数解释: 源站类型 约束限制: 不涉及 取值范围:
默认取值: 不涉及 |
origin_addr |
是 |
String |
参数解释: 源站IP或者域名 约束限制: 不涉及 取值范围: 不涉及 默认取值: 不涉及 |
priority |
是 |
Integer |
参数解释: 源站优先级 约束限制: 不涉及 取值范围: 1-100 默认取值: 不涉及 |
weight |
否 |
Integer |
参数解释: 权重 约束限制: 不涉及 取值范围: 1-100 默认取值: 不涉及 |
obs_web_hosting_status |
否 |
String |
参数解释: 是否开启OBS静态网站托管 约束限制: 源站类型为obs_bucket时传递 取值范围:
默认取值: 不涉及 |
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桶域名”时需要传该参数 取值范围:
默认取值: public: 关闭回源鉴权开关 |
bucket_access_key |
否 |
String |
参数解释: 第三方对象存储访问密钥ID,即AK 约束限制: 源站类型为第三方桶时必填 取值范围: 不涉及 默认取值: 不涉及 |
bucket_secret_key |
否 |
String |
参数解释: 第三方对象存储私密访问密钥,即SK 约束限制: 源站类型为第三方桶时必填 取值范围: 不涉及 默认取值: 不涉及 |
bucket_region |
否 |
String |
参数解释: 第三方对象存储区域 约束限制: 源站类型为第三方桶时必填 取值范围: 不涉及 默认取值: 不涉及 |
bucket_name |
否 |
String |
参数解释: 第三方对象存储名称 约束限制: 源站类型为第三方桶时必填 取值范围: 不涉及 默认取值: 不涉及 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
match_type |
是 |
String |
参数解释: 匹配类型 约束限制: 不涉及 取值范围:
默认取值: 不涉及 |
match_value |
否 |
String |
参数解释: 缓存规则匹配内容 约束限制:
取值范围: 不涉及 默认取值: 不涉及 |
ttl |
否 |
Integer |
参数解释: 资源在CDN节点的缓存过期时间 约束限制: 最大支持365天 取值范围: 不涉及 默认取值: 0 |
ttl_unit |
是 |
String |
参数解释: 缓存过期时间单位 约束限制: 不涉及 取值范围:
默认取值: 不涉及 |
priority |
是 |
Integer |
参数解释: 缓存规则的优先级,数值越大,优先级越高 约束限制: 优先级不能相同 取值范围: 1-100 默认取值: 不涉及 |
follow_origin |
否 |
String |
参数解释: 缓存过期时间来源,设置CDN节点的缓存遵循源站还是CDN侧的配置 约束限制: 不涉及 取值范围:
默认取值: off: CDN节点的缓存过期时间遵循“缓存规则”中的“缓存过期时间” |
force_cache |
否 |
String |
参数解释: 强制缓存:CDN节点缓存过期时间是否忽略源站响应头Cache-Control中的no-cache、private、no-store字段 约束限制: 强制缓存与缓存过期时间来源功能配合使用,具体使用限制及配置效果请参考CDN用户指南的配置节点缓存规则章节 取值范围:
默认取值: off: 关闭强制缓存 |
url_parameter_type |
否 |
String |
参数解释: URL参数 约束限制: 不涉及 取值范围:
默认取值: full_url: 使用完整URL参数 |
url_parameter_value |
否 |
String |
参数解释: URL参数值 约束限制:
取值范围: 不涉及 默认取值: 不涉及 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
type |
是 |
String |
参数解释: IP黑白名单类型 约束限制: 不涉及 取值范围:
默认取值: 不涉及 |
value |
否 |
String |
参数解释: 配置IP黑白名单
说明:
支持IPv6,支持配置IP地址和IP&掩码格式的网段
约束限制:
取值范围: 不涉及 默认取值: 不涉及 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
type |
是 |
String |
参数解释: Referer黑白名单类型 约束限制: 不涉及 取值范围:
默认取值: 不涉及 |
value |
否 |
String |
参数解释: 域名或IP地址
说明:
域名、IP地址可以混合输入,支持泛域名和带端口的域名
约束限制:
取值范围: 不涉及 默认取值: 不涉及 |
include_empty |
否 |
Boolean |
参数解释: 是否包含空Referer
说明:
如果是黑名单并开启该选项,则表示无referer不允许访问
如果是白名单并开启该选项,则表示无referer允许访问 约束限制: 不涉及 取值范围:
默认取值: false: 不包含空 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
status |
是 |
String |
参数解释: 强制跳转开关 约束限制: 不涉及 取值范围:
默认取值: 不涉及 |
type |
否 |
String |
参数解释: 强制跳转类型 约束限制: 如果开启强制跳转HTTPS,请先配置HTTPS证书,否则将导致访问失败 取值范围:
默认取值: 不涉及 |
redirect_code |
否 |
Integer |
参数解释: 重定向跳转码 约束限制: 不涉及 取值范围:
默认取值: 不涉及 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
status |
是 |
String |
参数解释: 智能压缩开关 约束限制: 不涉及 取值范围:
默认取值: 不涉及 |
type |
否 |
String |
参数解释: 智能压缩类型 约束限制: 当配置了多种智能压缩类型时,优先使用brotli压缩 取值范围: 多种智能压缩类型用“,”分隔,可选值如下:
默认取值: 不涉及 |
file_type |
否 |
String |
参数解释: 需要压缩的文件类型 约束限制: 不涉及 取值范围:
默认取值: 开启状态下,首次传空时默认值为.js,.html,.css,.xml,.json,.shtml,.htm,否则为上次设置值 |
compress_min_length |
否 |
Integer |
参数解释: 压缩区间最小范围 约束限制: 如果未设置参与压缩的文件大小,默认大小为“0MB~30MB”的文件参与压缩。 取值范围:
默认取值: 不涉及 |
compress_max_length |
否 |
Integer |
参数解释: 压缩区间最大范围 约束限制: 如果未设置参与压缩的文件大小,默认大小为“0MB~30MB”的文件参与压缩。 取值范围:
默认取值: 不涉及 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
type |
否 |
String |
参数解释: 缓存URL参数操作类型,即资源缓存时,URL参数的缓存范围 约束限制: 不涉及 取值范围:
说明:
本接口参数有调整,参数替换如下:
del_params替代del_args reserve_params替代reserve_args 默认取值: 不涉及 |
value |
否 |
String |
参数解释: URL参数的取值 约束限制: 多个参数使用“;”分隔 取值范围: 不涉及 默认取值: 不涉及 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
code |
否 |
Integer |
参数解释: 需要缓存的错误码 约束限制: 不涉及 取值范围:
默认取值: 不涉及 |
ttl |
否 |
Integer |
参数解释: 错误码缓存时间 约束限制: 不涉及 取值范围: 0-31536000,单位:秒
说明:
3XX状态码缓存时间范围为0-20s
默认取值: 不涉及 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
type |
是 |
String |
参数解释: UA黑白名单类型 约束限制: 不涉及 取值范围:
默认取值: 不涉及 |
value |
否 |
String |
参数解释: UA黑白名单内容
说明:
此参数作为旧参数,将于近期下线,建议使用ua_list字段设置UA黑白名单内容
约束限制:
取值范围:
默认取值: 不涉及 |
include_empty |
否 |
Boolean |
参数解释: 是否包含空UA
说明:
如果黑名单并开启该选项,则表示无UA不允许访问
如果是白名单并开启该选项,则表示无UA允许访问 约束限制: 不涉及 取值范围: true: 包含空 false:不包含空 默认取值:
|
ua_list |
否 |
Array of strings |
参数解释: 配置UA黑白名单 约束限制:
|
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
priority |
是 |
Integer |
参数解释: 回源URL改写规则的优先级
说明:
数值越大优先级越高,CDN按照优先级高的规则执行URL改写
约束限制:
取值范围: 1-100 默认取值: 不涉及 |
match_type |
是 |
String |
参数解释: 匹配类型 约束限制: 不涉及 取值范围:
默认取值: 不涉及 |
source_url |
否 |
String |
参数解释: 需要替换的URI 约束限制: 匹配方式为“所有文件”时,不支持配置参数 取值范围:
默认取值: 不涉及 |
target_url |
是 |
String |
参数解释: 替换后的URI 约束限制: 取值范围:
说明:
通配符 * 可通过$n捕获(n=1,2,3...,例如:/newtest/$1/$2.jpg)
默认取值: 不涉及 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
match_type |
是 |
String |
参数解释: URI的匹配方式 约束限制: 不涉及 取值范围:
默认取值: 不涉及 |
match_pattern |
是 |
String |
参数解释: URI的匹配规则 约束限制: match_type为file_extension时:
match_type为file_path时:
说明:
文件名后缀英文字符大、小写代表不同资源
取值范围: 1-512个字符 默认取值: 不涉及 |
priority |
是 |
Integer |
参数解释: 优先级
说明:
数值越大优先级越高
约束限制: 不涉及 取值范围: 1-100 默认取值: 不涉及 |
back_sources |
是 |
Array of backSources objects |
参数解释: 配置客户端请求匹配当前规则时,CDN节点回源访问的源站 约束限制: 每条规则的回源源站数量不超过1个 取值范围: 不涉及 默认取值: 不涉及 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
sources_type |
是 |
String |
参数解释: 源站类型 约束限制: 不涉及 取值范围:
默认取值: 不涉及 |
ip_or_domain |
是 |
String |
参数解释: 源站IP或者域名 约束限制: 不涉及 取值范围: 不涉及 默认取值: 不涉及 |
obs_bucket_type |
否 |
String |
参数解释: OBS桶类型 约束限制: 不涉及 取值范围:
默认取值: public: 公有桶 |
http_port |
否 |
Integer |
参数解释: HTTP端口 约束限制: 不涉及 取值范围: 1-65535 默认取值: 80 |
https_port |
否 |
Integer |
参数解释: HTTPS端口 约束限制: 不涉及 取值范围: 1-65535 默认取值: 443 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
remote_authentication |
是 |
String |
参数解释: 是否开启远程鉴权 约束限制: 不涉及 取值范围:
默认取值: 不涉及 |
remote_auth_rules |
是 |
RemoteAuthRule object |
参数解释: 远程鉴权配置 约束限制: 不涉及 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
auth_server |
是 |
String |
参数解释: 可访问的鉴权服务器地址 约束限制:
取值范围: 不涉及 默认取值: 不涉及 |
request_method |
是 |
String |
参数解释: 鉴权服务器支持的请求方法 约束限制: 不涉及 取值范围:
默认取值: 不涉及 |
file_type_setting |
是 |
String |
参数解释: 参与鉴权的文件类型 约束限制: 不涉及 取值范围:
说明:
文件类型不区分大小写,即:jpg和JPG代表同一种文件类型,多个文件类型用“|”分隔
默认取值: 不涉及 |
specified_file_type |
否 |
String |
参数解释: 参与鉴权的具体文件类型 约束限制:
取值范围:
默认取值: 不涉及 |
reserve_args_setting |
是 |
String |
参数解释: 参加鉴权的参数 约束限制: 不涉及 取值范围:
默认取值: 不涉及 |
reserve_args |
否 |
String |
参数解释: 设置参数 约束限制:
取值范围: 不涉及 默认取值: 不涉及 |
add_custom_args_rules |
否 |
Array of customArgs objects |
参数解释: 设置CDN节点转发用户请求到远程鉴权服务器时需添加的参数 约束限制: 不涉及 取值范围: 不涉及 默认取值: 不涉及 |
reserve_headers_setting |
是 |
String |
参数解释: 设置CDN节点转发用户请求到远程鉴权服务器时需要添加的请求头 约束限制: 不涉及 取值范围:
默认取值: 不涉及 |
add_custom_headers_rules |
否 |
Array of customArgs objects |
参数解释: 请求头鉴权参数 约束限制: 不涉及 取值范围: 不涉及 默认取值: 不涉及 |
auth_success_status |
是 |
String |
参数解释: 设置鉴权成功时远程鉴权服务器返回给CDN节点的状态码 约束限制: 不涉及 取值范围:
默认取值: 不涉及 |
auth_failed_status |
是 |
String |
参数解释: 设置鉴权失败时远程鉴权服务器返回给CDN节点的状态码 约束限制: 不涉及 取值范围:
默认取值: 不涉及 |
response_status |
是 |
String |
参数解释: 设置鉴权失败时CDN节点返回给用户的状态码 约束限制: 不涉及 取值范围:
默认取值: 不涉及 |
timeout |
是 |
Integer |
参数解释: 设置鉴权超时时间,即从CDN转发鉴权请求开始,到CDN节点收到远程鉴权服务器返回的结果的时间 约束限制: 不涉及 取值范围: 0或50-3000,单位:毫秒 默认取值: 不涉及 |
timeout_action |
是 |
String |
参数解释: 设置鉴权超时后,CDN节点如何处理用户请求 约束限制: 不涉及 取值范围:
默认取值: 不涉及 |
reserve_headers |
否 |
String |
参数解释: 要保留的请求头 约束限制:
取值范围: 不涉及 默认取值: 不涉及 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
type |
是 |
String |
参数解释: 参数类型 约束限制: 不涉及 取值范围:
默认取值: 不涉及 |
key |
是 |
String |
参数解释: 参数名 约束限制: 不涉及 取值范围:
默认取值: 不涉及 |
value |
是 |
String |
参数解释: 参数值 约束限制: 不涉及 取值范围:
默认取值: 不涉及 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
status |
是 |
String |
参数解释: 是否开启websocket协议 约束限制: 不涉及 取值范围:
默认取值: 不涉及 |
timeout |
否 |
Integer |
参数解释: 请求建立连接后,会话的保持时间 约束限制: 不涉及 取值范围: 1-300,单位:秒,当status为on时必填 默认取值: 不涉及 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
enable_video_seek |
是 |
Boolean |
参数解释: 视频拖拽开关 约束限制: 当本字段设置为“false”时,查询域名配置接口将不会返回视频拖拽配置信息 取值范围:
默认取值: 不涉及 |
enable_flv_by_time_seek |
否 |
Boolean |
参数解释: flv时间拖拽开关 约束限制: 不涉及 取值范围:
默认取值: 不涉及 |
start_parameter |
否 |
String |
参数解释: 自定义用户请求URL中视频播放的开始参数 约束限制: 不涉及 取值范围:
默认取值: 不涉及 |
end_parameter |
否 |
String |
参数解释: 自定义用户请求URL中视频播放的结束参数 约束限制: 不涉及 取值范围:
默认取值: 不涉及 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
status |
否 |
String |
参数解释: 是否开启请求限速
说明:
约束限制: request_limit_rules字段置空时代表关闭请求限速功能 取值范围: on 默认取值: 不涉及 |
priority |
是 |
Integer |
参数解释: 优先级
说明:
数值越大优先级越高
约束限制: 优先级不能相同 取值范围: 1-100 默认取值: 不涉及 |
match_type |
是 |
String |
参数解释: 匹配类型 约束限制: 不涉及 取值范围:
默认取值: 不涉及 |
match_value |
否 |
String |
参数解释: 匹配类型值 约束限制:
取值范围: 不涉及 默认取值: 不涉及 |
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 |
参数解释: 指明限速的时段 约束限制:
取值范围: 不涉及 默认取值: 0000-2400 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
status |
是 |
String |
参数解释: IP访问限频状态开关 约束限制: 不涉及 取值范围:
默认取值: 不涉及 |
qps |
否 |
Integer |
参数解释: 访问阈值 约束限制: 当开启ip限频时,访问阈值必填 取值范围: 1-100000,单位:次/秒 默认取值: 不涉及 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
status |
是 |
String |
参数解释: HSTS功能状态开关 约束限制: 不涉及 取值范围:
默认取值: 不涉及 |
max_age |
否 |
Integer |
参数解释: 过期时间,即响应头“Strict-Transport-Security”在客户端的缓存时间 约束限制: status参数为on时,必传 取值范围: 0-63072000,单位:秒 默认取值: 不涉及 |
include_subdomains |
否 |
String |
参数解释: 是否包含子域名 约束限制: status参数为on时,必传 取值范围:
默认取值: 不涉及 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
error_code |
是 |
Integer |
参数解释: 重定向的错误码 约束限制: 不涉及 取值范围:
默认取值: 不涉及 |
target_code |
是 |
Integer |
参数解释: 重定向状态码 约束限制: 不涉及 取值范围:
默认取值: 不涉及 |
target_link |
是 |
String |
参数解释: 重定向的目标链接 约束限制: 必须以http://或https://开头 取值范围: 不涉及 默认取值: 不涉及 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
status |
是 |
String |
参数解释: 是否开启回源SNI 约束限制: 不涉及 取值范围:
默认取值: 不涉及 |
server_name |
否 |
String |
参数解释: CDN节点回源时使用HTTPS协议握手的sni域名 约束限制:
取值范围:
默认取值: |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
condition |
是 |
UrlRewriteCondition object |
参数解释: 匹配条件 约束限制: 不涉及 取值范围: 不涉及 默认取值: 不涉及 |
redirect_status_code |
否 |
Integer |
参数解释: 重定向状态码 约束限制: 不涉及 取值范围:
默认取值: 不涉及 |
redirect_url |
是 |
String |
参数解释: 重定向URL 约束限制:
取值范围: 不涉及 默认取值: 不涉及 |
redirect_host |
否 |
String |
参数解释: 支持将客户端请求重定向到其他域名 约束限制: 不涉及 取值范围:
默认取值: 不填时默认为当前域名 |
execution_mode |
是 |
String |
参数解释: 执行规则 约束限制: 不涉及 取值范围:
默认取值: 不涉及 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
match_type |
是 |
String |
参数解释: 匹配类型 约束限制: 不涉及 取值范围:
默认取值: 不涉及 |
match_value |
是 |
String |
参数解释: 匹配内容 约束限制:
取值范围: 不涉及 默认取值: 不涉及 |
priority |
是 |
Integer |
参数解释: 访问URL重写规则的优先级
说明:
数值越大优先级越高
约束限制: 不支持多条规则设置同一优先级 取值范围: 1-100 默认取值: 不涉及 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
condition |
是 |
BrowserCacheRulesCondition object |
参数解释: 匹配条件 约束限制: 不涉及 取值范围: 不涉及 默认取值: 不涉及 |
cache_type |
是 |
String |
参数解释: 缓存生效类型 约束限制: 不涉及 取值范围:
默认取值: 不涉及 |
ttl |
否 |
Integer |
参数解释: 缓存过期时间 约束限制:
取值范围: 不涉及 默认取值: 不涉及 |
ttl_unit |
否 |
String |
参数解释: 缓存过期时间单位 约束限制: 当缓存生效类型为ttl时必填 取值范围:
默认取值: 不涉及 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
match_type |
是 |
String |
参数解释: 匹配类型 约束限制: 不涉及 取值范围:
默认取值: 不涉及 |
match_value |
否 |
String |
参数解释: 缓存匹配设置 约束限制:
取值范围: 不涉及 默认取值: 不涉及 |
priority |
是 |
Integer |
参数解释: 浏览器缓存的优先级, 数值越大优先级越高 约束限制: 不支持多条规则设置同一优先级 取值范围: 不涉及 默认取值: 1-100 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
type |
是 |
String |
参数解释: 规则类型 约束限制: 不涉及 取值范围:
默认取值: 不涉及 |
content_type |
是 |
String |
参数解释: 生效类型 约束限制: 不涉及 取值范围:
默认取值: 不涉及 |
content_value |
否 |
String |
参数解释: 生效规则 约束限制:
取值范围: 不涉及 默认取值: 不涉及 |
area |
是 |
String |
参数解释: 配置规则适用的区域 约束限制:
取值范围: 不涉及 默认取值: 不涉及 |
exception_ip |
否 |
String |
参数解释: 例外IP,配置指定IP不执行当前规则 约束限制: 不涉及 取值范围: 不涉及 默认取值: 不涉及 |
响应参数
状态码: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 |
请求成功。 |
错误码
请参见错误码。