Sep 9, 2025
Sep 9, 2025
Getting started with ngrok is almost suspiciously easy. Which is why the question we hear most often isn’t "where do I start?" but rather “what else can I do with ngrok?” For over a decade, we’ve been serving millions of developers and, through them, millions of users.
Sure, our documentation has all the answers, every CLI flag, every Traffic Policy configuration neatly laid out, but what about the developers who are always on the lookout for a TL;DR? What if you too are not looking for a full solution or a specific use case for your next project, but just want to know… what else **you** can do with ngrok?
Presenting ngrok's new cheatsheet that walks you through some of our most interesting offerings, designed to scratch that itch of not just serving, but also securing endpoints in as little as two steps. Read on or download the crisp two-pager printable in PDF.
1# Install via Homebrew2brew install ngrok3 4# Add your authtoken5ngrok config add-authtoken <token>6 7# Start an endpoint8ngrok http 801# Install via Apt2curl -sSL https://ngrok-agent.s3.amazonaws.com/ngrok.asc \3 | sudo tee /etc/apt/trusted.gpg.d/ngrok.asc >/dev/null \4 && echo "deb https://ngrok-agent.s3.amazonaws.com bookworm main" \5 | sudo tee /etc/apt/sources.list.d/ngrok.list \6 && sudo apt update \7 && sudo apt install ngrok8# OR9# Install via Snap10snap install ngrok11 12# Add your authtoken13ngrok config add-authtoken <token>14 15# Start an endpoint16ngrok http 801# Install via WinGet2winget install ngrok -s msstore3# OR4# Install via Scoop5scoop install ngrok6 7# Add your authtoken8ngrok config add-authtoken <token>9 10# Start an endpoint11ngrok http 801# Add ngrok Kubernetes Operator to Helm2helm repo add ngrok https://charts.ngrok.com3 4# Add ngrok API key and authtoken5export NGROK_AUTHTOKEN=YOUR_NGROK_AUTHTOKEN6export NGROK_API_KEY=YOUR_NGROK_API_KEY7 8helm install ngrok-operator ngrok/ngrok-operator \9 --namespace ngrok-operator \10 --create-namespace \11 --set credentials.apiKey=$NGROK_API_KEY \12 --set credentials.authtoken=$NGROK_AUTHTOKEN1# Install via Docker2docker pull ngrok/ngrok3 4# Run ngrok via Docker5docker run --net=host -it -e NGROK_AUTHTOKEN=xyz ngrok/ngrok:latest http 801# Node.js: https://ngrok.com/downloads/node-js2npm install @ngrok/ngrok3 4# Go: https://ngrok.com/downloads/go5go get golang.ngrok.com/ngrok/v26 7# Python: https://ngrok.com/downloads/python8python3 -m pip install ngrok9 10# Rust: https://ngrok.com/downloads/rust11# Install ngrok-rust package and the required dependencies12cargo add ngrok -F axum && cargo add axum && cargo add tokio -F rt-multi-thread -F macrosRead the Docs: https://ngrok.com/docs/agent/#example-usage
1# Example: API service on localhost:80802ngrok http 80801# Example: On localhost:30002ngrok http 30001# Example: On Port 222ngrok tcp 22ngrok tcp 5432ngrok http http://192.168.1.50:8080Read the Docs: https://ngrok.com/docs/agent/#troubleshooting-connectivity
1ngrok diagnose2 3# To test IPv6 connectivity4ngrok diagnose --ipv6 true5 6# To test connectivity between the ngrok agent and all ngrok points of presence7ngrok diagnose --region all8 9# For a verbose report10ngrok diagnose -w out.txt #OR11ngrok diagnose --write-report out.txtRead the Docs: https://ngrok.com/docs/traffic-policy/
policy.yamlnano policy.yamlList of Providers: https://ngrok.com/docs/traffic-policy/actions/oauth/#supported-providers
1# policy.yaml2on_http_request:3 - actions:4 - type: oauth5 config:6 provider: google # OAuth available with Amazon, Facebook, GitHub, GitLab, Google, LinkedIn, Microsoft, Twitchngrok http 8080 --traffic-policy-file=policy.yaml1# policy.yaml2on_http_request:3 - actions:4 - type: oauth5 config:6 provider: google7 - expressions:8 - "!(actions.ngrok.oauth.identity.email in ['alice@example.com','bob@example.com'])"9 actions:10 - type: deny1# policy.yaml2on_http_request:3 - actions:4 - type: oauth5 config:6 provider: google7 - expressions:8 - "!(actions.ngrok.oauth.identity.email.endsWith('@example.com'))"9 actions:10 - type: denyRead the Docs: https://ngrok.com/docs/traffic-policy/actions/verify-webhook/
verify-webhook action for Slack1# policy.yaml2on_http_request:3 - actions:4 - type: verify-webhook5 config:6 provider: slack7 secret: $SLACK_TOKENRead more: https://ngrok.com/docs/integrations/slack/webhooks/
1ngrok http 3000 \2 --verify-webhook=slack \3 --verify-webhook-secret=$SLACK_TOKENprovider for any supported providerList of supported providers: https://ngrok.com/docs/traffic-policy/actions/verify-webhook/
1# policy.yaml2on_http_request:3 - actions:4 - type: verify-webhook5 config:6 provider: $PROVIDER # Example: GitHub7 secret: $PROVIDER_TOKENRead the docs: https://ngrok.com/docs/universal-gateway/internal-endpoints/
1# Create a private, internal agent endpoint only reachable via forward-internal2ngrok http 8080 --url https://api.internalRead the Docs: https://ngrok.com/docs/traffic-policy/actions/forward-internal/
1# Forward to an internal endpoint from a public endpoint2on_http_request:3 - actions:4 - type: forward-internal5 config:6 url: https://api.internalRead the Docs: https://ngrok.com/docs/universal-gateway/cloud-endpoints/routing-and-policy-decentralization/
1# policy.yaml2# Route /api/* to api.internal, /app/* to app.internal3on_http_request:4 - expressions:5 - "req.path.startsWith('/api/')"6 actions:7 - type: forward-internal8 config:9 url: https://api.internal10 - expressions:11 - "req.path.startsWith('/app/')"12 actions:13 - type: forward-internal14 config:15 url: https://app.internalRead the Docs: https://ngrok.com/docs/traffic-policy/actions/forward-internal/#examples
1# policy.yaml2# Host-based and header-based dynamic forwarding to internal endpoints via forward-internal action3on_http_request:4 - expressions:5 - "req.host == 'api.example.com'"6 actions:7 - type: forward-internal8 config: { url: https://api.internal }9 - expressions:10 - "getReqHeader('X-Tenant') != ''"11 actions:12 - type: forward-internal13 config: { url: https://tenant.internal }Read the Docs: https://ngrok.com/docs/universal-gateway/examples/multiplex/
1# policy.yaml2on_http_request:3 - actions:4 - type: forward-internal5 config:6 url: https://${req.host.split(".$NGROK_DOMAIN")[0]}.internalRead the Docs: https://ngrok.com/docs/traffic-policy/actions/rate-limit/
1# policy.yaml2# 10 requests per 60s window per client IP -> 429 on limit3on_http_request:4 - actions:5 - type: rate-limit6 config:7 name: per-ip-60s8 algorithm: sliding_window9 capacity: 1010 rate: "60s"11 bucket_key:12 - conn.client_ipRead the Docs: https://ngrok.com/docs/traffic-policy/examples/block-unwanted-requests/#how-do-i-deny-traffic-from-bots-and-crawlers-with-a-robotstxt
1# policy.yaml2# Send a robots.txt denying crawlers3on_http_request:4 - expressions:5 - "req.path == '/robots.txt'"6 actions:7 - type: custom-response8 config:9 status_code: 20010 headers:11 Content-Type: "text/plain"12 body: |13 User-agent: *14 Disallow: /1# policy.yaml2# Deny common bot/AI user agents3on_http_request:4 - expressions:5 - "req.user_agent.raw.matches('(?i)(gptbot|chatgpt-user|ccbot|bingbot|googlebot)')"6 actions:7 - type: deny1# policy.yaml2# Also add X-Robots-Tag to all responses3on_http_response:4 - actions:5 - type: add-headers6 config:7 headers:8 X-Robots-Tag: "noindex, nofollow, noai, noimageai"Read the Docs: https://ngrok.com/docs/traffic-policy/actions/add-headers/
1# Common security headers2ngrok http 8080 \3 --request-header-add "X-Frame-Options: DENY" \4 --response-header-add "Referrer-Policy: no-referrer"1# policy.yaml2# Add headers on request/response3on_http_request:4 - actions:5 - type: add-headers6 config:7 headers:8 X-Frame-Options: "DENY"9on_http_response:10 - actions:11 - type: add-headers12 config:13 headers:14 Referrer-Policy: "no-referrer"Read the Docs: https://ngrok.com/docs/traffic-policy/actions/restrict-ips/
1# Allow only 203.0.113.0/24; deny others2ngrok http 8080 --cidr-allow 203.0.113.0/243 4# Or explicitly deny CIDRs5ngrok http 8080 --cidr-deny 0.0.0.0/0Read the Docs: https://ngrok.com/docs/traffic-policy/actions/owasp-crs-response/
1# policy.yaml2# Apply OWASP Core Rule Set on requests/responses3on_http_request:4 - actions:5 - type: owasp-crs-request6on_http_response:7 - actions:8 - type: owasp-crs-responseurl1# Choose a URL instead of random assignment2ngrok http 8080 --url https://baz.ngrok.devtraffic-policy-file1# Manipulate traffic to your endpoint with a traffic policy file2ngrok http 8080 --url https://baz.ngrok.dev --traffic-policy-file policy.yamltraffic-policy-url1# Manipulate traffic to your endpoint with a traffic policy URL2ngrok http 8080 --url https://baz.ngrok.dev policy --traffic-policy-url https://example.com/policy.ymlpooling-enabled1# Load Balance (different ports)2ngrok http 8080 --url https://api.example.com --pooling-enabled3ngrok http 8081 --url https://api.example.com --pooling-enabledThe first iteration of the ngrok cheat sheet was created by Keith Casey, who served on the Product/GTM Team at ngrok.