- 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
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 the SDKs or the Kubernetes Operator.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.
(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:Add your CA certificate to the vault 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.What’s happening here? This policy enforces mTLS certificate authentication where clients must present valid certificates signed by your trusted CA. Clients are rate limited based on their certificate identity, dangerous SQL operations are blocked, and authenticated requests are forwarded to your database service.
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