- 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
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 the SDKs or the Kubernetes Operator.If you only have one instance now, you can add additional replicas later for redundancy through load balancing.Reserve a domain
Navigate to the Domains section of the ngrok dashboard and click New + to reserve a free static domain like or a custom domain you already own.This guide refers to this domain as
$NGROK_DOMAIN from here on out.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.
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:Then add your secrets using the vault ID from the response:
Apply Traffic Policy to your Cloud Endpoint
While viewing your new Cloud Endpoint in the dashboard, copy the policy below and paste it into the Traffic Policy editor.
Make sure you change each of the following values:What’s happening here?
This policy creates a production-ready PaaS alternative.
On every HTTP request, the policy enforces OWASP WAF protection, DDoS mitigation via rate limiting, bot blocking for unwanted crawlers and Tor traffic, and authentication for admin/API routes, before forwarding your request to the pool of upstream services.On every HTTP response, the policy enforces WAF rules on the headers and body, then adds common security headers to the response.
$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
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