Supported fields and operators
Fields
Load Balancing expressions support these fields:
Field | Name in Expression Builder | Description |
---|---|---|
http.request.version Number | HTTP version | The version of the HTTP protocol used. Use this field when you require different checks for different versions. Example Values:
|
ip.src IP address | IP address | The client TCP IP address, which may be adjusted to reflect the actual address of the client by using, for example, HTTP headers such as Example value: |
http.request.uri String | URI | The absolute URI of the request. Example value: |
http.request.uri.path String | URI path | The URI path of the request. Example value: |
http.request.uri.query String | URI query string | The entire query string for the request, without the Example value: |
Operators
Overview
Comparison operators specify how values defined in an expression must relate to the actual HTTP request value for the expression to return true.
Logical operators combine two expressions to form a compound expression and use order of precedence to determine how an expression is evaluated.
Load Balancing expressions also support grouping symbols, which allow you to organize expressions, enforce operator precedence, and nest expressions. For examples and usage, see Grouping symbols in the Firewall Rules documentation.
Comparison operators
Comparison operators return true
when a value from an HTTP request matches a value defined in an expression.
This is the general pattern for using comparison operators:
<field> <comparison operator> <value>
Load Balancing expressions support these comparison operators:
Name | Operator Notation | Supported Data Types | Example (operator in bold) | ||
---|---|---|---|---|---|
String | IP | Rules list | |||
Equal | eq | ✅ | ✅ | ✅ | http.request.uri.path eq "/articles/2008/" |
Not equal | ne | ✅ | ✅ | ✅ | ip.src ne 93.184.216.0 |
Exactly contains | contains | ✅ | ❌ | ❌ | http.request.uri.path contains "/articles/" |
Matches RE2 regex | matches | ✅ | ❌ | ❌ | http.request.uri.path matches "^/articles/200[7-8]/$" |
Value is in a set of values | in | ✅ | ✅ | ✅ | ip.src in { 93.184.216.0 93.184.216.1 } |
Logical operators
Logical operators combine two or more expressions into a single compound expression. A compound expression has this general syntax:
<expression> <logical operator> <expression>
Each logical operator has an order of precedence. The order of precedence (along with grouping symbols) determines the order in which Cloudflare evaluates logical operators in an expression. The not
operator ranks first in order of precedence. For more on how Cloudflare evaluates logical operators in expressions, see Order of precedence in the Firewall Rules documentation.
Load Balancing expressions support these logical operators:
Name | English Notation | C-like Notation | Example | Order of Precedence |
---|---|---|---|---|
Logical NOT | not | ! | not ( http.host eq "www.cloudflare.com" and ip.src in 93.184.216.0/24 ) | 1 |
Logical AND | and | && | http.host eq "www.cloudflare.com" and ip.src in 93.184.216.0/24 | 2 |
Logical XOR (exclusive OR) | xor | ^^ | http.host eq "www.cloudflare.com" xor ip.src in 93.184.216.0/24 | 3 |
Logical OR | or | || | http.host eq "www.cloudflare.com" or ip.src in 93.184.216.0/24 | 4 |