A fully programmable secure web gateway
Cloudflare adds true programmability to its Secure Web Gateway, letting teams run custom Workers code during policy evaluation for flexible, lowâmaintenance security.

A Fully Programmable Secure Web Gateway
Cloudflare is extending its Zero Trust portfolio with a programmable Secure Web Gateway (SWG) that runs custom logic directly in the policy evaluation path. By integrating Cloudflare Workers with Gateway and Data Loss Prevention (DLP), customers can now write arbitrary code that transforms traffic, queries external data sources, or applies bespoke validation before a decision to allow, block, isolate, or log is made.
---
Why Traditional Gateways Hit a Ceiling
For three decades, most SWGs have followed a simple model: match a condition, then fire a terminal action (allow, block, isolate, log). This works for common useâcases but falls short when environments become complexâmultiple SaaS apps, custom authentication flows, or nuanced dataâhandling policies. Organizations are forced into one of two compromises:
- Selfâmanaged firewalls/proxies â full control but high operational overhead and limited portability.
- Vendorâlocked appliances â low maintenance but constrained to the vendorâs predefined rule set.
Cloudflareâs experience building Gateway for years shows that many customers repeatedly hit this tradeâoff, seeking deeper integration without the cost of managing their own infrastructure.
---
True Programmability: Workers Meet Gateway
The new Forward action and custom validation functions expose a Workers runtime inside the gateway decision engine. Key capabilities include:
- Inline traffic transformation â modify HTTP headers, rewrite URLs, or inject security tokens on the fly.
- External data lookups â call internal APIs, threatâintel services, or identity providers during policy evaluation.
- Fineâgrained DLP checks â run custom regex or ML models against payloads before data leaves the network.
- Zeroâtrust integration â all features are available across Cloudflareâs Zero Trust plans, keeping the management experience consistent.
Because Workers execute at the edge, these custom actions add minimal latency while preserving the global scale and reliability Cloudflare is known for.
---
Practical Use Cases
| Scenario | How a WorkerâPowered Gateway Helps | |----------|--------------------------------------| | Dynamic SaaS access | Query a corporate directory to verify a userâs role before allowing API calls to a thirdâparty service. | | Contextâaware content filtering | Inspect request payloads for PII patterns and redact or block them based on regional compliance rules. | | Adaptive threat response | Pull realâtime threat scores from an internal SIEM and adjust block thresholds on a perârequest basis. | | Custom authentication flows | Generate oneâtime tokens or perform OIDC token introspection before forwarding traffic to legacy applications. |
These examples illustrate how security teams can embed organizationâspecific logic without deploying separate proxies or rewriting large rule sets.
---
Getting Started
- Enable the Forward action in the Cloudflare Dashboard under Gateway â Policies.
- Create a Worker using the familiar JavaScript/TypeScript API. The runtime provides request and response objects, plus helper methods to read DLP metadata.
- Attach the Worker to a policy as a custom validation function. The function returns a boolean (allow/deny) or a transformed request object.
- Test in staging using the builtâin request preview tool, then roll out to production.
Documentation includes sample Workers for common patternsâheader injection, external risk lookups, and payload sanitizationâso teams can iterate quickly.
---
The Bottom Line
By marrying the flexibility of Cloudflare Workers with the security posture of Gateway and DLP, Cloudflare delivers a truly programmable SWG that eliminates the classic security tradeâoff. Teams gain the ability to tailor policies to their unique environments while offloading the heavy lifting of scaling, patching, and availability to Cloudflareâs edge network. The result is a more adaptable, lowerâmaintenance security layer that can evolve alongside modern, distributed workloads.
Source
Read original sourceWhy we picked this
Introduces a programmable secure web gateway leveraging Cloudflare Workers, relevant infrastructure for AI services