Skip to content
AnswerWell geo Documentation

Research · 7 min read · Answerwell

Zero Trust Gateway Policy Enforcement Order and Precedence

How Cloudflare Gateway evaluates DNS, network, and HTTP policies, sets precedence, and fixes order-of-enforcement surprises after the 2025 change.

This page summarizes Cloudflare Zero Trust documentation on Gateway order of enforcement and order of precedence: which policy types run first, how rules inside each builder interact, how that changed in mid-2025, and how Gateway relates to Cloudflare Access policies on the same traffic.

Gateway order of enforcement: DNS, network, then HTTP

Section titled “Gateway order of enforcement: DNS, network, then HTTP”

Gateway applies policies in a fixed sequence across policy builders (separate rule lists), not only by drag-and-drop order within one list.

Gateway applies your policies in the following order:

DNS policies with selectors evaluated before resolution Resolver policies (if applicable) DNS policies with selectors evaluated after resolution Egress policies (if applicable) Network policies HTTP policies

— Cloudflare, Order of enforcement

DNS and resolver steps are independent from later layers: a DNS block alone does not stop someone who connects by IP unless you also control network or HTTP paths. For proxied HTTP/3 traffic, Cloudflare documents the same DNS → Network → HTTP sequence (Order of enforcement).

At the WAN edge, secure WAN traffic documentation places Network Firewall (L3/L4) ahead of Gateway; inside Gateway the order remains DNS → Network → HTTP.

2025 change: network policies before HTTP policies

Section titled “2025 change: network policies before HTTP policies”

From 2025-07-14, Gateway evaluates Network (layer 4) policies before HTTP (layer 7) policies. Filter outcomes for allow/block are unchanged for many pairs, but client notifications and block pages can change when both layers target the same destination.

Gateway will now evaluate Network (Layer 4) policies before HTTP (Layer 7) policies. This change preserves your existing security posture and does not affect which traffic is filtered — but it may impact how notifications are displayed to end users.

— Cloudflare, Gateway will now evaluate Network policies before HTTP policies

Combined rules (simplified) Before change After change
Network Block + HTTP Block (with block page) Block; HTTP block page / HTTP notification settings Block; follows Network notification settings; no HTTP block page
Network Allow + HTTP Block HTTP block + HTTP notification No change
Network Block + HTTP Allow Network block + Network notification No change

Cloudflare cites a more intuitive network-then-application model and fewer 526 errors by checking the network path before decrypted TLS (changelog). If users must still see an HTTP-style block page, add a client notification on the Network policy or rely on a single HTTP policy for that domain (changelog).

Order of precedence: first match inside each builder

Section titled “Order of precedence: first match inside each builder”

Order of precedence is the priority of individual rules within the DNS, Network, or HTTP policy list. Gateway walks the list in ascending precedence (lower number = higher priority in the UI: top of the list first).

Order of precedence refers to the priority of individual policies within the DNS, network, or HTTP policy builder. Gateway evaluates policies in ascending order beginning with the lowest value.

The order of precedence follows the first match principle. Once traffic matches an Allow or Block policy, evaluation stops in that filtering phase.

— Cloudflare, Order of enforcement

Cloudflare recommends the most specific allow, do-not-scan, or do-not-inspect rules above broad block rules (Troubleshoot Gateway). A later rule in the same phase cannot override an earlier match; HTTP request allow/block does not skip the separate Forward and body phases (Order of enforcement).

In the dashboard, policies run from top to bottom starting at precedence 1 (Order of enforcement). Reorder via drag-and-drop or the API precedence field on Update a Zero Trust Gateway rule (linked from the same page). New API-created policies without an explicit precedence often start around 1000 with spacing logic described in Order of enforcement.

DNS policies: resolution timing vs list order

Section titled “DNS policies: resolution timing vs list order”

Gateway evaluates DNS policies in two passes tied to resolution, then by precedence within each pass.

When DNS queries are received, Gateway evaluates policies with pre-resolution selectors, resolves the DNS query, then evaluates policies with post-resolution selectors. This means policies with selectors evaluated before DNS resolution take precedence.

— Cloudflare, Order of enforcement

A Domain rule evaluated pre-resolution can block example.com even when a post-resolution Allow appears higher in the list (Order of enforcement). Policies mixing both selector types are evaluated entirely post-resolution (Order of enforcement).

Resolver policies (Enterprise) run after pre-resolution DNS policies and before post-resolution DNS policies. Order most-specific regional resolvers first and the fallback last; the first match wins (regional private DNS tutorial).

HTTP policies: action-type phases within the HTTP builder

Section titled “HTTP policies: action-type phases within the HTTP builder”

Within HTTP policies, evaluation order is not only top-to-bottom by precedence. Action types define phases (Order of enforcement):

  1. Do Not Inspect — all matches first (by precedence); a match bypasses remaining HTTP policies except Clientless Web Isolation (implicit isolate).
  2. Isolate — by precedence; isolated requests can still hit later allow/block (e.g. block a path inside isolation).
  3. Allow, Block, Do Not Scan — by precedence; first match stops this request-policy phase.
  4. Forward (beta) — first matching rule invokes one Worker; placing Forward above Block does not bypass Block (Create your first HTTP policy).
  5. Body policies and inspection (DLP, AV, sandbox) — can interrupt an already-running Worker; body block may differ from the first logged action (Order of enforcement).

The learning path on HTTP policies recommends grouping Do Not Inspect policies logically at the top, then allows, then isolate/block, because Do Not Inspect is terminal regardless of list position.

Default when nothing matches: Allow for DNS, Network, and HTTP unless HTTP settings use a default Block; use a lowest-precedence catch-all block plus higher allow exceptions for a deny-by-default posture (Order of enforcement).

Applications, paths, and overlapping hostnames

Section titled “Applications, paths, and overlapping hostnames”

Application paths (Access and path-scoped rules): for a shared root path, the more specific path wins; dashboard.com/eng/exec does not inherit dashboard.com/eng rules when its own rule exists (Application paths).

Overlapping hostnames (many SaaS apps on one host): Gateway Application selectors in HTTP policies limit actions to the matched app; other apps on the same hostname may appear in logs without receiving that policy’s action (Applications and app types). Put the most specific Gateway policies at the highest precedence (Applications and app types).

Gateway vs Cloudflare Access on the same flow

Section titled “Gateway vs Cloudflare Access on the same flow”

Gateway Allow on network traffic does not bypass Access. Traffic to a private IP or hostname protected by Access still runs Access application policies; Gateway Block stops further evaluation (Order of enforcement).

By default, Access application policies run after all Gateway network policies. To interleave evaluation, add a Network policy with selector Access Infrastructure Target or Self-hosted Access App with Private Address / is / Present / Allow, then set precedence via dashboard or API (Add an infrastructure application, SSH with Access for Infrastructure, Secure a private IP or hostname). Users must still pass Access policies; the Gateway allow is for routing only (Add an infrastructure application). For browser RDP, turn off Enforce Cloudflare One Client session duration if it would block targets (Connect to RDP in a browser).

Access policy order (separate product): Service Auth and Bypass first (UI top-to-bottom), then Block and Allow; first Allow/Block match wins (Policies). The Policies FAQ contrasts this with Gateway HTTP exceptions (Do Not Inspect, Isolate).

In tiered setups, parent account Gateway policies evaluate before child policies. Children may override a parent rule when allow_child_bypass is set on that rule via the API (Tenant API).

Common mistakes when policies “fight” each other

Section titled “Common mistakes when policies “fight” each other”
  • Expecting a low-listed Allow to beat an earlier Block in the same builder — precedence is first match, not “most permissive wins” (Troubleshoot Gateway).
  • DNS allow without HTTP/network block — IP bypass remains possible (Order of enforcement).
  • Relying on HTTP block pages after 2025-07-14 when a silent Network block also matches (changelog).
  • Assuming Do Not Inspect disables isolation in clientless remote browser sessions (Order of enforcement).
  • Editing precedence in dashboard and Terraform without terraform refresh, causing drift (Order of enforcement).

Cloudflare’s worked example for https://test.example.com with DNS, network, and HTTP rules shows DNS and network first-match wins, then HTTP Do Not Inspect before block (Order of enforcement).

  1. In the Cloudflare dashboard, open Zero Trust → Traffic policies → Firewall policies and confirm each builder’s order matches Order of enforcement (DNS phases, then Network, then HTTP).
  2. For any domain with both Network and HTTP blocks, test after 2025-07-14 behavior: verify whether users see the notification you intend (changelog).
  3. Reproduce a known allow rule that “should win” and confirm no higher-precedence block in the same phase matches first (Troubleshoot Gateway).
  4. For Access-backed private apps, confirm Gateway network allows (if used) sit at the intended precedence and that Access still enforces authentication (Order of enforcement).
  5. You can check automatically in Answerwell (our tool): https://answerwell.org/workspace

If something on this page does not match your tenant or the official docs, email yimasynthetic@gmail.com with the page URL and the exact statement you want clarified.