Building with LLMs?We want your feedback!
Sign up for early access to ngrok’s AI Gateway and our team will reach out to learn more about your needs.
1: 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. We’ll refer to this domain as$NGROK_DOMAIN from here on out.
2: Run n8n + ngrok
To run n8n and ngrok in Docker, you can either use Docker Compose to run both services together or run them as separate containers. In both cases, you can use a.env file to store configuration values.
Replace NGROK_DOMAIN and NGROK_AUTHTOKEN with your values, as well as N8N_HOST and WEBHOOK_URL with your reserved domain. If you don’t already have an authtoken, you can find it in your dashboard here.
.env
docker-compose.yaml file to run both services together or run them as separate containers with docker run.
docker-compose.yaml file is located.
3. Try out your n8n endpoint
You can now access your n8n instance at the domain you reserved in step 1. Visit it in your browser to go through the first time n8n admin account setup.Optional: Secure your n8n dashboard with Traffic Policy
Even though n8n comes with built-in user administration, you can protect the sign-in page from automated attacks by restricting access to only trusted IPs. Go to our IP address helper tool to get your public IP address. Next, create a file namedn8n.yaml on the same system where n8n runs and paste in the following policy, replacing $YOUR_IP.
n8n.yaml
What’s happening here?This policy applies the
restrict-ips Traffic Policy action and allows only
devices with a matching IP address to access your n8n instance.
All other requests are denied at ngrok’s network without reaching your service.docker-compose.yaml file to mount the policy file into the ngrok container and tell ngrok to use it.
Optional: Enforce verification on incoming webhooks
If you want to receive webhooks from external services, but also want to control precisely which services can send these requests and during what conditions, you can use theverify-webhooks action.
For example, if you want to verify a webhook from GitHub, you can edit your n8n.yaml file and paste in the policy below.
Replace $WORKFLOW_UUID with your workflow’s path and $SECRET with the secret you configured when you created your webhook.
n8n.yaml
What’s happening here?This policy filters for only traffic that contains the specific
/webhook/$WORKFLOW_UUID path. It then verifies that the traffic both originates from GitHub (or another supported provider) and contains the appropriate secret.Configure both IP restrictions and webhook verification
If you configured IP restrictions earlier, and then set up webhook verification, you’ll find that your webhooks won’t work because you haven’t added the provider’s IP to yourrestrict-ips action to allow them.
Because it’s next to impossible to identify all the IPs where a provider’s webhooks might come from, it’s easier to disable IP restrictions on the /webhooks/ path.
Edit your n8n.yaml file with the policy below.
n8n.yaml
What’s happening here?This policy first verifies any incoming webhooks as before. Then, the policy applies IP restrictions to only traffic not to the
/webhook/ path, which allows your webhooks provider’s request to reach n8n successfully.What’s next?
- Watch our livestreamed n8n workshop to see this example deployed live.
- Read more about Traffic Policy, core concepts, and actions you might want to implement next.
- View your Ollama traffic in Traffic Inspector.