预部署域名内部重定向配置

更新时间:2022-12-05 14:47:28

适用产品

应用安全加速解决方案、IPv6一体化解决方案、电商安全加速解决方案、金融安全加速解决方案、政企安全加速解决方案、应用安全解决方案、区块链安全加速解决方案、IPv6安全加速解决方案、点播分发、直播分发、移动加速、网页加速、下载分发、全站加速

接口描述

查看内部重定向配置

  • 调用URL: https://open.chinanetcenter.com/api/predeploy/InnerRedirect/*
  • 调用方法:PUT
  • 限制说明:· 加速域名必须已备案完成。 · 加速域名必须不包含如下信息:出售药物和管制刀具类,含有不法言论、信息。 · 视频类加速域名必须有视听许可证;博客论坛或社区类加速域名必须有BBS专项审批资质。 · 接口请求和返回结果接受xml和json格式。
推荐使用 Open API在线调试

Open API在线调试功能提供可视化界面在线调试API、支持生成代码示例、快速检索查看API文档等能力。前往调试

请求参数

Path 参数

参数名称描述
*domain-nameString
需要查询配置的域名或域名id

Body 参数

参数名称描述
*rewrite-rule-settingsList
一级服务改写替换—二级服务 内部重定向 注意: 1. 定义一组内部重定向内容,,如果有使用内部重定向内容,此项必填 2. 需要清空域名下的内容重定向内容,可以传入空节点 3. 如果有开启其他高级配置(如防盗链配置),有些配置可能会有配置冲突,建议先与技术支持人员确认
data-idLong
添加grid类型标识,表示客户多组配置时,具体某组配置;data-id重复,已入参同个id最后一组为准生效 data-id可以通过查询接口获取。 注意:添加grid类型标识:data-id,每一组配置对应一个data-id: a、如果客户有传data-id,说明指定修改其中一组配置项内容,不需求修改其他组配置内容不需要入参; b、如果客户入参多组配置,其中有些组配置有传data-id,有些没有传,则有传data-id的表示修改具体某组配置,没有传data-id的表示在原来基础上新增一组配置; c、如果客户入参都没有传data-id,表示用本次的配置全量覆盖原先配置; d、如果客户入参没有传任何配置项参数,只传了域名和二级标签,表示清空这个接口对应域名二级服务所有配置。(c、d内容和当前方案实现一致); e、一个gird标签下的入参不能为空,如果,没有具体的配置项,则data-id必填,且值为实际存在的data-id,表示清空这个data-id对应配置项的值;
*path-patternString
url匹配模式,支持正则,客户入参参考:.* 对于匹配到的URL进行内容重定向
except-path-patternString
例外的url匹配模式,某些URL除外:如abc.jpg,不做内容重定向 客户入参参考:^https?://[^/]+/.*\.m3u8
custom-patternString
匹配条件:指定常用类型,可选值为all或homepage 1、all:全部文件 2、homepage:首页
directoryString
目录
file-typeString
匹配条件:文件类型,多个请以英文;分隔,可选值:gif png bmp jpeg jpg html htm shtml mp3 wma flv mp4 wmv zip exe rar css txt ico js swf m3u8 xml f4m bootstarp ts
custom-file-typeString
匹配条件:自定义文件类型,多个请以英文;分隔。
ignore-letter-caseString
忽略大小写,可选值为true或false,true表示忽略大小写;false表示不忽略大小写; 新增配置项时,不传默认为 true 如果客户传了空值:如,则表示清空配置
*publish-typeString
改写内容的生成位置。可输入值为:Cache表示节点; 暂不支持其他入参格式
priorityString
表示客户多组重定向内容的优先执行顺序。数字越大,优先级越高。 新增配置项时,不传默认为 10
*before-valueString
配置项:旧url 表示改写前的协议方式(即需要改写的对象),如:^https://([^/]+/.*) 如果是回源协议改写,则表示客户请求的原始url,配套的参数after-value,表示客户请求需要转换的回源请求。
*after-valueString
配置项:新url 表示改写后的协议方式,如:http://$1 如果请求重定向带状态码则参考入参:301:https://$1 注:如果url含域名,则域名需要是本身。
*rewrite-typeString
重定向类型;支持入参: before:防盗链之前 after:防盗链之后
request-headerString
exception-request-headerString
specify-urlPredeployredirectconfigRequestRewriteRuleSettingsSpecifyUrl
uriString
match-query-stringString
query-stringsString
protocolString

返回参数

Body 参数

参数名称描述
preDeployIdString
预部署任务的id,可以根据这个id查询预部署的进展和结果

错误码

错误代码(code)描述(message)HTTP状态码语义
InvalidParameterThe url-pattern can't be empty.400url-pattern不能为空
InvalidParameterThe publish-type can't be empty.400publish-type不能为空
InvalidParameterThe before-value can't be empty.400before-value值不能为空
InvalidParameterThe after-value can't be empty.400after-value值不能为空
InvalidParameterThe rewrite-type can't be empty.400rewrite-type值不能为空
InvalidParameterNo rewrite-rule-settings was specified.400未指定重写规则
InvalidParameterNo domain was specified.400未指定域名
InvalidParameterThe ignore-letter-case is invalid.400ignore-letter-case无效
InvalidParameterThe publish-type is invalid.400publish-type无效
InvalidParameterThe priority is invalid.400优先级无效
InvalidParameterThe rewrite-type is invalid.400rewrite-type无效
InvalidParameterThe path-pattern is required.400path-pattern无效
InvalidParameterThe publish-type is required.400publish-type无效
InvalidParameterThe before-value is required.400before-value必填
InvalidParameterThe after-value is required.400after-value必填
InvalidParameterThe rewrite-type is required.400rewrite-type必填
InvalidParameterThe request has null config with null data-id, please remove it.400未指定重写规则。请求的配置为空,数据ID为空,请将其删除。
NoSuchDomainThe specified domain does not exist.404指定域名不存在
InternalErrorWe encountered an internal error. Please try again.500遇到内部错误,请重试。
ConfigErrorThe config {0} does not access.400某个配置无法访问
CustomerNoOwnDomaincustomer not own domain name.400不是客户的域名
WrongDataIdWrong data-id.400错误的dataid

示例

JSON
XML
JSON
请求示例
复制代码 复制成功
#!/bin/bash
username="example_username"
apiKey="example_apiKey"
date=`env LANG="en_US.UTF-8" date -u "+%a, %d %b %Y %H:%M:%S GMT"`
password=`echo -en "$date" | openssl dgst -sha1 -hmac $apiKey -binary | openssl enc -base64`
curl -i --url "https://open.chinanetcenter.com/api/predeploy/InnerRedirect/a1.example.com" \
-X "PUT" \
-u "$username:$password" \
-H "Date: $date" \
-H "Accept: application/json" \
-H "Content-Type:application/json" \
-d '{
    "rewrite-rule-settings": [
        {
            "data-id": "31506537", 
            "path-pattern": ".*", 
            "except-path-pattern": "^https?://[^/]+/.*.m3u8", 
            "ignore-letter-case": "true", 
            "publish-type": "Cache", 
            "priority": "10", 
            "before-value": "^http://([^/]+/.*)", 
            "after-value": "https://$1", 
            "rewrite-type": "before"
        }, 
        {
            "path-pattern": ".*", 
            "except-path-pattern": "^https?://[^/]+/.*.m3u8", 
            "ignore-letter-case": "true", 
            "publish-type": "Cache", 
            "priority": "9", 
            "before-value": "http", 
            "after-value": "https", 
            "rewrite-type": "before"
        }
    ]
}'
返回示例
复制代码 复制成功
HTTP/1.1 202 OK 
Server: openresty/1.11.2.2
Date: Thu, 14 Mar 2019 08:09:45 GMT
Content-Type: application/json;charset=utf-8
Content-Length: 31
Connection: keep-alive
App-Name: service_confApi
x-cnc-request-id: 86f908a5-3e45-4be3

{"preDeployId":"66201667e7424820b9e359671178757c"}
本篇文档内容对您是否有帮助?
有帮助
我要反馈
提交成功!非常感谢您的反馈,我们会继续努力做到更好!