- Give each developer their own public URL like
bob.devtest.example.com
to route public traffic or webhooks into their local development environment. - Route requests to the right internal service using domain-based matching.
- Apply consistent policies like IP restrictions or mTLS to every developer endpoint from a single gateway.
What you’ll need
- A production pay-as-you-go account for creating wildcard domains
1. Let developers create endpoints for their services
Each developer can start their own Agent Endpoint using an internal URL that’s namespaced to your shared ngrok account, likebob.internal
, replacing $PORT
based on where their service listens.
They can also use one of our SDKs or the Kubernetes Operator.
2. Reserve a domain
Navigate to the Domains section of the ngrok dashboard and click New + to reserve a custom wildcard domain like*.devtest.example.com
.
You’ll then need to set up CNAME records with your DNS provider.
3. Create a Cloud Endpoint
Navigate to the Endpoints section of the ngrok dashboard, then click New + and Cloud Endpoint. In the URL field, enter the wildcard domain you just reserved to finish creating your Cloud Endpoint.4. Route traffic to developer environments with Traffic Policy
While still viewing your new cloud endpoint in the dashboard, copy and paste the policy below into the Traffic Policy editor.bob.devtest.example.com
, this policy extracts bob
from the hostname string and forwards it to bob.internal
, which in turn connects to that developer’s local environment. You can extend this to any number of developer environments by having them create new Agent Endpoints on internal URLs like https://alice.internal
and so on.
Try out your endpoint
Visit the domain you reserved either in the browser or in the terminal using a tool likecurl
.
You should see the app or service at the port connected to your internal Agent Endpoint.
What’s next?
- Read our best practices for developer productivity guide for ways to improve this example with developer-specific authtokens and custom connect URLs.
- Explore other examples of using the
forward-internal
Traffic Policy actions.