- Enforce strict mTLS certificate authentication before any database access
- Rate limit requests per client to prevent abuse and runaway costs
- Block dangerous queries to protect sensitive data
- Support secure database replication across clouds without exposing credentials
1. Create an endpoint for your database service
Start an internal Agent Endpoint for your database proxy or HTTP database interface, replacing$PORT
based on where it listens.
You 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 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.
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. (Optional) Create a vault and secrets
For production environments, store your CA certificate securely using Traffic Policy Secrets. This step is optional—you can also include the certificate directly in your policy. Create a vault to store your CA certificate: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.If you don’t have certificates, you can generate them using the steps in the mTLS example documentation:Add the contents of
ca.crt
to your vault as client-ca-certificate
.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 the mTLS authentication and rate limiting:
What’s next?
- Read about other gateway shapes you can build with ngrok
- Learn more about mTLS certificate authentication for high-security environments
- For token-based authentication, explore JWT validation as a scalable alternative to basic authentication
- Set up comprehensive logging to send database access events to your SIEM or monitoring platform
- Use URL rewriting to transform database queries or add security constraints
- View database access patterns in Traffic Inspector to identify potential security issues