haproxy acl 语法解释

使用ACL过程分析

  提取- extract a data sample from a stream, table or the environment
  转换- optionally apply some format conversion to the extracted sample
  匹配- apply one or multiple pattern matching methods on this sample
  动作- perform actions only when a pattern matches the sample


The action of extracting such data is called fetching a sample(采样).

Matching them against predefined constant data called patterns(模式).


http-request { allow | deny | tarpit | auth [realm <realm>] | redirect <rule> |
              add-header <name> <fmt> | set-header <name> <fmt> |
              del-header <name> | set-nice <nice> | set-log-level <level> |
              replace-header <name> <match-regex> <replace-fmt> |
              replace-value <name> <match-regex> <replace-fmt> |
              set-tos <tos> | set-mark <mark> |
              add-acl(<file name>) <key fmt> |
              del-acl(<file name>) <key fmt> |
              del-map(<file name>) <key fmt> |
              set-map(<file name>) <key fmt> <value fmt>
             }

             [ { if | unless } <condition> ]


提取、转换、匹配==[ { if | unless } <condition> ]

动作==http-request {allow|deny……}

ACL语法

acl <aclname>             <criterion> [flags]                  [operator] [<value>] ...


criterion系正式用语, 指"判断某人、某事的真善美程度或价值的标准"

The criterion generally is the name of a sample fetch method。

Sample fetch methods were only used to retrieve data to match against patterns using ACLs.

The sample fetch methods are the only ones supporting a conversion.

Apply to the portion of request/response specified in <criterion> and may beadjusted with optional flags[flags]. 

Some criteria also support an operatorwhich may be specified before the set of values.

Optionally some conversion operators may be applied to the sample.

The values are of the type supported by the criterion, and are separated by spaces.

operator用逗号分隔;value用空格分隔.



Sample fetch methods return data which can be of the following types :
  - boolean
  - integer (signed or unsigned)
  - IPv4 or IPv6 address
  - string

  - data block


The following ACL flags are currently supported :

   -i : ignore case during matching of all subsequent patterns.
   -f : load patterns from a file.
   -m : use a specific pattern matching method
   -n : forbid the DNS resolutions
   -M : load the file pointed by -f like a map file.
   -u : force the unique id of the ACL
   -- : force end of flags. Useful when a string looks like one of the flags.


使用ACL形成condition

  - AND (implicit)
  - OR  (explicit with the "or" keyword or the "||" operator)
  - Negation with the exclamation mark ("!")

A condition is formed as a disjunctive form:

   [!]acl1 [!]acl2 ... [!]acln  { or [!]acl1 [!]acl2 ... [!]acln } ...

举例

   With named ACLs :

        acl site_dead nbsrv(dynamic) lt 2
        acl site_dead nbsrv(static)  lt 2
        monitor fail  if site_dead

   With anonymous ACLs :

        monitor fail if { nbsrv(dynamic) lt 2 } || { nbsrv(static) lt 2 }

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值