UNPKG

2.89 kBMarkdownView Raw
1# localtunnel [![Build Status](https://travis-ci.org/defunctzombie/localtunnel.png?branch=master)](https://travis-ci.org/defunctzombie/localtunnel) #
2
3localtunnel exposes your localhost to the world for easy testing and sharing! No need to mess with DNS or deploy just to have others test out your changes.
4
5Great for working with browser testing tools like browserling or external api callback services like twilio which require a public url for callbacks.
6
7## installation ##
8
9```
10npm install -g localtunnel
11```
12
13This will install the localtunnel module globally and add the 'lt' client cli tool to your PATH.
14
15## use ##
16
17Assuming your local server is running on port 8000, just use the ```lt``` command to start the tunnel.
18
19```
20lt --port 8000
21```
22
23Thats it! It will connect to the tunnel server, setup the tunnel, and tell you what url to use for your testing. This url will remain active for the duration of your session; so feel free to share it with others for happy fun time!
24
25You can restart your local server all you want, ```lt``` is smart enough to detect this and reconnect once it is back.
26
27### arguments
28
29Below are some common arguments. See `lt --help` for additional arguments
30
31* `--subdomain` request a named subdomain on the localtunnel server (default is random characters)
32* `--local-host` proxy to a hostname other than localhost
33
34## API ##
35
36The localtunnel client is also usable through an API (for test integration, automation, etc)
37
38### localtunnel(port [,opts], fn)
39
40Creates a new localtunnel to the specified local `port`. `fn` will be called once you have been assigned a public localtunnel url. `opts` can be used to request a specific `subdomain`.
41
42```javascript
43var localtunnel = require('localtunnel');
44
45var tunnel = localtunnel(port, function(err, tunnel) {
46 if (err) ...
47
48 // the assigned public url for your tunnel
49 // i.e. https://abcdefgjhij.localtunnel.me
50 tunnel.url;
51});
52
53tunnel.on('close', function() {
54 // tunnels are closed
55});
56```
57
58### opts
59
60* `subdomain` A *string* value requesting a specific subdomain on the proxy server. **Note** You may not actually receive this name depending on availablily.
61* `local_host` Proxy to this hostname instead of `localhost`. This will also cause the `Host` header to be re-written to this value in proxied requests.
62
63### Tunnel
64
65The `tunnel` instance returned to your callback emits the following events
66
67|event|args|description|
68|----|----|----|
69|error|err|fires when an error happens on the tunnel|
70|close||fires when the tunnel has closed|
71
72The `tunnel instance has the following methods
73
74|method|args|description|
75|----|----|----|
76|close||close the tunnel|
77
78## other clients ##
79
80Clients in other languages
81
82*go* [gotunnelme](https://github.com/NoahShen/gotunnelme)
83
84## server ##
85
86See defunctzombie/localtunnel-server for details on the server that powers localtunnel.
87
88## License ##
89MIT