页面规则

在一个 YAML 配置文件中,您可以定义多个页面规则。

参数说明

参数名数据类型是否必选说明
enable_rulebool规则的启用状态(启用或禁用)
conditionsarray规则生效的前置条件集合
actionsdict规则触发后的动作
wafdictWeb 应用防火墙(WAF)配置
cachedict缓存相关配置
lastbool是否在当前规则匹配后停止处理后续规则

更多参数的详细说明和使用示例,请参考以下文档:

配置示例

- enable_rule: true

  conditions:
  - var: uri
    op: eq
    vals:
      - /hello

  waf:
    rule_sets:
      - scanner_detection
      - protocol_enforcement
      - application_attack_xss
      - application_attack_sqli
    sensitivity: medium
    action: "403 Forbidden"
    cross_requests: false

  actions:
    set-proxy-uri:
      uri: /hello/world

  cache:
    cache_key:
      - name: req-header
        args: customid
      - name: 'query-string'
    enforce_cache: true
    default_ttls:
      - ttl_unit: min
        status: 200
        ttl: 300

在此示例中,当 URI 等于 /hello 时,将触发规则:启动 WAF 规则集,设置上游服务器为 hello-backend,并施行缓存策略。缓存的键由请求头中的 customid 和查询字符串组成,缓存的默认生存时间(TTL)设置为 300 分钟。