添加单条

请求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