添加单条
请求URL
{{url}}/api/site/create
请求方式
post
Header
x-api-key
{{x-api-key}}
是
string
无
x-api-secret
{{x-api-secret}}
是
string
无
请求参数示例
{
"user_package": "5",
"domain": "abcde.com",
"http_listen": {
"port": "80"
},
"backend": [
{
"addr": "127.0.0.1",
"weight": 1,
"state": "up"
}
],
"backend_http_port": "80",
"backend_protocol": "follow",
"backend_https_port": "443",
"proxy_timeout": "",
"backend_port_mapping": false,
"health_check": {
"enable": 1,
"protocol": "http",
"host": "www.qq.com",
"path": "/",
"status_code": "200 301 302",
"interval": 5
},
"ups_keepalive": false,
"ups_keepalive_conn": 0,
"ups_keepalive_timeout": 10,
"proxy_http_version": 1.1,
"proxy_ssl_protocols": "TLSv1",
"backend_host": "www.baidu.com",
"range": false,
"proxy_cache": [
{
"type": "dir",
"content": "/static/",
"expire": "1",
"unit": "d",
"ignore_arg": false,
"proxy_ignore_headers": "",
"no_cache": [
{
"variable": "$uri",
"string": "/api/"
}
]
}
],
"cc_default_rule": 0,
"cc_switch": {
"rule": "1",
"switch": "10",
"enable": 1
},
"extra_cc_rule": [
{
"filter": {
"within_second": 10,
"extra": {},
"type": "req_rate",
"max_per_uri": 1,
"max_challenge": 1
},
"matcher": {
"ip": {
"operator": "=",
"value": "111"
}
}
}
],
"block_region": "id",
"black_ip": "",
"white_ip": "",
"acl": "",
"hotlink": {
"enable": 1,
"domain": "",
"allow_empty": 1
},
"cors": {
"enable": 1,
"allow_origin": "*",
"allow_methods": "GET POST",
"allow_headers": "DNT Keep-Alive User-Agent X-Requested-With If-Modified-Since Cache-Control Content-Type",
"expose_headers": "Content-Length Content-Range",
"allow_credentials": 1,
"max_age": 1728000
},
"resp_header": [
{
"name": "aaa",
"value": "bbb"
}
],
"req_header": [
{
"name": "aaa",
"value": "bbb"
}
],
"page_404": "",
"page_50x": "",
"url_rewrite": [
{
"host": "qq.com",
"match": "(.*)",
"redirect": "http://baidu.com$1",
"code": "301"
}
],
"gzip_enable": false,
"gzip_types": "text/plain",
"websocket_enable": false,
"acme_proxy_to_orgin": false,
"post_size_limit": 10,
"recv_real_time": false,
"send_real_time": false,
"spider_to_sip": "",
"groups": "",
"enable": false
}
请求json字段说明
user_package
否
String
已购套餐ID
domain
否
String
绑定的域名,支持通配符域名,多个域名空格分隔
http_listen
否
Object
无
http_listen.port
否
String
监听端口
https_listen
否
Object
HTTPS设置
https_listen.port
否
String
无
https_listen.cert
否
String
无
https_listen.hsts
否
Integer
无
https_listen.ocsp_stapling
否
Integer
无
https_listen.ssl_protocols
否
String
无
https_listen.ssl_ciphers
否
String
无
https_listen.ssl_prefer_server_ciphers
否
String
无
https_listen.force_ssl_enable
否
Integer
无
https_listen.force_ssl_port
否
String
无
balance_way
否
String
源服务器负载均衡方式,可选值为ip_hash、rr、url_hash、least_conn、random。ip_hash为根据客户端IP定源,rr是轮循,url_hash是根据url定源,least_conn是取最少连接的源,random是随机分配
backend
否
Array
指定源IP,格式为数组
backend.addr
否
String
源IP
backend.weight
否
Integer
权重
backend.state
否
String
state为状态,默认为up,可选值为down,up,backup
backend_http_port
否
String
当回源协议为http时,回源使用的端口
backend_protocol
否
String
回源协议,可选值为follow、http、https。
backend_https_port
否
String
当回源协议为https时,回源使用的端口
proxy_timeout
否
String
回源超时时间
backend_port_mapping
否
Boolean
回源端口映射,表示回源的协议和端口与访问的协议的端口一致。
health_check
否
Object
源站健康检查
health_check.enable
否
Integer
无
health_check.protocol
否
String
无
health_check.host
否
String
无
health_check.path
否
String
无
health_check.status_code
否
String
无
health_check.interval
否
Integer
无
ups_keepalive
否
Boolean
回源keepalive
ups_keepalive_conn
否
Integer
keepalive的连接数
ups_keepalive_timeout
否
Integer
keepalive超时时间
proxy_http_version
否
Number
回源的http协议版本,可选1.1,1.0
proxy_ssl_protocols
否
String
回源SSL协议,可选TLSv1 TLSv1.1 TLSv1.2
backend_host
否
String
回源的Host值,可选$host、$host:$server_port和自定义
range
否
Boolean
分断取源,一次取1MB
proxy_cache
否
Array
缓存设置,数据格式为数组
proxy_cache.type
否
String
type可选为suffix、dir、full_path,分别是后缀,目录,全路径
proxy_cache.content
否
String
无
proxy_cache.expire
否
String
无
proxy_cache.unit
否
String
unit可选为d、h、m、s,分别为天,小时,分钟,秒。ignore_arg表示忽略参数
proxy_cache.ignore_arg
否
Boolean
表示忽略参数
proxy_cache.proxy_ignore_headers
否
String
当proxy_ignore_headers值为X-Accel-Expires Expires Cache-Control Set-Cookie时,表示强制缓存
proxy_cache.no_cache
否
Array
no_cache表示排除符合条件的缓存
proxy_cache.no_cache.variable
否
String
表示uri匹配/api/的url不缓存。variable为变量,可选为$args、$content_type、$content_length、$host、$https、$is_args、$query_string、$remote_addr、$request_method、$request_uri、$scheme、$status、$uri,以及$arg_x,$cookie_x,$http_x,其中$arg_x为获取参数值,x为参数名;$cookie_x为cookie值,x为cookie名称;$http_x为请求头值,x为请求头名称
proxy_cache.no_cache.string
否
String
无
cc_default_rule
否
Integer
默认的防御规则组
cc_switch
否
Object
无
cc_switch.rule
否
String
规则组ID
cc_switch.switch
否
String
网站QPS超过时切换
cc_switch.enable
否
Integer
是否启用
extra_cc_rule
否
Array
无
extra_cc_rule.filter
否
Object
无
extra_cc_rule.filter.within_second
否
Integer
无
extra_cc_rule.filter.extra
否
Object
无
extra_cc_rule.filter.type
否
String
无
extra_cc_rule.filter.max_per_uri
否
Integer
无
extra_cc_rule.filter.max_challenge
否
Integer
无
extra_cc_rule.matcher
否
Object
无
extra_cc_rule.matcher.ip
否
Object
无
extra_cc_rule.matcher.ip.operator
否
String
无
extra_cc_rule.matcher.ip.value
否
String
无
block_region
否
String
屏蔽区域,可选值两字母的国家代码
black_ip
否
String
黑名单IP,一行一个,支持子掩码/8 /16 /24,如192.168.0.0/8、192.168.0.0/16、192.168.0.0/24.
white_ip
否
String
白名单IP,一行一个,支持子掩码/8 /16 /24,如192.168.0.0/8、192.168.0.0/16、192.168.0.0/24.
acl
否
String
指定ACL ID
hotlink
否
Object
无
hotlink.enable
否
Integer
可选值为0或1
hotlink.domain
否
String
为空时,只允许当前添加的域名,可填写额外的域名
hotlink.allow_empty
否
Integer
可选值为0或1,表示是否允许空来源访问
cors
否
Object
设置跨站支持
cors.enable
否
Integer
无
cors.allow_origin
否
String
无
cors.allow_methods
否
String
无
cors.allow_headers
否
String
无
cors.expose_headers
否
String
无
cors.allow_credentials
否
Integer
无
cors.max_age
否
Integer
无
resp_header
否
Array
设置响应头
resp_header.name
否
String
无
resp_header.value
否
String
无
req_header
否
Array
设置请求头
req_header.name
否
String
无
req_header.value
否
String
无
page_404
否
String
自定义404错误页面
page_50x
否
String
自定义50x错误页面,包括500 502 503 504
url_rewrite
否
Array
url重定向,表示taobao.com重定向到baidu.com
url_rewrite.host
否
String
无
url_rewrite.match
否
String
无
url_rewrite.redirect
否
String
无
url_rewrite.code
否
String
无
gzip_enable
否
Boolean
gzip开启
gzip_types
否
String
gzip的content type,如text/plain text/css text/xml text/javascript application/javascript application/x-javascript application/json
websocket_enable
否
Boolean
websocket开启
acme_proxy_to_orgin
否
Boolean
当为1时,/.well-known/acme-challenge/的请求回源。
post_size_limit
否
Integer
上传文件最大大小,单位为MB
recv_real_time
否
Boolean
数据实时返回,0为关闭,1为开启
send_real_time
否
Boolean
数据实时发送,0为关闭,1为开启
spider_to_sip
否
String
指定搜索引擎回源的IP地址,当需要关闭此功能时,可设置此值为空
groups
否
String
指定所属的网站组,多个以逗号分隔
enable
否
Boolean
网站启用或禁用
成功返回示例
{
"code": 0,
"data": null,
"msg": "网站添加成功"
}
失败返回示例
{
"code": -1,
"data": null,
"msg": "证书不存在"
}
Last updated