- Validate incoming traffic, block malicious traffic, rewrite URLs, and respond with custom content.
- Forward traffic to your agents running across the globe and orchestrate traffic across your infrastructure.
- Add Traffic Policies to any type of ngrok endpoint to scope traffic management for each of your endpoints.
Concepts
Phases
Defined points in the lifecycle of a request to your endpoint where you can use Traffic Policy to modify request headers, transform response bodies, and more.
Phase Rules
Conditions and actions you configure to filter, manipulate, or manage traffic at specific phases, such as blocking requests from certain IPs or adding authentication headers.
Expressions
Conditions used in Phase Rules to determine when an action should be applied, such as checking if a request header matches a value or if an IP address is in a blocklist.
Actions
Operations that execute when a Phase Rule condition is met, such as adding headers, rate limiting requests, or redirecting traffic.
CEL Interpolation
Dynamically evaluate variables and macros in configuration values, such as inserting request headers into URLs or using timestamps in response headers.
Features
- Actions - Transform, redirect, and manage traffic flow with actions like
add-headers,rate-limit, andjwt-validation. - Variables - Filter, segment, and dynamically configure traffic rules and actions based on specific conditions.
- Macros - Apply macros in rule conditions to refine traffic segmentation and configure actions with dynamic precision.
Use cases
Block unwanted requests
Block malicious traffic, Tor exit nodes, bots, and specific IP addresses
from accessing your endpoints.
Add authentication
Add JWT validation, OAuth, OIDC, and basic authentication to secure
your endpoints.
Rate limit requests
Rate limit requests based on endpoint, IP address, or API key to
protect your services.
Rewrite URLs
Rewrite URLs and paths to route traffic to different backend services
or endpoints.
What’s next?
- Get started by applying a Traffic Policy to your app with the ngrok agent.
- Learn the key concepts that make up a Traffic Policy and how it works.
- Explore practical examples to see Traffic Policies in action.