You need to enable JavaScript to run this app.
导航

CreateCCRule-创建 CC 防护规则

最近更新时间2024.03.01 16:47:37

首次发布时间2023.11.10 18:24:47

创建 CC 防护规则,可根据网络访问 IP、Session 等各种 HTTP 请求对象进行请求限制,当满足设定的统计条件后,对其访问执行防护动作,以防止服务器资源被过度占用,确保正常访问业务不受影响。

请求说明

  • 请求方式:POST
  • 请求地址:https://open.volcengineapi.com/?Action=CreateCCRule&Version=2020-12-09

请求参数

参数

类型

是否必填

示例值

描述

Name

String

123

规则名称,支持英文、汉字和数字,不支持特殊字符。长度限制在 20 个字符内。

Url

String

/test/*

请求路径,支持通配符**仅可出现一次。

AdvancedEnable

Boolean

true

是否启用高级条件。

  • true:启用。
  • false:不启用。

Field

String

CLIENTIP

统计对象,多个对象用逗号分隔。格式为类型:对应值

  • 自定义 Header。格式为HEADER:具体参数,例如HEADER:Authorization
  • 自定义 Cookie。格式为COOKIE:具体参数,例如COOKIE:PHPSESSId
  • 自定义参数。格式为ARGS:具体参数,例如ARGS:device_Id
  • 源 IP。直接配置为CLIENTIP

SingleThreshold

Integer

10

每个统计对象访问的次数阈值。取值范围 1~300,000。

PathThreshold

Integer

100

请求路径访问的次数阈值。取值范围 1~300,000。

CountTime

Integer

60

统计时长,单位:秒。取值范围 1~1,800。

CCType

Integer

0

执行动作。

  • 0:观察
  • 1:限速
  • 2:拦截
  • 7:人机验证

EffectTime

Integer

100

统计时长,单位:秒。取值范围 1~86,400。

说明

执行动作为“观察”时无需填写。

RulePriority

Integer

0

规则执行优先级,数字越大优先级越低。

  • 0:P0
  • 1:P1
  • 2:P2
  • 3:P3
  • 4:P4
  • 5:P5
  • 6:P6
  • 7:P7
  • 8:P8
  • 9:P9

Enable

Enum

1

是否启用规则。

  • 0:不启用
  • 1:启用

AccurateGroup

AccurateGroupobject

-

高级条件配置,未开启高级条件时无需配置此字段。

Host

String

example.volcwaf001.com

需要设置防护规则的网站域名。

AccurateGroup

参数

类型

是否必填

示例值

描述

AccurateRules

Array of AccurateRules objects

-

规则详情。

Logic

Integer

1

规则间的运算关系。

  • 1:与
  • 2:或

AccurateRules

参数

类型

是否必填

示例值

描述

HttpObj

String

request.method

自定义对象,与ObjType存在映射关系。

  • 请求协议:request.schema
  • 请求 uri:request.uri
  • 请求方法:request.method
  • 请求路径:request.path
  • 请求参数:request.queryargs
  • 请求头:request.header
  • 请求 User-Agent:request.header.ua
  • 请求 refer:request.header.refer
  • 请求 Cookies:request.header.cookies
  • 请求体长度:request.header.content-length
  • 请求体格式:request.header.content-type
  • X-forwarded-for:request.header.x-forwarded-for
  • 客户端 IP:request.header.clientip
  • 自定义 Args:request.queryargs.自定义参数名称。例如request.queryargs.abc
  • 自定义 header:request.header.自定义Header 名称。例如request.header.abc
  • 自定义 cookie:request.cookie.自定义 cookie 名称。例如request.cookie.abc

ObjType

Integer

0

匹配字段。

  • 0:请求协议
  • 1:请求 uri
  • 2:请求方法
  • 3:请求路径
  • 4:请求参数
  • 5:请求头
  • 6:请求 User-Agent
  • 7:请求 refer
  • 8:请求 Cookies
  • 9:请求体长度
  • 10:请求体格式
  • 11:X-forwarded-for
  • 12:客户端 IP
  • 13:自定义 Args
  • 14:自定义 header
  • 15:自定义 cookie

Opretar

Integer

0

逻辑运算符。

  • 0:大于
  • 1:大于等于
  • 2:等于
  • 3:小于
  • 4:小于等于
  • 5:不等于
  • 6:包含子串
  • 7:不包含子串
  • 8:包含前缀
  • 9:不包含前缀
  • 10:包含后缀
  • 11:不包含后缀
  • 12:包含所有匹配集合
  • 13:不包含所有匹配集合
  • 14:属于匹配集合
  • 15:不属于匹配集合
  • 16:正则
  • 17:判断为 IP
  • 18:判断为 IPv4
  • 19:判断为 IPv6
  • 20:判断为私网 IP
  • 21:判断为公网 IP

Property

Integer

0

固定取值为 0,取HttpObj的值用于匹配对应详情。

ValueString

string

123

匹配内容。
逻辑关系判断为 IP、 IPv4、 IPv6、私网 IP 或公网 IP 时不需要填写。

返回参数

参数

类型

示例值

描述

Id

String

144565

创建的规则 ID。

请求示例

POST https://open.volcengineapi.com/?Action=CreateCCRule&Version=2020-12-09
X-Date: 20230711T035055Z
Authorization: HMAC-SHA256 Credential=AKLTNGU0OGEyMT***/20230711/cn-beijing/waf/request, SignedHeaders=content-type;x-content-sha256;x-date, Signature=da4fac562d00f41ad8***

{
  "Name": "123",
  "Url": "/test.html",
  "AdvancedEnable": true,
  "Field": "CLIENTIP",
  "SingleThreshold": 10,
  "PathThreshold": 100,
  "CountTime": 60,
  "CCType": 1,
  "RulePriority": 0,
  "Enable": 1,
  "AccurateGroup": {
    "Logic": 1,
    "AccurateRules": [
      {
        "Property": 0,
        "HttpObj": "request.schema",
        "ObjType": 0,
        "Opretar": 2,
        "ValueString": "HTTP"
      }
    ]
  },
  "EffectTime": 60,
  "Host": "example.volcwaf001.com"
}

返回示例

{
    "ResponseMetadata": {
        "RequestId": "202310091729184CEFD57F221FFCBF****",
        "Action": "CreateCCRule",
        "Version": "2020-12-09",
        "Service": "waf",
        "Region": "cn-beijing"
    },
    "Result": {
        "Id": 144565
    }
}