node package manager

ngrok

node wrapper for ngrok

ngrok

Ngrok exposes your localhost to the web. https://ngrok.com/

usage

var ngrok = require('ngrok');
ngrok.connect(function (err, url) {});
 
or
 
npm install ngrok -g
ngrok http 8080

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:

ngrok.authtoken(token, function(err, token) {});
ngrok.connect({authtoken: token, ...}, function (err, url) {});
ngrok authtoken <token>
var ngrok = require('ngrok');
 
ngrok.connect(function (errurl) {}); // https://757c1652.ngrok.io -> http://localhost:80 
ngrok.connect(9090, function (errurl) {}); // https://757c1652.ngrok.io -> http://localhost:9090 
ngrok.connect({proto: 'tcp', addr: 22}, function (errurl) {}); // tcp://0.tcp.ngrok.io:48590 
ngrok.connect(opts, function(errurl) {});
ngrok.connect({
proto: 'http', // http|tcp|tls 
addr: 8080, // port or network address 
auth: 'user:pwd', // http basic authentication for tunnel 
subdomain: 'alex', // reserved tunnel name https://alex.ngrok.io, 
authtoken: '12345' // your authtoken from ngrok.com 
}, function (errurl) {});

Other options: name, inspect, host_header, bind_tls, hostname, crt, key, client_cas, remote_addr - read here

The ngrok and all tunnels will be killed when node process is done. To stop the tunnels use

ngrok.disconnect(url); // stops one 
ngrok.disconnect(); // stops all 
ngrok.kill(); // kills ngrok process 

Also you can use ngrok as an event emitter, it fires "connect", "disconnect" and "error" events

ngrok.once('connect', function (url) {};
ngrok.connect(port);

You can use ngrok's configurations files, then just pass name option when making a tunnel. Configuration files allow to specify more options, eg ngrok region you want to use.

OS X /Users/example/.ngrok2/ngrok.yml
Linux /home/example/.ngrok2/ngrok.yml
Windows C:\Users\example\.ngrok2\ngrok.yml

When tunnel is established you can use the ngrok interface http://127.0.0.1:4040 to inspect the webhooks done via ngrok.

npm install downloads ngrok binaries for you platform and puts them into bin folder. You can host binaries yourself and set NGROK_CDN_URL env var before installing ngrok.

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

Please run git update-index --assume-unchanged bin/ngrok to not override ngrok stub in your pr. Unfortunately it can't be gitignored.