Match Conditions
Match conditions determine when rules should be executed. They provide a flexible system for targeting specific requests based on various attributes like headers, paths, IP addresses, and more.
Overview
Control how conditions are evaluated with three logical operators:
Match Operators
Choose how multiple conditions should be combined in your matching logic
Condition Types
Paths
Match against request URLs using various strategies from exact matches to wildcard patterns.
Basic Path Matching
- paths
- !paths
{
"paths": [
"/api/*",
"/v2/users/*"
]
}{
"!paths": [
"/api/*",
"/v2/users/*"
]
}Path Prefix Matching
- paths_startswith
- !paths_startswith
{
"paths_startswith": [
"/api/",
"/admin/"
]
}{
"!paths_startswith": [
"/api/",
"/admin/"
]
}Exact Path Matching
- paths_full
- !paths_full
{
"paths_full": [
"/health",
"/status"
]
}{
"!paths_full": [
"/health",
"/status"
]
}Wildcard Path Matching
- paths_wildcard
- !paths_wildcard
{
"paths_wildcard": [
"/api/*/users",
"/files/*.jpg"
]
}{
"!paths_wildcard": [
"/api/*/users",
"/files/*.jpg"
]
}Headers
Match against HTTP request and response headers with multiple matching strategies for flexible header-based routing.
Basic Header Matching
- reqheader
- !reqheader
{
"reqheader": {
"User-Agent": [
"mobile-app",
"desktop-app"
],
"Accept-Language": [
"en-US",
"en-GB"
]
}
}{
"!reqheader": {
"User-Agent": [
"mobile-app",
"desktop-app"
],
"Accept-Language": [
"en-US",
"en-GB"
]
}
}Header Value Matching
- reqheader_values
- !reqheader_values
{
"reqheader_values": {
"Authorization": [
"Bearer abc123"
],
"X-API-Key": [
"key1",
"key2"
]
}
}{
"!reqheader_values": {
"Authorization": [
"Bearer abc123"
],
"X-API-Key": [
"key1",
"key2"
]
}
}Header Prefix Matching
- reqheader_startswith_values
- !reqheader_startswith_values
{
"reqheader_startswith_values": {
"User-Agent": [
"Mozilla/",
"Chrome/"
],
"X-Forwarded-For": [
"192.168."
]
}
}{
"!reqheader_startswith_values": {
"User-Agent": [
"Mozilla/",
"Chrome/"
],
"X-Forwarded-For": [
"192.168."
]
}
}Header Wildcard Matching
- reqheader_wildcard_values
- !reqheader_wildcard_values
{
"reqheader_wildcard_values": {
"User-Agent": [
"*mobile*",
"*tablet*"
],
"Accept": [
"image/*"
]
}
}{
"!reqheader_wildcard_values": {
"User-Agent": [
"*mobile*",
"*tablet*"
],
"Accept": [
"image/*"
]
}
}Exact Header Matching
- reqheader_full_values
- !reqheader_full_values
{
"reqheader_full_values": {
"Content-Type": [
"application/json"
],
"X-Requested-With": [
"XMLHttpRequest"
]
}
}{
"!reqheader_full_values": {
"Content-Type": [
"application/json"
],
"X-Requested-With": [
"XMLHttpRequest"
]
}
}Basic Response Header Matching
- respheader
- !respheader
{
"respheader": {
"Content-Encoding": [
"gzip"
],
"Server": [
"AkamaiNetstorage"
]
}
}{
"!respheader": {
"Content-Encoding": [
"gzip"
],
"Server": [
"AkamaiNetstorage"
]
}
}Response Header Value Matching
- respheader_values
- !respheader_values
{
"respheader_values": {
"Server": [
"AkamaiNetstorage"
],
"Content-Type": [
"text/html"
]
}
}{
"!respheader_values": {
"Server": [
"AkamaiNetstorage"
],
"Content-Type": [
"text/html"
]
}
}Response Header Prefix Matching
- respheader_startswith_values
- !respheader_startswith_values
{
"respheader_startswith_values": {
"content-type": [
"text/"
]
}
}{
"!respheader_startswith_values": {
"content-type": [
"text/"
]
}
}Response Header Wildcard Matching
- respheader_wildcard_values
- !respheader_wildcard_values
{
"respheader_wildcard_values": {
"Server": [
"*aws*"
]
}
}{
"!respheader_wildcard_values": {
"Server": [
"*aws*"
]
}
}Exact Response Header Matching
- respheader_full_values
- !respheader_full_values
{
"respheader_full_values": {
"Content-Type": [
"application/json"
],
"X-Requested-With": [
"XMLHttpRequest"
]
}
}{
"!respheader_full_values": {
"Content-Type": [
"application/json"
],
"X-Requested-With": [
"XMLHttpRequest"
]
}
}Query Parameters
Match against URL query parameters for dynamic request routing and processing.
Query Parameter Existence
- query_exists
- !query_exists
{
"query_exists": [
"debug",
"preview"
]
}{
"!query_exists": [
"debug",
"preview"
]
}Query Parameter Values
- query_values
- !query_values
{
"query_values": {
"version": [
"v1",
"v2"
],
"format": [
"json",
"xml"
]
}
}{
"!query_values": {
"version": [
"v1",
"v2"
],
"format": [
"json",
"xml"
]
}
}Query Wildcard Matching
- query_wildcard_values
- !query_wildcard_values
{
"query_wildcard_values": {
"search": [
"*product*"
],
"category": [
"electronics*"
]
}
}{
"!query_wildcard_values": {
"search": [
"*product*"
],
"category": [
"electronics*"
]
}
}Exact Query Parameter Matching
- query_full_values
- !query_full_values
{
"query_full_values": {
"version": [
"v1.0"
],
"format": [
"json",
"xml"
]
}
}{
"!query_full_values": {
"version": [
"v1.0"
],
"format": [
"json",
"xml"
]
}
}Query Parameter Prefix Matching
- query_startswith_values
- !query_startswith_values
{
"query_startswith_values": {
"category": [
"tech",
"news"
],
"tag": [
"featured"
]
}
}{
"!query_startswith_values": {
"category": [
"tech",
"news"
],
"tag": [
"featured"
]
}
}Query Parameter Map Matching
- query
- !query
{
"query": {
"action": [
"view",
"edit"
],
"format": [
"json"
]
}
}{
"!query": {
"action": [
"view",
"edit"
],
"format": [
"json"
]
}
}Geographic Matching
Match requests based on client geographic location using country, region, continent, and city codes.
Geographic Country Matching
geo_country- geo
- !geo
{
"geo": [
"US",
"CA",
"GB"
]
}{
"!geo": [
"US",
"CA",
"GB"
]
}Geographic Region-Based Matching
geo_region- region
- !region
{
"region": [
"BY",
"IL",
"NY"
]
}{
"!region": [
"BY",
"IL",
"NY"
]
}Geographic Continent-Based Matching
geo_continent- continent
- !continent
{
"continent": [
"NA",
"EU"
]
}{
"!continent": [
"NA",
"EU"
]
}Geographic City-Based Matching
geo_city- city
- !city
{
"city": [
"MUNICH",
"CHICAGO"
]
}{
"!city": [
"MUNICH",
"CHICAGO"
]
}IP & ASN Matching
Match requests based on client IP addresses (IPv4/IPv6) and Autonomous System Numbers.
ASN Matching
- asn
- !asn
{
"asn": [
16509,
8075,
13335
]
}{
"!asn": [
16509,
8075,
13335
]
}ASN Exact Matching
- asn_equals
- !asn_equals
{
"asn_equals": [
"16509",
"15169",
"32934"
]
}{
"!asn_equals": [
"16509",
"15169",
"32934"
]
}IPv4 Matching
- ipv4
- !ipv4
{
"ipv4": [
"192.0.2.100",
"198.51.100.0/24",
"203.0.113.0/24"
]
}{
"!ipv4": [
"192.0.2.100",
"198.51.100.0/24",
"203.0.113.0/24"
]
}IPv6 Matching
- ipv6
- !ipv6
{
"ipv6": [
"2001:db8::1",
"2001:db8::/32"
]
}{
"!ipv6": [
"2001:db8::1",
"2001:db8::/32"
]
}Cookie Matching
Match requests based on cookie names using exact, prefix, or wildcard patterns.
Cookie Name Matching
- cookie_name
- !cookie_name
{
"cookie_name": [
"session_id",
"user_pref"
]
}{
"!cookie_name": [
"session_id",
"user_pref"
]
}Cookie Name Prefix
- cookie_name_startswith
- !cookie_name_startswith
{
"cookie_name_startswith": [
"sess_",
"temp_"
]
}{
"!cookie_name_startswith": [
"sess_",
"temp_"
]
}Cookie Name Wildcards
- cookie_name_wildcard
- !cookie_name_wildcard
{
"cookie_name_wildcard": [
"*_session",
"user_*"
]
}{
"!cookie_name_wildcard": [
"*_session",
"user_*"
]
}Request Properties
Match requests based on HTTP method, protocol scheme, and file extension.
HTTP Method Matching
- method
- !method
{
"method": [
"GET",
"POST",
"PUT"
]
}{
"!method": [
"GET",
"POST",
"PUT"
]
}Protocol/Scheme Matching
scheme- protocol
- !protocol
{
"protocol": [
"https"
]
}{
"!protocol": [
"https"
]
}URL Scheme Matching
protocol- scheme
- !scheme
{
"scheme": [
"https"
]
}{
"!scheme": [
"https"
]
}File Extension Matching
- extension
- !extension
{
"extension": [
"jpg",
"png",
"gif",
"webp"
]
}{
"!extension": [
"jpg",
"png",
"gif",
"webp"
]
}Response Properties
Match based on response properties such as origin timeout status. Available in response match conditions only (onClientResponse, onOriginResponse).
Origin Timeout Matching
- origin_timeout
- !origin_timeout
{
"origin_timeout": true
}{
"!origin_timeout": true
}Response Status Code Matching
- status
- !status
{
"status": [
500,
"502-504",
"5xx"
]
}{
"!status": [
500,
"502-504",
"5xx"
]
}Performance and Validation
โกEfficient Matching
- โUse specific conditions first
- โPrefer prefix over wildcards
โ ๏ธPerformance Tips
- โ Avoid complex wildcards
- โ Limit array sizes
- โ Use matchAll for quick exits
โ Best Practices
- โStart with simple conditions
- โTest thoroughly in staging
- โDocument complex logic