- Load balance across multiple app instances with automatic failover
- Terminate TLS and use custom domains professionally
- Add authentication and security without changing your application code
- Monitor traffic and performance with comprehensive logging
- Protect against attacks with WAF-like rules and rate limiting
- Handle geo-aware routing and DDoS protection at the edge
1. Create endpoints for your application instances
Start multiple Agent Endpoints with the same URL to create an endpoint pool for automatic load balancing. Replace$PORT
with your application ports.
You can also use one of our SDKs or the Kubernetes Operator.
If you only have one instance now, you can add additional replicas later for redundancy through load balancing.
By using the same URL with
--pooling-enabled
, ngrok automatically creates an Endpoint Pool that distributes traffic round-robin across all healthy instances with automatic failover.2. Reserve a domain
Navigate to the Domains section of the ngrok dashboard and click New + to reserve a free static domain likehttps://your-service.ngrok.app
or a custom domain you already own.
We’ll refer to this domain as $NGROK_DOMAIN
from here on out.
For a production PaaS alternative, consider using a custom domain you own instead of an ngrok subdomain.
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 domain you just reserved to finish creating your Cloud Endpoint.4. Create a vault and secrets
Store your authentication and API secrets securely using Traffic Policy Secrets. First, create a vault to store your application secrets:5. Apply Traffic Policy to your Cloud Endpoint
While still viewing your new cloud endpoint in the dashboard, copy and paste the policy below into the Traffic Policy editor. Make sure you change each of the following values:$GITHUB_CLIENT_ID
: Replace with your GitHub OAuth app client ID$YOUR_ADMIN_EMAIL
: Replace with your admin email address for OAuth access$YOUR_ADMIN_USERNAME
: Replace with the username for API authenticationhttps://service.internal
: Replace with your actual pooled endpoint URL
6. 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.
Test a few of the features you added with Traffic Policy:
What’s next?
- Read about other gateway shapes you can build with ngrok
- Learn about Endpoint Pooling for simpler automatic load balancing
- Explore custom domains to use your own domain instead of ngrok subdomains
- Use Traffic Inspector to monitor performance and debug issues
- Add circuit breaker protection to handle upstream failures gracefully