This document explains how to configure policies and rules to control your
outbound agentic and non-agentic web traffic with Secure Web Proxy. You can control
which traffic is allowed or denied based on various criteria, ensuring only
authorized traffic leaves your network. Secure Web Proxy provides three
primary mechanisms for defining these controls: [authorization
policies](https://docs.cloud.google.com/secure-web-proxy/docs/policies-and-rules-overview#authorization-policies), [gateway security
policies and rules](https://docs.cloud.google.com/secure-web-proxy/docs/policies-and-rules-overview#policies-overview), and [service rate limiting
policies](https://docs.cloud.google.com/secure-web-proxy/docs/policies-and-rules-overview#rate-limiting-policies).

## Use the appropriate policy type

To secure outbound traffic with Secure Web Proxy, choose the policy mechanism
that best suits your appropriate traffic type:

- **Agentic AI traffic** : when deploying Secure Web Proxy as an
  [Agent Gateway](https://docs.cloud.google.com/secure-web-proxy/docs/deploy-swp-as-agent-gateway.md.txt),
  you can configure all security controls on the `agentGateway` resource by
  using
  [authorization policies with extension bindings](https://docs.cloud.google.com/secure-web-proxy/docs/policies-and-rules-overview.md.txt#authz-policies-with-agent-gateway).
  This lets you enforce *Model Context Protocol* (*MCP)* method-level
  restrictions, verify agent identity, and invoke external security services
  like Model Armor and Identity-Aware Proxy (IAP). Any policies
  that are directly attached to the underlying `Gateway` resource are ignored.

- **Standard web traffic** : when using Secure Web Proxy as an outbound proxy
  for non-agentic workloads, configure either an authorization policy or a
  gateway security policy directly on the `Gateway` resource:

  - **Authorization policy** : we recommend this policy type for deployments that require granular [frontend mutual TLS
    (mTLS)](https://docs.cloud.google.com/secure-web-proxy/docs/use-frontend-mtls-with-swp), identity checks, or [custom authorization
    extensions](https://docs.cloud.google.com/secure-web-proxy/docs/setup-authz-policies#delegate).
  - **Gateway security policy** : use this policy type to filter traffic based on [service accounts](https://docs.cloud.google.com/secure-web-proxy/docs/use-service-accounts.md.txt), [secure tags](https://docs.cloud.google.com/secure-web-proxy/docs/use-tags.md.txt), or [URL lists](https://docs.cloud.google.com/secure-web-proxy/docs/use-url-list.md.txt).

These policy models are mutually exclusive on a single gateway. In addition to
choosing your primary security policy, you can optionally configure the
following type of policy:

- **Service rate limiting policy**: use this policy type to prioritize traffic, protect external destinations from traffic overloads, and control the costs of outbound web traffic by limiting request counts. You can attach a service rate limiting policy to a gateway that uses either an authorization policy or a gateway security policy.

## Authorization policies

[Authorization policies](https://docs.cloud.google.com/load-balancing/docs/auth-policy/auth-policy-overview.md.txt)
let you establish identity-based access control checks
when processing outbound requests through Secure Web Proxy. You can configure
authorization policies
([`AuthzPolicy`](https://docs.cloud.google.com/load-balancing/docs/reference/network-security/rest/v1/projects.locations.authzPolicies.md.txt))
to validate the identity of a source workload or agent that accesses the
internet.

> [!NOTE]
> **Note:** If you already have a [gateway security policy](https://docs.cloud.google.com/secure-web-proxy/docs/policies-and-rules-overview.md.txt#policies-overview) with existing security rules, then you don't need to remove them. Secure Web Proxy ignores these rules when you apply an authorization policy to the gateway.

An authorization policy lets you specify conditions to allow, deny, or delegate
request authorization based on their source, destination, and other
request attributes. Requests that pass these checks are forwarded to the web
destination. Requests that fail are rejected with a `403 Forbidden` error.

For Secure Web Proxy, you can attach authorization policies
to your gateway resource to define the security perimeter for your outbound
traffic and evaluate authorization policy rules in
Secure Web Proxy. In addition, you can configure Secure Web Proxy to
delegate authorization decisions to an external authorization engine by using
Service Extensions ([authorization
extensions](https://docs.cloud.google.com/service-extensions/docs/configure-extensions-for-swp)).

For more information about how to configure authorization policies, see
[Set up authorization policies for
Secure Web Proxy](https://docs.cloud.google.com/secure-web-proxy/docs/setup-authz-policies).

Authorization policies provide the following benefits over standard
[gateway security policies](https://docs.cloud.google.com/secure-web-proxy/docs/policies-and-rules-overview.md.txt#policies-overview):

- **Consistent policy surface** : use the unified
  [`AuthzPolicy`](https://docs.cloud.google.com/load-balancing/docs/reference/network-security/rest/v1/projects.locations.authzPolicies.md.txt)
  API to manage traffic authorization for
  Secure Web Proxy along with other services such as Application Load Balancer and
  Cloud Service Mesh (CSM).

- **Service Extensions support**: use Service Extensions
  to delegate authorization decisions to your custom logic. You
  can use authorization extensions to perform request-level authorization (based
  on headers, identity, and more) and content sanitization (such as sensitive data
  protection or threat detection).

- **Identity-centric security** : while still supporting IP-based rules,
  authorization policies provide a more robust security posture by letting you
  enforce controls based on identity. You can define your security perimeter by
  using [service
  accounts](https://docs.cloud.google.com/secure-web-proxy/docs/setup-authz-policies#service-account),
  [tags](https://docs.cloud.google.com/secure-web-proxy/docs/setup-authz-policies.md.txt#tag), or [frontend mutual
  TLS](https://docs.cloud.google.com/secure-web-proxy/docs/use-frontend-mtls-with-swp). You can also use
  Service Extensions to delegate authorization decisions to
  identity-based services like IAP.

### Security and governance with Agent Gateway

When you [deploy Secure Web Proxy as an
Agent Gateway](https://docs.cloud.google.com/secure-web-proxy/docs/deploy-swp-as-agent-gateway),
you configure all governance policies on the `agentGateway` resource rather than
on the underlying proxy. Secure Web Proxy evaluates only the policies that are
explicitly attached to the `agentGateway` resource. The proxy ignores any
policies that are directly attached to the underlying `Gateway` resource.

Agent Gateway governance uses the following two-tier policy architecture:

1. **Extension bindings (primary governance mechanism)** :
   [extension bindings in
   Service Extensions](https://docs.cloud.google.com/gemini-enterprise-agent-platform/govern/gateways/extension-bindings-overview)
   are the primary mechanism to govern agentic traffic. You can attach managed
   security services directly to your `agentGateway` resource to inspect,
   authenticate, and sanitize agent communications in the following ways:

   - **Model Armor** : performs deep payload inspection to scan prompts and responses for sensitive data, jailbreaks, and prompt injection attacks. For more information, see [Delegate authorization to
     Model Armor](https://docs.cloud.google.com/gemini-enterprise-agent-platform/govern/gateways/delegate-authorization#configure-authz-ma).
   - **IAP** : cryptographically verifies client and agent identities before forwarding tool calls to backend resources. For more information, see [Delegate authorization to
     IAP](https://docs.cloud.google.com/gemini-enterprise-agent-platform/govern/gateways/delegate-authorization#configure-authz-iap).
2. **Authorization policies (fine-grained control, exceptions, and bypasses)** :
   [authorization
   policies](https://docs.cloud.google.com/secure-web-proxy/docs/setup-authz-policies#authz-policy-agentic-mcp)
   complement extension bindings by providing granular L4 and L7 rule
   evaluation:

   - **TLS inspection bypass**: configure network-level (L4) rules to bypass TLS interception for trusted external endpoints where deep inspection isn't required.
   - **MCP method and tool restrictions**: enforce HTTP-level (L7) rules to restrict MCP method actions, such as allowing only approved tools or restricting specific tool parameters.

> [!NOTE]
> **Note:** We recommend that you deploy a dedicated Secure Web Proxy gateway that's connected to an Agent Gateway specifically for AI agent traffic, rather than reusing a proxy that's configured for non-agentic workloads. This separation helps ensure that agent-specific guardrails, such as extension bindings, MCP method filtering, and client identity verification, are isolated from standard gateway security policies.

## Gateway security policies and rules

A [gateway security
policy](https://docs.cloud.google.com/secure-web-proxy/docs/create-a-policy#gateway-security-policies) is the
core security item that defines access controls for all outbound non-agentic web
traffic.

> [!NOTE]
> **Note:** Gateway security policies and rules are designed for non-agentic web traffic. To govern outbound AI agent traffic, use an [authorization policy with
> extension bindings](https://docs.cloud.google.com/secure-web-proxy/docs/policies-and-rules-overview#authz-policies-with-agent-gateway) attached to an `agentGateway` resource.

Gateway security policies include the following key features:

- **Policy control**: a policy contains the gateway security rules that the proxy
  uses to allow or deny a web request. You can create a single policy and reuse it across multiple
  Secure Web Proxy instances to keep your security rules consistent and
  efficient.

- **Secure by default** : gateway security policies are `deny-all`
  by default. The proxy blocks every HTTP and HTTPS request until you
  create a specific rule to permit it. This enforces a zero-trust architecture from
  the start.

- **Policy logic**: every policy is built on two core checks: determine
  the traffic source and verify the allowed destination.

> [!NOTE]
> **Note:** For information about the quotas and system limits that apply to Secure Web Proxy policies, see [Quotas and limits](https://docs.cloud.google.com/secure-web-proxy/docs/quotas.md.txt).

A [gateway security rule](https://docs.cloud.google.com/secure-web-proxy/docs/configure-rules.md.txt) is an
instruction in a gateway security policy that matches and defines the final action:
allow or deny.

Your Secure Web Proxy instance evaluates
rules based on priority, with the lowest number checked first. The proxy stops
and acts on the first rule that matches the request.

- **Session Matcher**: checks basic information about the network connection as
  it's being set up. Session Matcher includes the following items:

  - Source identity (service account or secure tag)
  - Destination hostname (the domain name)
  - Destination port
- **Application Matcher**: inspects the content of the actual web request. It's
  typically used to ensure granular control and requires TLS inspection to check
  encrypted traffic. Application Matcher includes the following items:

  - Full URL path
  - Request method---for example, block all `DELETE` actions
  - Specific HTTP headers

> [!NOTE]
> **Note:** To analyze request attributes such as HTTP methods or headers, [enable TLS inspection](https://docs.cloud.google.com/secure-web-proxy/docs/enable-tls-inspection.md.txt). When TLS inspection is active, use [authorization policies](https://docs.cloud.google.com/secure-web-proxy/docs/policies-and-rules-overview.md.txt#authorization-policies) instead of standard gateway rules to get finer control over identity and content controls for decrypted traffic.

## Service rate limiting policies

> [!WARNING]
>
> **Preview**
>
>
> This product or feature is
>
> subject to the "Pre-GA Offerings Terms" in the General Service Terms section
> of the [Service Specific
> Terms](https://docs.cloud.google.com/terms/service-terms#1).
>
> Pre-GA products and features are available "as is" and might have limited support.
>
> For more information, see the
> [launch stage descriptions](https://cloud.google.com/products/#product-launch-stages).

Service rate limiting policies help keep your outbound web traffic gateways
resilient. Although other traffic management mechanisms prioritize scaling
resources, rate limiting throttles resource-intensive clients at the source to
maximize gateway availability.

Secure Web Proxy enforces service rate limiting at the end of the request
processing path, after all gateway security rules, authorization checks, and
service extensions complete successfully. This helps ensure that only authorized
and trusted traffic consumes your rate limit budget.

> [!NOTE]
> **Note:** Service rate limiting applies only to Layer 7 traffic that matches a Secure Web Proxy rule with an application attribute (`ApplicationMatcher`). The outbound web traffic that matches a rule with only a session attribute (`SessionMatcher`) isn't subject to rate limiting.

For more information about how to set up rate limiting policies, see
[Service rate limiting
overview](https://docs.cloud.google.com/load-balancing/docs/srl-policy/service-rate-limiting-overview) and
[Configure service rate limiting
policies](https://docs.cloud.google.com/secure-web-proxy/docs/configure-service-rate-limiting-policies).

## Limitations

When you configure policies in Secure Web Proxy, the following
limitations apply:

- **Gateway security policies**: these policies don't support authorization
  extensions. Advanced capabilities like using custom logic or delegating
  authorization decisions to external services are available only through
  authorization policies.

- **Authorization policies**: these policies don't support URL lists or regular
  expression (regex) matching for URL strings.

- **Service rate limiting policies** : rate limiting applies only to Layer 7
  traffic that matches a rule with an application attribute
  (`ApplicationMatcher`). For outbound web traffic that matches a rule with only a
  session attribute (`SessionMatcher`), rate limiting isn't applied.

## What's next

- [Set up authorization policies for
  Secure Web Proxy](https://docs.cloud.google.com/secure-web-proxy/docs/setup-authz-policies)
- [Configure service rate limiting
  policies](https://docs.cloud.google.com/secure-web-proxy/docs/configure-service-rate-limiting-policies)
- [Gateway security policies](https://docs.cloud.google.com/secure-web-proxy/docs/create-a-policy.md.txt)
- [Gateway security rules](https://docs.cloud.google.com/secure-web-proxy/docs/configure-rules.md.txt)
- [Deploy Secure Web Proxy as an
  Agent Gateway](https://docs.cloud.google.com/secure-web-proxy/docs/deploy-swp-as-agent-gateway)