A curated collection of production-ready Traffic Policy examples for ngrok endpoints. These policies demonstrate common patterns for traffic management, security, and optimization.
New to ngrok? Sign up for a free account and get started in minutes!
ngrok's Traffic Policies provide a powerful configuration language for managing traffic to your endpoints. With policies, you can:
- 🛡️ Security: Block malicious traffic and validate requests
- 🔄 Routing: Rewrite URLs and redirect traffic
- 📊 Monitoring: Log requests and add custom headers
- ⚡ Performance: Cache responses and load balance
- 🎯 Targeting: Route traffic based on conditions
Traffic policies can be scoped to specific endpoints, enabling teams to manage policies independently - API teams for internal services, DevOps for public endpoints.
This repository is organized to roughly mirror the ngrok Traffic Policy Documentation structure for easy navigation
Use a policy directly from this repository:
# For local development
ngrok http 8080 --traffic-policy-url https://raw.githubusercontent.com/ngrok-samples/traffic-policy-examples/main/security/rate-limit.yaml
# For cloud endpoints
ngrok api endpoints create \
--url your-domain.ngrok.app \
--traffic-policy-url https://raw.githubusercontent.com/ngrok-samples/traffic-policy-examples/main/security/rate-limit.yaml
Clone the repository and reference local files:
# Clone the repository
git clone https://github.com/ngrok-samples/traffic-policy-examples.git
cd traffic-policy-examples
# Use with ngrok agent
ngrok http 8080 --traffic-policy-file ./security/rate-limit.yaml
# Use with cloud endpoints
ngrok api endpoints create \
--url your-domain.ngrok.app \
--traffic-policy-file ./security/rate-limit.yaml
Copy any policy configuration and modify it for your specific needs, then apply it through the ngrok Dashboard or API.
We welcome contributions from the community! Here's how you can help:
- Open an issue describing the use case and policy you'd like to see
- Include details about the problem you're solving and expected behavior
- Fork this repository
- Create a new branch for your policy
- Add your policy file in the appropriate category directory
- Include clear documentation and comments in the policy
- Submit a pull request with a detailed description
- Use clear, descriptive filenames
- Include inline comments explaining complex logic
- Test your policy before submitting
- Follow the existing file structure and naming conventions
- For policy questions: ngrok Discord
- For documentation: Traffic Policy Docs
- For bugs or issues: GitHub Issues
Note: Spam submissions will be closed and reported. Please ensure your contributions are relevant and helpful to the community.