npm install ngrokconst ngrok = ;const url = await ngrok;
npm install ngrok -gngrok http 8080
This module uses node>=8.3.0 with async-await. For callback-based version use 2.3.0
You can create basic http-https-tcp tunnel without authtoken. For custom subdomains and more you should obtain authtoken by signing up at ngrok.com. Once you set it, it's stored in ngrok config and used for all tunnels. Few ways:
await ngrok;await ngrok;
const url = await ngrok; // ->const url = await ngrok; // ->const url = await ngrok; // tcp://0.tcp.ngrok.io:48590const url = await ngrok;
const url = await ngrok;
name, inspect, host_header, bind_tls, hostname, crt, key, client_cas, remote_addr - read here
Note on regions: region used in first tunnel will be used for all next tunnels too.
The ngrok and all tunnels will be killed when node process is done. To stop the tunnels use
await ngrok; // stops oneawait ngrok; // stops allawait ngrok; // kills ngrok process
Note on http tunnels: by default bind_tls is true, so whenever you use http proto two tunnels are created - http and https. If you disconnect https tunnel, http tunnel remains open. You might want to close them both by passing http-version url, or simply by disconnecting all in one go
You can use ngrok's configurations files, and just pass
name option when making a tunnel. Configuration files allow to store tunnel options. Ngrok looks for them here:
OS X /Users/example/.ngrok2/ngrok.yml Linux /home/example/.ngrok2/ngrok.yml Windows C:\Users\example\.ngrok2\ngrok.yml
You can specify a custom
configPath when making a tunnel.
When tunnel is established you can use the ngrok interface http://127.0.0.1:4040 to inspect the webhooks done via ngrok. Same url hosts internal client api. You can get it as wrapped request and manage tunnels yourself.
const url = await ngrok;const api = ngrok;const tunnels = await api;
npm install downloads ngrok binary for your platform from official ngrok hosting. To host binaries yourself set NGROK_CDN_URL env var before installing ngrok. To force specific platform set NGROK_ARCH, eg NGROK_ARCH=freebsdia32
First time you create tunnel ngrok process is spawned and runs until you disconnect or when parent process killed. All further tunnels are created or stopped by using internal ngrok api which usually runs on http://127.0.0.1:4040
git update-index --assume-unchanged bin/ngrok to not override ngrok stub in your pr. Unfortunately it can't be gitignored.
Test suite covers basics usage without authtoken, as well as features available for free and paid authtokens. You can supply your own tokens into env vars, otherwise warning given and some specs are ignored (locally and in PR builds). Travis supplies real tokens to master branch and runs all specs always.