Condition Operators
Operators define how a variable is compared against a value. Based on their applicable scenarios, operators are categorized as follows:
Numeric Operators
Used for numeric comparisons. Applicable to numeric variables such as port numbers, status codes, lengths, and counts.
Number = (
==): Numeric equal. Checks whether the variable’s numeric value equals the specified value.Number ≠ (
!=): Numeric not equal. Checks whether the variable’s numeric value does not equal the specified value.Number < (
<): Numeric less than. Checks whether the variable’s numeric value is less than the specified value.Number ≤ (
<=): Numeric less than or equal. Checks whether the variable’s numeric value is less than or equal to the specified value.Number > (
>): Numeric greater than. Checks whether the variable’s numeric value is greater than the specified value.Number ≥ (
>=): Numeric greater than or equal. Checks whether the variable’s numeric value is greater than or equal to the specified value.
String Operators
Used for string comparisons. Applicable to string variables such as URI, Host, request headers, and cookies.
String = (
eq): String equal. Checks whether the variable’s string value is exactly the same as the specified value. Supports regular expression (rx) and wildcard (wc) pattern matching.String ≠ (
ne): String not equal. Checks whether the variable’s string value differs from the specified value. Supports regular expression and wildcard pattern matching.String < (
lt): String less than. Compares lexicographically and checks whether the variable’s value is less than the specified value.String ≤ (
le): String less than or equal. Compares lexicographically.String > (
gt): String greater than. Compares lexicographically and checks whether the variable’s value is greater than the specified value.String ≥ (
ge): String greater than or equal. Compares lexicographically.Contains (
contains): Checks whether the variable’s value contains the specified substring. Supports regular expression and wildcard pattern matching.Not contains (
!contains): Checks whether the variable’s value does not contain the specified substring. Supports regular expression and wildcard pattern matching.Contains word (
contains-word): Checks whether the variable’s value contains the specified complete word (delimited by word boundaries).Not contains word (
!contains-word): Checks whether the variable’s value does not contain the specified complete word.Prefix matches (
prefix): Checks whether the variable’s value starts with the specified string. Supports regular expression and wildcard pattern matching.Prefix not matches (
!prefix): Checks whether the variable’s value does not start with the specified string. Supports regular expression and wildcard pattern matching.Suffix matches (
suffix): Checks whether the variable’s value ends with the specified string. Supports regular expression and wildcard pattern matching.Suffix not matches (
!suffix): Checks whether the variable’s value does not end with the specified string. Supports regular expression and wildcard pattern matching.
String Length Operators
Used for numeric comparisons on the string length of a variable’s value. Applicable to string variables.
String length = (
str-len-eq): Checks whether the length of the variable’s value equals the specified number.String length ≠ (
str-len-ne): Checks whether the length of the variable’s value does not equal the specified number.String length < (
str-len-lt): Checks whether the length of the variable’s value is less than the specified number.String length ≤ (
str-len-le): Checks whether the length of the variable’s value is less than or equal to the specified number.String length > (
str-len-gt): Checks whether the length of the variable’s value is greater than the specified number.String length ≥ (
str-len-ge): Checks whether the length of the variable’s value is greater than or equal to the specified number.
IP Operators
Used for IP address and CIDR range matching. Applicable to variables such as client address, server address, and X-Forwarded-For addresses.
IP address or CIDR match (
~~): Checks whether the IP address in the variable falls within the specified network range. Values should be in CIDR notation, such as192.168.0.1/24or::1/24.IP address or CIDR NOT match (
!~~): Checks whether the IP address in the variable does not fall within the specified network range.
Boolean Operators
Used for boolean value checks. Applicable to boolean variables such as ua-is-mobile, duplicate-req-header, and req-rejected. These operators do not require a right-hand side value.
Is True (
is-true): Checks whether the variable’s value is true.Is False (
!is-true): Checks whether the variable’s value is false.
Empty Operators
Used to check whether a variable has a value. Applicable to variables that may not exist, such as request headers, cookies, and parameters. These operators do not require a right-hand side value.
Is Empty (
is-empty): Checks whether the variable’s value is empty (undefined or an empty string).Not Empty (
!is-empty): Checks whether the variable’s value is not empty.
Date/Time Operators
Used for time range checks. Only applicable to the Time (date) variable.
Within the time interval (
within-date): Checks whether the current time falls within the specified time range. Requires settingstart_timeandend_time.Not within the time interval (
!within-date): Checks whether the current time does not fall within the specified time range.Within the time period (
within-period): Checks whether the current time falls within the specified recurring time period. In addition to start and end times, you can also setweekdays, where 1 represents Monday and 7 represents Sunday. Suitable for recurring rules such as “Monday through Friday, 9:00 AM to 6:00 PM”.Not within the time period (
!within-period): Checks whether the current time does not fall within the specified recurring time period.