The match operators in a rule include comparison operators and logical operators. You can use more than 10 types of comparison operators and logical operators between rules to build a variety of rule expressions.
Comparison operators
Comparison operators are used to compare the input values in a request with the values configured in an expression.
eq
Indicates that the input value in a request is equal to the match value.
Operator name:
equal toMatch value type:
StringExample:
(http.host eq "www.example.com")
ne
Indicates that the input value in a request is not equal to the match value.
Operator name:
not equal toMatch value type:
StringExample:
(http.host ne "www.example.com")
contains
Indicates that the input value in a request contains a specific string.
Operator name:
containsMatch value type:
StringExample:
(http.host contains "example.com")
not...contains
Indicates that the input value in a request does not contain a specific string.
Operator name:
does not containMatch value type:
StringExample:
(not http.host contains "example.com")
matches
Indicates that the input value in a request complies with a specific regular expression. Compatible with Perl Compatible Regular Expressions (PCRE).
Only Premium and Enterprise plans support regular expressions.
Operator name:
matches the specified regular expressionMatch value type:
StringExample:
(http.host matches "(www|blog)\.example\.com")
not...matches
Indicates that the input value in a request does not comply with a specific regular expression. Compatible with PCRE.
Only Premium and Enterprise plans support regular expressions.
Operator name:
does not match the specified regular expressionMatch value type:
StringExample:
(not http.host matches "(www|blog)\.example\.com")
in
Indicates that the input values in a request contain one or more preset match values. You can also use $ together to implement grouping.
Operator name:
contains one of the following itemsMatch value type:
ArrayExample:
(http.host in {"www.example-1.com" "www.example-2.com"})( ip.src in $<LIST_NAME>)
not...in
Indicates that the input values in a request do not contain all preset match values. You can also use $ together to implement grouping.
Operator name:
does not contain any of the following itemsMatch value type:
ArrayExample:
(not http.host in {"www.example-1.com" "www.example-2.com"})(not ip.src in $<LIST_NAME>)
starts_with
Indicates that the start of the input value in a request matches the preset match value.
Operator name:
starts withMatch value type:
StringExample:
(starts_with(http.host, "blog"))
not starts_with
Indicates that the start of the input value in a request does not match the preset match value.
Operator name:
does not start withMatch value type:
StringExample:
(not starts_with(http.host, "blog"))
ends_with
Indicates that the end of the input value in a request matches the preset match value.
Operator name:
ends withMatch value type:
StringExample:
(ends_with(http.host, "cn"))
not ends_with
Indicates that the end of the input value in a request does not match the preset match value.
Operator name:
does not end withMatch value type:
StringExample:
(not ends_with(http.host, "cn"))
le
Indicates that the input value in a request is less than or equal to the preset match value.
Operator name:
less than or equal toMatch value type: int
Example:
(ip.geoip.asnum le 45104)
ge
Indicates that the input value in a request is greater than or equal to the preset match value.
Operator name:
greater than or equal toMatch value type:
intExample:
(ip.geoip.asnum ge 45104)
lt
Indicates that the input value in a request is less than the preset match value.
Operator name:
less thanMatch value type:
intExample:
(ip.geoip.asnum lt 45104)
gt
Indicates that the input value in a request is greater than the preset match value.
Operator name:
greater thanMatch value type:
intExample:
(ip.geoip.asnum gt 45104)
len eq
Indicates that the length of the input value in a request is equal to the preset match value.
Operator name:
length equal toMatch value type:
StringExample:
(len(http.request.cookies["session"]) eq 330688)
len gt
Indicates that the length of the input value in a request is greater than the preset match value.
Operator name:
length greater thanMatch value type:
StringExample:
(len(http.request.cookies["session"]) gt 330688)
len lt
Indicates that the length of the input value in a request is less than the preset match value.
Operator name:
length less thanMatch value type:
StringExample:
(len(http.request.cookies["session"]) lt 330688)
exists
Checks that a preset value exists in a request.
Operator name:
existsMatch value type:
StringExample:
(exists(http.request.headers["user-agent"]))
not exists
Checks that a preset value does not exist in a request.
Operator name:
does not existMatch value type:
StringExample:
(not exists(http.request.headers["user-agent"]))
Other operators
lower
Converts letters of the input value in a request to lowercase letters if the request value is case-insensitive.
Operator name:
case-insensitiveMatch value type:
StringExample:
(lower(http.request.uri))
Logical operators
Logical operators are used to combine multiple expressions into a compound expression.
not
Executes the logical NOT operator on an expression.
Operator name:
logical NOTExample:
not (http.host )
and
Indicates that the request must satisfy two or more expressions.
Operator name:
logical ANDExample:
(http.host eq "www.example.com" and ip.geoip.country eq "CN")
or
Indicates that the request only needs to satisfy one of the preset expressions.
Operator name:
logical ORExample:
(http.host eq "www.example.com") or (ip.geoip.country eq "CN")