Code Monkey home page Code Monkey logo

server's Introduction

localtunnel-server

Build Status

localtunnel 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.

This repo is the server component. If you are just looking for the CLI localtunnel app, see (https://github.com/localtunnel/localtunnel).

overview

The default localtunnel client connects to the localtunnel.me server. You can, however, easily set up and run your own server. In order to run your own localtunnel server you must ensure that your server can meet the following requirements:

  • You can set up DNS entries for your domain.tld and *.domain.tld (or sub.domain.tld and *.sub.domain.tld).
  • The server can accept incoming TCP connections for any non-root TCP port (i.e. ports over 1000).

The above are important as the client will ask the server for a subdomain under a particular domain. The server will listen on any OS-assigned TCP port for client connections.

setup

# pick a place where the files will live
git clone git://github.com/defunctzombie/localtunnel-server.git
cd localtunnel-server
npm install

# server set to run on port 1234
bin/server --port 1234

The localtunnel server is now running and waiting for client requests on port 1234. You will most likely want to set up a reverse proxy to listen on port 80 (or start localtunnel on port 80 directly).

NOTE By default, localtunnel will use subdomains for clients, if you plan to host your localtunnel server itself on a subdomain you will need to use the --domain option and specify the domain name behind which you are hosting localtunnel. (i.e. my-localtunnel-server.example.com)

use your server

You can now use your domain with the --host flag for the lt client.

lt --host http://sub.example.tld:1234 --port 9000

You will be assigned a URL similar to heavy-puma-9.sub.example.com:1234.

If your server is acting as a reverse proxy (i.e. nginx) and is able to listen on port 80, then you do not need the :1234 part of the hostname for the lt client.

REST API

POST /api/tunnels

Create a new tunnel. A LocalTunnel client posts to this enpoint to request a new tunnel with a specific name or a randomly assigned name.

GET /api/status

General server information.

Deploy

You can deploy your own localtunnel server using the prebuilt docker image.

Note This assumes that you have a proxy in front of the server to handle the http(s) requests and forward them to the localtunnel server on port 3000. You can use our localtunnel-nginx to accomplish this.

If you do not want ssl support for your own tunnel (not recommended), then you can just run the below with --port 80 instead.

docker run -d \
    --restart always \
    --name localtunnel \
    --net host \
    defunctzombie/localtunnel-server:latest --port 3000

server's People

Contributors

ajay-gandhi avatar bryanhelmig avatar defunctzombie avatar fiveyellowmice avatar infn8 avatar jonasfj avatar lukehorvat avatar ppeeou avatar readmecritic avatar scandinaro avatar sidtehkid avatar sidthekidder avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

server's Issues

subdomain lookup fails when running on localhost

the server uses tldjs to extract subdomains. but tldjs doesn't consider localhost a valid domain; so subdomain lookup fails and proxy calls fallback to the /www page

Looks like we need to add the following line atop server.js

tldjs.validHosts = ['localhost'];

let me know if you have any concerns before I send a pull request.

localtunnel server returned an error...

/usr/local/lib/node_modules/localtunnel/bin/client:48
        throw err;
        ^

Error: localtunnel server returned an error, please try again
    at Request._callback (/usr/local/lib/node_modules/localtunnel/lib/Tunnel.js:53:27)
    at Request.self.callback (/usr/local/lib/node_modules/localtunnel/node_modules/request/request.js:198:22)
    at emitTwo (events.js:87:13)
    at Request.emit (events.js:172:7)
    at Request.<anonymous> (/usr/local/lib/node_modules/localtunnel/node_modules/request/request.js:1082:10)
    at emitOne (events.js:82:20)
    at Request.emit (events.js:169:7)
    at IncomingMessage.<anonymous> (/usr/local/lib/node_modules/localtunnel/node_modules/request/request.js:1009:12)
    at emitNone (events.js:72:20)
    at IncomingMessage.emit (events.js:166:7)

Error connecting

I'm trying to setup my own localtunnel server and can't seem to get it working. I'm pretty sure I have both ends setup correctly, and I do get back an address when I connect with the lt client, but after a few seconds the connection drops with

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: connect ETIMEDOUT
    at errnoException (net.js:901:11)
    at Object.afterConnect [as oncomplete] (net.js:892:19)

I also see on my server HTML page that the tunnel count goes to 1, then back to 0 when the connection drops.

Any ideas?

Request problem

We are using localtunnel to expose some local REST Api to the world. We installed localtunnel to our web server but looks like something is wrong. Tunnel works in 1 case out of 100. We get error

no more client, queue callback

and can't get response from the local server.
Do I miss something?

Server starts like:

bin/server --port 1234 //display your index.html

Localhost client:

lt --host http://*myhost*:1234 --port 80 --open

and i get url

your url is: http://smcowmlcpe.*myhost*:123

localtunnel server returned an error, please try again

I know about #31 #50 but I'm not using subdomains
I'm getting this error since this morning, nothing else changed, and I'm only doing:
lt --port 3000

/Users/nzylber1/.nvm/versions/node/v6.9.5/lib/node_modules/localtunnel/bin/client:48
        throw err;
        ^

Error: localtunnel server returned an error, please try again
    at Request._callback (/Users/nzylber1/.nvm/versions/node/v6.9.5/lib/node_modules/localtunnel/lib/Tunnel.js:53:27)
    at Request.self.callback (/Users/nzylber1/.nvm/versions/node/v6.9.5/lib/node_modules/localtunnel/node_modules/request/request.js:186:22)
    at emitTwo (events.js:106:13)
    at Request.emit (events.js:191:7)
    at Request.<anonymous> (/Users/nzylber1/.nvm/versions/node/v6.9.5/lib/node_modules/localtunnel/node_modules/request/request.js:1081:10)
    at emitOne (events.js:96:13)
    at Request.emit (events.js:188:7)
    at IncomingMessage.<anonymous> (/Users/nzylber1/.nvm/versions/node/v6.9.5/lib/node_modules/localtunnel/node_modules/request/request.js:1001:12)
    at IncomingMessage.g (events.js:291:16)
    at emitNone (events.js:91:20)

Unexpected token

bin/server --port 5000

/home/user/localtunnel-server/bin/server:36
server.listen(argv.port, () => {
^
SyntaxError: Unexpected token )
at Module._compile (module.js:439:25)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:906:3

Leaking Sockets

Looks like the server is leaking sockets.

My server gets 'clients' connecting to new subdomains frequently; the setup is probably similar to localtunnel.me with thousands of client connections over time.

After a while; my system refuses to allocate anymore sockets to the process.

I haven't found the leak yet;

I made small modification to my fork; proxy.js:118:19 is 'client_server.listen'


error: listen EMFILE 0.0.0.0
at Object.exports._errnoException (util.js:855:11)
at exports._exceptionWithHostPort (util.js:878:20)
at Server._listen2 (net.js:1224:19)
at listen (net.js:1273:10)
at Server.listen (net.js:1328:5)
at new Proxy (/home/nodejs/taskmill/cloud/www/node_modules/localtunnel-server/proxy.js:118:19)
at Proxy (/home/nodejs/taskmill/cloud/www/node_modules/localtunnel-server/proxy.js:9:16)
at new_client (/home/nodejs/taskmill/cloud/www/node_modules/localtunnel-server/server.js:169:18)
at /home/nodejs/taskmill/cloud/www/node_modules/localtunnel-server/server.js:239:9
at Layer.handle as handle_request
at next (/home/nodejs/taskmill/cloud/www/node_modules/express/lib/router/route.js:131:13)
at Route.dispatch (/home/nodejs/taskmill/cloud/www/node_modules/express/lib/router/route.js:112:3)
at Layer.handle as handle_request
at /home/nodejs/taskmill/cloud/www/node_modules/express/lib/router/index.js:277:22
at param (/home/nodejs/taskmill/cloud/www/node_modules/express/lib/router/index.js:349:14)
at param (/home/nodejs/taskmill/cloud/www/node_modules/express/lib/router/index.js:365:14)
at Function.process_params (/home/nodejs/taskmill/cloud/www/node_modules/express/lib/router/index.js:410:3)
at next (/home/nodejs/taskmill/cloud/www/node_modules/express/lib/router/index.js:271:10)
at expressInit (/home/nodejs/taskmill/cloud/www/node_modules/express/lib/middleware/init.js:33:5)
at Layer.handle as handle_request
at trim_prefix (/home/nodejs/taskmill/cloud/www/node_modules/express/lib/router/index.js:312:13)
at /home/nodejs/taskmill/cloud/www/node_modules/express/lib/router/index.js:280:7
at Function.process_params (/home/nodejs/taskmill/cloud/www/node_modules/express/lib/router/index.js:330:12)
at next (/home/nodejs/taskmill/cloud/www/node_modules/express/lib/router/index.js:271:10)
at query (/home/nodejs/taskmill/cloud/www/node_modules/express/lib/middleware/query.js:49:5)
at Layer.handle as handle_request
at trim_prefix (/home/nodejs/taskmill/cloud/www/node_modules/express/lib/router/index.js:312:13)
at /home/nodejs/taskmill/cloud/www/node_modules/express/lib/router/index.js:280:7
at Function.process_params (/home/nodejs/taskmill/cloud/www/node_modules/express/lib/router/index.js:330:12)
at next (/home/nodejs/taskmill/cloud/www/node_modules/express/lib/router/index.js:271:10)
at Function.handle (/home/nodejs/taskmill/cloud/www/node_modules/express/lib/router/index.js:176:3)
at EventEmitter.handle (/home/nodejs/taskmill/cloud/www/node_modules/express/lib/application.js:173:10)
at app (/home/nodejs/taskmill/cloud/www/node_modules/express/lib/express.js:38:9)
at Server. (/home/nodejs/taskmill/cloud/www/node_modules/localtunnel-server/server.js:278:9)

Error: Invalid protocol

I have LT-server setup on my VPS. ubuntu 14.04. Basic LAMP and LT-Server.

I can not connect from a remote client or on the same server using localhost. I get this error on the localhost:

root@ipvr:/etc# lt --host "localhost:4545" --port 567

/usr/local/lib/node_modules/localtunnel/node_modules/request/main.js:304
 if (!self.httpModule) throw new Error("Invalid protocol")
                             ^
Error: Invalid protocol
at Request.init (/usr/local/lib/node_modules/localtunnel/node_modules/request/main.js:304:31)
at new Request (/usr/local/lib/node_modules/localtunnel/node_modules/request/main.js:105:8)
at request (/usr/local/lib/node_modules/localtunnel/node_modules/request/main.js:968:11)
at get_url (/usr/local/lib/node_modules/localtunnel/client.js:197:9)
at Tunnel._init (/usr/local/lib/node_modules/localtunnel/client.js:222:7)
at Tunnel.open (/usr/local/lib/node_modules/localtunnel/client.js:281:10)
at localtunnel (/usr/local/lib/node_modules/localtunnel/client.js:310:12)
at Object.<anonymous> (/usr/local/lib/node_modules/localtunnel/bin/client:40:1)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)

The server is located at sub.example.com. So Clients would be at 1234.sub.example.com. Im not sure if this would cause a problem. I changed the hosts file as suggested by another issue with no luck

Subdomain character limit too low

The current character limit prohibits me from using anything more than my computer's name (e.g. brandon-macbook-pro) as a subdomain. I'd like it to be my computer's full hostname plus my project and company name (i.e. brandon-macbook-pro.local.api.acme). The domain names specification permits subdomains 63 characters in length or less. It would be awesome if we could get the limit changed from 20 to 63.

port number in README.md is error

Setup section has a error:

"// server set to run on port 1234
bin/server --port 1324"

--->

"// server set to run on port 1234
bin/server --port 1234"

Is this supply any tcp connect?

hi there.
if i have a tcp server that not in http built, and run localtunnel on it, may I connect to it?
be careful, not http.

tunnel server is offline

Hi guys,

when running a client via lt --host http://sub.example.tld:1234 --port 9000
after running server by node server --port 1234
I got this error:
tunnel server offline: getaddrinfo ENOTFOUND sub.example.tld sub.example.tld:1234, retry 1s
I dont get any msj showing that the server is running on port 1234.

thanks in advance.

static files not fully loaded

I posted an issue on the client side, but as i believe the error comes form the server somehow i am posting it here too.
Also i have seen some other issues relating to the same error, but no definitive answer has been provided.
The problem is my react-webpack app bundle a mid-sized vendor.js file (270kb) that has to be loaded by my single page application. But strangely, the file almost never seems to load completely. When i use my browser to access it i can see that it gets truncated in the middle. The browser seems to be loading but nothing more pass through, at least not all the time (sometimes it manage to load, maybe ith help of the cache)
Note that it seems to fail always at the same points
Any idea to fix the behavior ?

(111: Connection refused) while connecting to upstream

We are trying to setup another server so that others can still use your great package. Im sure your servers are flooded. We were trying to teach a group of 75 students tonight at 5pm how to build bots, but the local tunnel servers can be spotty so we wanted to setup our own server.

We purchased a wildcard ssl cert and all is well, but for some reason we keep getting these errors from the server

root@localtunnel-1:/home/patrick# lt -h "https://bot-tunnel.com" -p 3000
/usr/local/lib/node_modules/localtunnel/bin/client:48
        throw err;
        ^

Error: localtunnel server returned an error, please try again
    at Request._callback (/usr/local/lib/node_modules/localtunnel/lib/Tunnel.js:53:27)
    at Request.self.callback (/usr/local/lib/node_modules/localtunnel/node_modules/request/request.js:186:22)
    at emitTwo (events.js:106:13)
    at Request.emit (events.js:191:7)
    at Request.<anonymous> (/usr/local/lib/node_modules/localtunnel/node_modules/request/request.js:1081:10)
    at emitOne (events.js:96:13)
    at Request.emit (events.js:188:7)
    at IncomingMessage.<anonymous> (/usr/local/lib/node_modules/localtunnel/node_modules/request/request.js:1001:12)
    at IncomingMessage.g (events.js:291:16)
    at emitNone (events.js:91:20)
root@localtunnel-1:/home/patrick# docker logs -f 62b574c59565
2016/12/15 16:11:55 [error] 5#5: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 76.98.113.158, server: , request: "GET /?new HTTP/1.1", upstream: "
http://127.0.0.1:3000/?new", host: "bot-tunnel.com"
2016/12/15 16:12:15 [error] 5#5: *3 connect() failed (111: Connection refused) while connecting to upstream, client: 76.98.113.158, server: , request: "GET /?new HTTP/1.1", upstream: "
http://127.0.0.1:3000/?new", host: "bot-tunnel.com"
2016/12/15 16:12:34 [error] 5#5: *7 connect() failed (111: Connection refused) while connecting to upstream, client: 104.131.9.173, server: , request: "HEAD / HTTP/1.1", upstream: "htt
p://127.0.0.1:3000/", host: "bot-tunnel.com"
2016/12/15 16:13:22 [error] 5#5: *9 connect() failed (111: Connection refused) while connecting to upstream, client: 76.98.113.158, server: , request: "GET /?new HTTP/1.1", upstream: "
http://127.0.0.1:3000/?new", host: "bot-tunnel.com"
2016/12/15 16:13:28 [error] 5#5: *11 connect() failed (111: Connection refused) while connecting to upstream, client: 76.98.113.158, server: , request: "GET /?new HTTP/1.1", upstream: 
"http://127.0.0.1:3000/?new", host: "bot-tunnel.com"
2016/12/15 16:15:03 [error] 5#5: *15 connect() failed (111: Connection refused) while connecting to upstream, client: 104.131.9.173, server: , request: "HEAD / HTTP/1.1", upstream: "ht
tp://127.0.0.1:3000/", host: "bot-tunnel.com"
2016/12/15 16:16:46 [error] 5#5: *19 connect() failed (111: Connection refused) while connecting to upstream, client: 104.131.9.173, server: , request: "HEAD / HTTP/1.1", upstream: "ht
tp://127.0.0.1:3000/", host: "bot-tunnel.com"
2016/12/15 16:17:43 [error] 5#5: *23 connect() failed (111: Connection refused) while connecting to upstream, client: 104.131.9.173, server: , request: "HEAD / HTTP/1.1", upstream: "ht
tp://127.0.0.1:3000/", host: "bot-tunnel.com"
2016/12/15 16:17:59 [error] 5#5: *25 connect() failed (111: Connection refused) while connecting to upstream, client: 193.111.60.5, server: , request: "GET / HTTP/2.0", upstream: "http
://127.0.0.1:3000/", host: "bot-tunnel.com"
2016/12/15 16:17:59 [error] 5#5: *25 connect() failed (111: Connection refused) while connecting to upstream, client: 193.111.60.5, server: , request: "GET /favicon.ico HTTP/2.0", upst
ream: "http://127.0.0.1:3000/favicon.ico", host: "bot-tunnel.com"
2016/12/15 16:18:00 [error] 5#5: *28 connect() failed (111: Connection refused) while connecting to upstream, client: 193.111.60.5, server: , request: "GET /favicon.ico HTTP/2.0", upst
ream: "http://127.0.0.1:3000/favicon.ico", host: "bot-tunnel.com"
2016/12/15 16:22:51 [error] 5#5: *30 connect() failed (111: Connection refused) while connecting to upstream, client: 205.251.129.126, server: , request: "GET / HTTP/2.0", upstream: "h
ttp://127.0.0.1:3000/", host: "bot-tunnel.com"
2016/12/15 16:22:51 [error] 5#5: *30 connect() failed (111: Connection refused) while connecting to upstream, client: 205.251.129.126, server: , request: "GET /favicon.ico HTTP/2.0", u
pstream: "http://127.0.0.1:3000/favicon.ico", host: "bot-tunnel.com"
2016/12/15 16:22:52 [error] 5#5: *30 connect() failed (111: Connection refused) while connecting to upstream, client: 205.251.129.126, server: , request: "GET /favicon.ico HTTP/2.0", u
pstream: "http://127.0.0.1:3000/favicon.ico", host: "bot-tunnel.com"
2016/12/15 16:24:45 [error] 5#5: *34 connect() failed (111: Connection refused) while connecting to upstream, client: 76.98.113.158, server: , request: "GET /?new HTTP/1.1", upstream: 
"http://127.0.0.1:3000/?new", host: "bot-tunnel.com"
2016/12/15 16:27:04 [error] 5#5: *36 connect() failed (111: Connection refused) while connecting to upstream, client: 76.99.69.216, server: , request: "GET / HTTP/2.0", upstream: "http
://127.0.0.1:3000/", host: "bot-tunnel.com", referrer: "https://support.namecheap.com/visitor/index.php?/LiveChat/Chat/Start"
2016/12/15 16:27:04 [error] 5#5: *36 connect() failed (111: Connection refused) while connecting to upstream, client: 76.99.69.216, server: , request: "GET /favicon.ico HTTP/2.0", upst
ream: "http://127.0.0.1:3000/favicon.ico", host: "bot-tunnel.com", referrer: "https://bot-tunnel.com/"
2016/12/15 16:30:07 [error] 5#5: *39 connect() failed (111: Connection refused) while connecting to upstream, client: 104.197.143.216, server: , request: "GET /?new HTTP/1.1", upstream
: "http://127.0.0.1:3000/?new", host: "bot-tunnel.com"
2016/12/15 16:30:13 [error] 5#5: *41 connect() failed (111: Connection refused) while connecting to upstream, client: 104.197.143.216, server: , request: "GET /?new HTTP/1.1", upstream
: "http://127.0.0.1:3000/?new", host: "bot-tunnel.com"
tion refused) while connecting to upstream, client: 104.197.143.216, server: , request: "GET /?new HTTP/1.1", upstream
: "http://127.0.0.1:3000/?new", host: "bot-tunnel.com"

"--local-host" option not working with "--host"

I'm running the current "master" localtunnel server, but when i run in my machine this command:

lt --port 80 --subdomain example --local-host example.dev --host hello.com

The option "--local-host" is somehow overwritten by "localhost".

When I use this command:

lt --port 80 --subdomain example --local-host example.dev

The option "--local-host" work very well, that's why I'm assuming the problem is on the localtunnel server.

Unknown Error - 502 status code from client

I've read through issue #8 and I have realized that I am facing a similar problem even though I am using the lt syntax as per your instruction.
i.e. I am running the server at port 2530 by the following
DEBUG=localtunnel* ./server --port 2530
and I run the client by the following
lt --host "http://sub.example.org:2530" --port 2350 --subdomain testreq
At the client end I've added a long stack traces lib (https://github.com/mattinsler/longjohn) and the error I get there is the following:

Error: localtunnel server returned an error, please try again
    at Request._callback (/usr/lib/node_modules/localtunnel/client.js:215:27)
    at self.callback (/usr/lib/node_modules/localtunnel/node_modules/request/main.js:122:22)
    at EventEmitter.emit (events.js:98:17)
    at Request.<anonymous> (/usr/lib/node_modules/localtunnel/node_modules/request/main.js:655:16)
    at EventEmitter.emit (events.js:117:20)
    at IncomingMessage.<anonymous> (/usr/lib/node_modules/localtunnel/node_modules/request/main.js:617:14)
    at EventEmitter.emit (events.js:117:20)
---------------------------------------------
    at Request.init (/usr/lib/node_modules/localtunnel/node_modules/request/main.js:126:10)
    at new Request (/usr/lib/node_modules/localtunnel/node_modules/request/main.js:105:8)
    at request (/usr/lib/node_modules/localtunnel/node_modules/request/main.js:968:11)
    at get_url (/usr/lib/node_modules/localtunnel/client.js:204:9)
    at Tunnel._init (/usr/lib/node_modules/localtunnel/client.js:232:7)
    at Tunnel.open (/usr/lib/node_modules/localtunnel/client.js:291:10)
    at localtunnel (/usr/lib/node_modules/localtunnel/client.js:320:12)
    at Object.<anonymous> (/usr/lib/node_modules/localtunnel/bin/client:40:1)

while, at the server, all I get is the following:

localtunnel server listening on port: 2530 +0ms
  localtunnel-server request /testreq +0ms

Any thoughts?

Update:
After changing the hostname and DNS settings by removing the subdomain(e.g. change http://sub.example.com to http://example.com) I finally got it to work!

Bad Gateway Response

I have setup Localtunnel, and have successfully received the sub domain, however any attempt to test my api with the url results in a "502 Bad Gateway" response.
Is there something i didn't set up correct? I can confirm my localhost:5000 is working, and that is the port I provided.
Thanks

server actually not working for subdomains

I just checked the code, and contrary to whats written in the readme (You can set up DNS entries for your domain.tld and *.domain.tld (or sub.domain.tld and *.sub.domain.tld).)

I am not under the impression that the localtunnel server works for sub domains, since in the code, the server always checks for existance of a subdomain in the request, and if so, tries to associate a client session, thus failing all requests that try to do registration api status, etc. can someone confirm this behaviour?

headers aren't passed through by the server

The issue is with:

        var client_req = http.request(opt, function(client_res) {
            // should set headers here
            client_res.pipe(res);
            on_finished(client_res, function(err) {
                done();
            });
        });

we need to set the headers from the incoming request to the response

Nginx Config

What nginx config are you using? This is what I was using on my server, but was getting weird stuff going on in the maybe_bounce function with this. Maybe related to something not being passed from Nginx? (see #10)

# Tunnel Proxy
server {
    listen 80;
    server_name *.tunnel.example.com tunnel.example.com;

    location / {
        proxy_set_header    Host $http_host;        
        proxy_pass          http://127.0.0.1:1234;
        proxy_buffering     off;
    }
}

Enable on boot?

I've had it configured and running from
bin/server --port 1234

But how can I enable it to start from any other directory, say /

The local-tunnel doesn't start up if I run it like,
localtunnel-server/bin/server --port 1234

More of like, Unattended Server side

HTTPS

Is it possible to use https?

secret for connections

I have an issue where hosting localtunnel unprotected on the internet would cause issues with random people connecting to my server. how can I protect my localtunnel server with a password or certificate?

Server at localtunnel.me fails to detect occupied subdomains

First Invocation

$ lt -p 89 -s testing123
your url is: https://testing123.localtunnel.me

Second Invocation
(Started on the same machine, without terminating the first invocation.)

$ lt -p 90 -s testing123
your url is: https://testing123.localtunnel.me

The following also happens:

First Invocation

$ lt -p 89
your url is: https://inpvvzkfuo.localtunnel.me

Second Invocation

$ lt -p 90 -s inpvvzkfuo
your url is: https://inpvvzkfuo.localtunnel.me

As far as I can tell, visiting the conflicting domain delivers responses consistent with the first invocation.

Server binds to 0.0.0.0

Hi!

I noticed that the server binds to all adresses. It would be nice, when proxying the requests, to make it listen on localhost only (or even better, having it listen to a unix socket). Instead of having the option:

--port <number>

Could we have:

--listen <host:ip|unix-socket>

Cheers!

Server return 404 when trying to connect via websockets

So I tried to reverse DNS my WEBRTC server since Chrome now requires HTTPS to allow the user to use the site. Unfortunately, when attempting to connect via /webrtc, instead of forwarding my websocket to the server, the site just returns 404, .localtunnel.me/webrtc not found. Does this software support websocket connections? If so, what am I doing wrong? Do I just have something misconfigured or the is problem with the actual functionality of this server?

I was using Chromium's Webrtc Server through webrtc_ros for further information.

Can't make it work

Hi, here's what I did:

  • setup *.localtunnel.function.fr CNAME function.fr.
  • ping localtunnel.function.fr works
  • ping dsadsa.localtunnel.function.fr works
  • using lt --host http://localtunnel.function.fr --port 8080 fails

It fails because maybe_bounce() does not find any client and so return true; and respond 502 to client.

I wonder how this could work, I know it does, but can you help on this? Everything is up and running if you want to test.

Also, I am setting this up because I get "Not running" errors most of the time while testing with zuul/saucelabs.

gyp ERR! configure error

F:\lt server\localtunnel-server\node_modules\utf-8-validate>if not defined npm_config_node_gyp (node "E:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\....\node_modules\node-gyp\bin\node-gyp.js" rebuild ) else (node "" rebuild )
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\python.EXE", you can set the PYTHON env variable.
gyp ERR! stack at PythonFinder.failNoPython (E:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:483:19)
gyp ERR! stack at PythonFinder. (E:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:508:16)
gyp ERR! stack at E:\Program Files\nodejs\node_modules\npm\node_modules\graceful-fs\polyfills.js:284:29
gyp ERR! stack at FSReqWrap.oncomplete (fs.js:152:21)
gyp ERR! System Windows_NT 10.0.14393
gyp ERR! command "E:\Program Files\nodejs\node.exe" "E:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" "rebuild"
gyp ERR! cwd F:\lt server\localtunnel-server\node_modules\utf-8-validate
gyp ERR! node -v v8.1.2
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok

[email protected] install F:\lt server\localtunnel-server\node_modules\bufferutil
node-gyp rebuild

F:\lt server\localtunnel-server\node_modules\bufferutil>if not defined npm_config_node_gyp (node "E:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\....\node_modules\node-gyp\bin\node-gyp.js" rebuild ) else (node "" rebuild )
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\python.EXE", you can set the PYTHON env variable.
gyp ERR! stack at PythonFinder.failNoPython (E:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:483:19)
gyp ERR! stack at PythonFinder. (E:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:508:16)
gyp ERR! stack at E:\Program Files\nodejs\node_modules\npm\node_modules\graceful-fs\polyfills.js:284:29
gyp ERR! stack at FSReqWrap.oncomplete (fs.js:152:21)
gyp ERR! System Windows_NT 10.0.14393
gyp ERR! command "E:\Program Files\nodejs\node.exe" "E:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" "rebuild"
gyp ERR! cwd F:\lt server\localtunnel-server\node_modules\bufferutil
gyp ERR! node -v v8.1.2
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
npm notice created a lockfile as package-lock.json. You should commit this file.

added 215 packages in 43.349s

Docker friendly

To be able to Dockerify the server a few things seem required to be fixed:

  • Must not require connection of clients to a random port.
  • Should outputs errors and logs to stdout/stderr.
  • Should provide a README for the localtunnel-server Docker showing how to use it
  • Could change localtunnel-server Docker to run as non-privileged user (set USER)
  • lt client could be more descriptive when it fails (currently shows Error: localtunnel server returned an error, please try again with a stack trace and nothing more).

Crashing with connection refused when left idle

I absolutely love localtunnel! That being said, I've been encountering an issue where the client will just die and produce an error stack when left idle for a little while. (I have not timed this, but it always happens)

I can connect to the --subdomain I set when launching it just fine though until it dies.

Node version: 8.6.0

/usr/local/lib/node_modules/localtunnel/bin/client:58
        throw err;
        ^

Error: connection refused: localtunnel.me:41159 (check your firewall settings)
    at Socket.<anonymous> (/usr/local/lib/node_modules/localtunnel/lib/TunnelCluster.js:47:32)
    at emitOne (events.js:77:13)
    at Socket.emit (events.js:169:7)
    at emitErrorNT (net.js:1253:8)
    at doNTCallback2 (node.js:450:9)
    at process._tickCallback (node.js:364:17)

Is there something I can do to prevent this happening? Sometimes I'll have to run LT on my office desktop/scotch-box when I'm out with clients showing them current progress and whatnot.

Unknown Error - 502 status code from client, 200 from browser

I've read through issue #3, and enabled the debugging, but all i get in the console is

localtunnel server listening on port: 1300 +0ms

when I start the server, and

localtunnel-server request /?new +0ms

when i make a request from the client.

From the client, I run:

$ lt --host "http://dev.jshawl.com" --port 1300

And it returns Error: localtunnel server returned an error, please try again.

This seems to be coming from line 210 of client.js - https://github.com/defunctzombie/localtunnel/blob/7b1fef982fecc2ce24ea9a95eb5854483b072b79/client.js#L210

When I console.log the res.statusCode, it gives a 502 (bad gateway), but I've confirmed (I think) that nginx is set up correctly - http://dev.jshawl.com/

Is there something else I should try/console.log/test to get this working?

Mysterious unhandled error event

Hello,
I got interested in trying out localtunnel but everytime i run it with my local servers i get

events.js:72
throw er; // Unhandled 'error' event
^
Error: connection refused: localtunnel.me:40283 (check your firewall settings)

What don't i do right?

Setup Fail after npm install

Hi, I got the following error running bin/server --port 1234 after npm install

server.listen(argv.port, () => {
                          ^
SyntaxError: Unexpected token )
    at Module._compile (module.js:439:25)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at `node.js:902:3`

Does it related to babel runtime that could not resolve ES6? Could you please give some instructions to solve this? thanks a lot.

Server not closing connection if client shutdown

I noticed the server doesn't close the connection is client was forcefully shut down and i was wondering how could i implement a close client connection if connection is not active? that way preventing problem, for example if client is using a custom sub domain and tries to reconnect it won't be able to used the same custom sub domain cause the current connection is still open in the server side and the server will assign a random sub domain even if you specified to use an specific sub domain.

I also noticed that if you tried to reconnect to your previous connection using previous sub domain the server will crash giving you a [error] bookrc.js:8 read ECONNRESET
Any ideas on how to fix this issue?

Run multiple simultaneous tunnels that have stable public ports

If I need to expose a set of ports that need to work together, let's say ports 3000 and 4000 it would be nice to be able to configure it somehow, e.g.

tunnels:
  frontend:
    local_addr: localhost:3000
    remote_addr: elgalu.localtunnel.me:3000
  backend:
    local_addr: localhost:4000
    remote_addr: elgalu.localtunnel.me:4000

Also, would be any conflicts with fixed ports numbers? what if another user wants to use ports 3000 and 4000? even though it sets a different subdomain, if all resolve to the same IP and network interface there will be collisions right?

feature request: ssl encrypt the raw tcp tunnel

sorry to be a drag as i find this software very useful for browser testing on saucelabs, but after the initial handshake and request (which can be ssl protected by a reverse proxy on server), the client seems to be communicating with the server directly through dynamically created raw tcp sockets <proxy.js:line 24>.

this makes it unsuitable for any kind of saucelabs testing that involves sensitive data. there is another project, https://github.com/pghalliday/single-tls-tunnel, which does encrypt its tcp socket, but it seems to be broken and unmaintained.

a fix to encrypt the sockets is certainly a non-trivial matter, but its highly desirable, and hopefully someone will address it (sorry i'm just a whiner ;)

the README should also explain the mechanism a bit more so users aren't led to believe that a secure tunnel exists between the client and server, simply by setting up an nginx https reverse proxy (like i was :b)

Question: limit requests based on ip

Hi, this is more of a question rather than an an issue. Was wondering if its possible to block requests based on ip's coming from a request.To ensure that only registered as valid ip are processed for tunneling.

throw an error when connect to server

my lt version is 1.8.1,and node version is v0.10.41
localtunnel-server version is v0.8.0,and node version is v0.10.41
then

ubuntu@myserver:~/localtunnel-server/server$ ./bin/server --port 2333
  localtunnel server listening on port: 2333 +0ms

when i connect to the server

[www@localhost ~]$ lt --host http://tunnel.mydomain.com:2333 --port 8000

/home/www/.nvm/v0.11.8/lib/node_modules/localtunnel/bin/client:48
        throw err;
              ^
Error: localtunnel server returned an error, please try again
    at Request._callback (/home/www/.nvm/v0.11.8/lib/node_modules/localtunnel/lib/Tunnel.js:53:27)
    at Request.self.callback (/home/www/.nvm/v0.11.8/lib/node_modules/localtunnel/node_modules/request/request.js:198:22)
    at Request.EventEmitter.emit (events.js:106:17)
    at Request.<anonymous> (/home/www/.nvm/v0.11.8/lib/node_modules/localtunnel/node_modules/request/request.js:1082:10)
    at Request.EventEmitter.emit (events.js:125:20)
    at IncomingMessage.<anonymous> (/home/www/.nvm/v0.11.8/lib/node_modules/localtunnel/node_modules/request/request.js:1009:12)
    at IncomingMessage.EventEmitter.emit (events.js:125:20)
    at _stream_readable.js:896:16
    at process._tickCallback (node.js:311:11)

and the server side output:

  localtunnel-server request /?new +10s

anyone can help?

Database or Log?

Does the localtunnel server keep a list of active clients anywhere? I am not a JS devoloper at all really, I know enough to follow the existing code pretty well but I could never edit it. I looked arround and could not find anything.

I would like to manage clients on your software with keybox.

[QUESTION] Authencation?

Would it be possible to have some sort of authentication for clients? I am thinking of using this for servers I manage to keep a service port open with my server. The only problem is I dont want just anyone to be able to connect. I would like to just have a passcode to be included on the client end to connect.

Is this possible with the current setup?

new connection on port: banana

I was having issues setting it up on my server, so I started testing locally and got similar results.

I cloned localtunnel-server locally and ran this command:

env DEBUG="localtunnel*" bin/server --port 1234

Then I ran this command in another shell:

 lt --host http://localhost:1234 --port 8000 --subdomain banana

(I have a Laravel app running on port 8000 and lt --port 8000 works going through localtunnel.me.)

The client says my url is http://banana.localhost:1234 and if I go there (I added banana.localhost to my hosts), then I get the main index of what's at localtunnel.me.

The server debug output says a bunch of stuff about connection to port "banana" when I connect the client.

  localtunnel server listening on port: 1234 +0ms
  localtunnel-server request /banana +0ms
  localtunnel-server making new client with id banana +11ms
  localtunnel-server tcp server listening on port: 50814 +1ms
  localtunnel-server new connection on port: banana +12ms
  localtunnel-server new connection on port: banana +0ms
  localtunnel-server new connection on port: banana +1ms
  localtunnel-server new connection on port: banana +0ms
  localtunnel-server new connection on port: banana +0ms
  localtunnel-server new connection on port: banana +1ms
  localtunnel-server new connection on port: banana +0ms
  localtunnel-server new connection on port: banana +0ms
  localtunnel-server new connection on port: banana +0ms
  localtunnel-server new connection on port: banana +1ms
  localtunnel-server request / +8s
  localtunnel-server request /static/541f20/css/style.css +496ms
  localtunnel-server request /static/99735c/css/grid.css +1ms
  localtunnel-server request /static/0f1bee/css/widgets.css +1ms
  localtunnel-server request /static/21e1e0/js/index.js +1ms
  localtunnel-server request /engine.io/?EIO=2&transport=websocket&sid=6RlMHqlk_JJVrx9UAAAA +216ms

This is more or less what was happening on my server, too, except I was having issues with the maybe_bounce function. If I forced it to return false, then my experience on the server is the same as that.

alternative to server?

Hello, This is rather a question than an issue.

I like and apprechiate the concept of this project very much. When you want to make a simple solution for many users and for general access, this is the way to go.

However, the requirements for the public server/gateway such as the permission for setting up DNS entries are not easy to meet. And I would like to have the server part as freely and easily deployable as possible.

I wonder it is possible to use a CGI/script on a public server rather than a service?

I can imagine using such a solution so that the one would start up the tunnel client by specifying the url to the CGI/script on the public server plus an identifier in addition to the local IP_address:port of the service to be made publicly available.

The script on the public server could act as a gateway between the web user and the server behind a firewall. It could be configured manually to create a given kind of a bi-directional pipe corresponding to a given identifier/service.

A request from a web user would be buffered on the public server. The type of the requested service would be identified by the identifier provided by the web user upon sending the request. The tunnel client behind the firewall would query the CGI/script regularly. If there is a request with a matching identifier waiting then a suitable pipe would be created and the web user could be connected with the service behind the firewall through the pipe on the public server and the tunnel client:

web user <=> pipe on public server manged by the CGI/script <=> tunnel client behind the firewall <=> service behind the firewall

For example a web server could be accessed as
http://public.service.com/myusername/tunnels.cgi?ID=my_files_in_office
The CGI/script would then redirect my browser to
http://public.service.com/myusername/tunnel_hgT543j
Where I could access my files.

Or for my zero client NoVNC solution the access url would be
http://public.service.com/myusername/tunnels.cgi?ID=office_pc

Please note that I am just a plain user who is wondering whether this can be done or not.

The advantage would be that no DNS setup is needed on the public server. The disadvantage is that each service should be configured separately on the public server by the account holder. But IMO this is not a big deal.

So I wonder if this is possible to implement. What do you think?

Limit open ports?

Like the read me says, I was only able to get the server working after opening ports 1025-65535 for TCP. But this range covers a lot of well known ports that I won't necessarily want open. Could we get an option to limit this to a small range of high ports? For example, mosh uses 60000-61000, which I'm fine opening on my firewall.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.