Configure Ngrok for Team Development
Set up ngrok v3 configuration files — endpoints with traffic policies, OAuth authentication, rate limiting, IP restrictions, webhook verification, and team-shared development environments.
Content
Overview
The ngrok configuration file (ngrok.yml) defines tunnels, authentication, and traffic policies in a reproducible YAML format. Instead of passing flags on every ngrok invocation, you define your tunnel setup once and share it across the team. In ngrok v3, agent configuration is nested under the agent field and endpoints are defined under endpoints (the older tunnels field is deprecated).
Configuration File Location
ngrok looks for its config file in this order:
1. --config flag path
2. NGROK_CONFIG environment variable
3. ~/.config/ngrok/ngrok.yml (Linux/macOS)
4. %APPDATA%\ngrok\ngrok.yml (Windows)
For project-specific configs, keep a ngrok.yml in your repo and reference it with --config:
Basic Multi-Tunnel Configuration
Note the v3 changes: configuration uses endpoints instead of tunnels, and each endpoint specifies url and upstream rather than proto and addr.
OAuth Authentication
Protect tunnels with OAuth so only authenticated users from your organization can access them:
Supported OAuth providers: Google, GitHub, Microsoft, Facebook, LinkedIn, GitLab, Twitch, and Amazon. For most teams, Google or GitHub provides the simplest setup since your team already has accounts.
Traffic Policies
Traffic policies are ngrok's policy engine — they evaluate rules using Common Expression Language (CEL) expressions and execute actions at three lifecycle phases: on_tcp_connect, on_http_request, and on_http_response.
Rate Limiting
The bucket_key determines how rate limits are applied. Using conn.client_ip creates per-IP limits. You can also bucket by header values (e.g., API keys) for per-client limits.
API Key Validation
IP Allowlisting
Webhook Verification
Verify incoming webhooks from services like GitHub or Stripe:
Ngrok verifies the webhook signature before the request reaches your local server. Invalid signatures get rejected at the edge, reducing noise during development.
Response Header Manipulation
Combining Multiple Policies
Traffic policy rules are evaluated in order. Combine authentication, rate limiting, and header manipulation in a single endpoint:
Starting Tunnels
Inspection and Debugging
ngrok's built-in inspector captures all traffic for debugging:
Team Configuration Pattern
Share tunnel configuration through Git without exposing secrets:
Each developer sets their own NGROK_AUTHTOKEN and NGROK_SUBDOMAIN environment variables. The configuration file is safe to commit because it contains no secrets.
Best Practices
- -Store the ngrok config in your project repo and gitignore nothing except the authtoken (use env vars for the token).
- -Use custom domains for webhook endpoints — random ngrok URLs change on every restart, breaking webhook registrations.
- -Add OAuth on every publicly accessible tunnel. Unauthenticated tunnels are indexed by scanners within minutes.
- -Use traffic policies for rate limiting and access control — they execute at the ngrok edge before traffic reaches your machine.
- -Run multiple endpoints for microservice architectures instead of tunneling a single reverse proxy.
- -Enable the web inspector (
http://localhost:4040) during development to debug request/response cycles. - -Use webhook verification policies to filter invalid payloads at the edge.
Common Pitfalls
- -Committing authtokens to version control — always use environment variables.
- -Using CLI flags instead of a config file — flags are not reproducible or shareable.
- -Running a single tunnel when multiple services need exposure — each service should get its own endpoint.
- -No authentication on public tunnels — bots scan ngrok subdomains continuously.
- -Not using the web inspector — it is the fastest way to debug webhook payloads and API issues.
- -Using the deprecated
tunnelsfield in v3 configs — migrate toendpointswithurlandupstream.
FAQ
Discussion
Loading comments...