Docs
Skip to content

Firewall

Conditions_

Learn how Firewall conditions match requests by hostname, path, method, headers, query parameters, IP, client, and location in Appwrite.

5 min read

Raw

Conditions define which requests a Firewall rule matches. A condition compares one attribute of the request, such as its path or the client's country, against a value you choose.

Every condition on a rule must match for the rule to apply. Two conditions on one rule mean "this and that", never "this or that". To match either of two values, create one rule for each.

Attributes

The condition builder groups attributes by what they describe. A further 13 attributes need the premium Geo DB addon.

Request

AttributeMatchesTypical use
HostnameHost serving the requestSeparate policies per domain
PathURL path only, query string strippedProtect /v1/... prefixes or sensitive routes
MethodMethod enum (GET, POST, and others), uppercasedRestrict mutating methods on a path
Protocolhttp or httpsTreat plaintext traffic differently
HeaderA named request headerRequire, block, or match custom headers
Query parameterA named query string parameterMatch tokens or flags passed in the URL
Query parameter nameThe parameter names present, ignoring their valuesMatch on the presence of a parameter
AcceptRaw Accept headerTell browser navigation from API calls
Accept-LanguageRaw Accept-Language headerFilter by the languages a client asks for
CookieRaw Cookie headerMatch a cookie your application sets

Accept, Accept-Language, and Cookie carry a value only for Functions and Sites traffic. On an API rule they are always empty.

Client

AttributeMatchesTypical use
IP addressClient IP as seen by Appwrite. Single IPs or CIDR blocksBlock or allowlist addresses and ranges
Operating systemOperating system derived from the user agentFilter traffic by client platform
BrowserBrowser derived from the user agentFilter specific browsers or embedded clients
User agentRaw User-Agent headerFilter bots, scripts, or known clients

Location

AttributeMatchesTypical use
CountryISO country code from geo lookup, uppercasedGeo allow or deny lists
ContinentContinent code from geo lookup, uppercasedBroad geo policies

Premium Geo DB

With the premium Geo DB addon you can also match on City, State, Postal code, Latitude, Longitude, Time zone, Weather code, ISP, AS number, AS organization, Connection type, Connection usage type, and Connection organization. The network attributes tell data center traffic apart from residential and mobile connections.

Without the addon the Console disables these attributes, and the API rejects them with a waf_rule_premium_condition error.

If the addon lapses on a project that already uses them, Appwrite treats those attributes as empty on API traffic. Equals conditions then never match, and Not equal conditions match every request, so a deny rule can start denying everything. Rewrite those rules before you drop the addon.

Header and query parameter keys

Header and Query parameter conditions target a named key. Enter the header name (for example x-api-client) or parameter name (for example token) together with the operator and value.

Keys must be lowercase to match. The Console lowercases the key when it saves the rule. Through the API, write the key in lowercase yourself, or the condition never matches.

Appwrite strips these headers before it evaluates conditions. A Header condition on any of them never matches, even though you can save the rule:

cookie, authorization, x-appwrite-key, x-appwrite-jwt, x-appwrite-user-jwt, x-appwrite-session, and any x-forwarded-* header.

To match a cookie on Functions or Sites traffic, use the Cookie attribute instead.

Matching details

  • IP address accepts single IPs (203.0.113.10) and CIDR blocks (10.0.0.0/8). CIDR blocks match only with Equals and Not equal.
  • Path conditions work best with Starts with, for prefixes such as /v1/account.
  • Operating system and Browser are derived from the user agent and may not resolve for unusual clients. Match User agent directly instead.

Text comparison ignores case.

When Appwrite cannot resolve a location

Geo lookup fails for some addresses. Country and Continent then hold unresolved on an API rule, and are unset on a Functions or Sites rule.

Either way they match every Not equal condition, so a rule that allows only certain countries denies that traffic too. On an API rule, add Country Not equal unresolved to let it through.

Operators

OperatorMeaningNeeds a value
EqualsExact matchYes
Not equalDoes not equalYes
ContainsValue contains the textYes
Does not containValue does not contain the textYes
Starts withValue begins with the textYes
Ends withValue ends with the textYes
Is emptyAttribute is unsetNo
Is not emptyAttribute is setNo

Which operators appear depends on the attribute:

AttributeOperators
Most attributesEquals, not equal, contains, starts with, ends with, is empty, is not empty
MethodEquals, not equal, is empty, is not empty
Country, ContinentEquals, not equal, contains, does not contain
Latitude, Longitude, AS number (Premium Geo DB)Equals, not equal, is empty, is not empty

Is empty matches attributes the request did not send, such as a missing header. It does not match User agent: when that header is absent, Appwrite stores an empty string rather than leaving it unset.

Multiple conditions

Add several conditions on one rule when you need a narrow match. Examples:

  • Path starts with /v1/users and method equals DELETE
  • Country equals US and path starts with /v1
  • IP not equal to your office range (198.51.100.0/24) and path starts with /v1
  • Header x-api-client is empty and user agent contains bot

A rule holds at most 100 conditions.

The Console previews how many recent requests a rule would match. See Impact preview.

Attribute names for the API

The Console sends these names for you. Use them when you create rules through the API. Any other name returns a 400 error.

Console labelAPI name
Hostnamehost
Pathpath
Methodmethod
Protocolprotocol
Headerheaders.<name>
Query parameterquery.<key>
Query parameter namequeryKeys
Acceptaccept
Accept-LanguageacceptLanguage
Cookiecookie
IP addressip
Operating systemos
Browserbrowser
User agentuserAgent
Countrycountry
Continentcontinent
Citycity
Statestate
Postal codepostalCode
Latitudelatitude
Longitudelongitude
Time zonetimeZone
Weather codeweatherCode
ISPisp
AS numberautonomousSystemNumber
AS organizationautonomousSystemOrganization
Connection typeconnectionType
Connection usage typeconnectionUsageType
Connection organizationconnectionOrganization

Was this page helpful?

Share what worked or what we should fix. Once approved, our agents automatically apply suggested updates to the docs.