Traffic Policy lets you configure access controls once and enforce them on every device in your fleet. No firmware pushes, OTA updates, or truck rolls required to update security rules. Use Traffic Policy to:Documentation Index
Fetch the complete documentation index at: https://ngrok.com/docs/llms.txt
Use this file to discover all available pages before exploring further.
- Authenticate and restrict traffic before it reaches your devices. Require JWTs, OAuth, or specific IP ranges so only authorized traffic can reach your fleet, and rate limit noisy consumers before they overwhelm a device.
- Access services, not entire devices. Unlike VPNs, ngrok exposes exactly the service each consumer needs and not a single port or process more. Use internal endpoints combined with Cloud Endpoints to control which services are accessible and to whom, and to forward and load balance traffic across them.
- Update policy without touching devices. When a new security requirement comes in, update one Traffic Policy and the change applies across your entire fleet immediately. No need to push updates to individual devices.
Restrict access by IP
Limit access to specific IP addresses or CIDR ranges: The following Traffic Policy configuration demonstrates how to restrict access to specific IP addresses using therestrict-ips action.
Example Traffic Policy document
1.1.1.1 are
allowed, while requests from the IP 110.0.0.0
are denied.
Example request
If the request comes from an allowed IP, the response will proceed as normal. If the request comes from a denied IP, the connection will be closed:JWT validation
Require a valid JWT token on every request: The following Traffic Policy configuration is an example configuration of thejwt-validation action. For a
more real-world example, check out the Auth0 guide.
Example Traffic Policy document
Example request
Authorization header with the Bearer prefix and getting back a 200 OK
response.
See the jwt-validation action reference for full configuration options.
OAuth
Require login via Google, GitHub, Microsoft, or other providers:Rate limit by host header
Prevent a misbehaving integrator, customer app, or internal service from overwhelming your devices: The following Traffic Policy configuration demonstrates how to use therate-limit action to rate limit
all incoming requests by the Host header.
Example Traffic Policy document
Example request
httpbin.ngrok.app using the curl
command returns a 429 status code with a retry-after header indicating
the number of seconds to wait before retrying the request.
See the rate-limit action reference for details.
Forward traffic to internal services
Route public traffic to internal endpoints so devices are never directly exposed. This example configuration will set up a public endpoint (forward-internal-example.ngrok.app) forwarding all traffic it receives to a internal endpoint (example.internal) that forwards the request to port 80 on your local machine. Since it is forwarding all traffic to the internal endpoint, no traffic will be sent to 8080 which is the upstream port for the public endpoint.
Example Traffic Policy document
Start an internal endpoint
Start public endpoint with Traffic Policy
Example request
https://example.internal which will then forward the request to port 80 on your local machine.
Next steps
- Traffic Policy reference: explore all available actions
- Security: credential management, mTLS, and compliance
- Cloud-to-device: configure internal and cloud endpoints for your device services