Only support top level domain #31

Closed
opened 2015-08-28 09:03:02 +00:00 by bastengao · 8 comments
bastengao commented 2015-08-28 09:03:02 +00:00 (Migrated from github.com)

It not works when host domain is not top level domain. I want to use subdomain as base domain described in https://github.com/localtunnel/server#use-your-server, such as subdomain.example.com and *.subdomain.example.com. This issue is similar to #21.

It not works when host domain is not top level domain. I want to use subdomain as base domain described in https://github.com/localtunnel/server#use-your-server, such as `subdomain.example.com` and `*.subdomain.example.com`. This issue is similar to #21.
lukehorvat commented 2015-10-08 07:58:40 +00:00 (Migrated from github.com)

Are you getting a no active client error? I am.

I've been doing a little debugging, and logging hostname and subdomain just above this line yields xxxxxxxxx.localtunnel.example.com and xxxxxxxxx.localtunnel respectively. As a result, I get the error no active client for 'xxxxxxxxx.localtunnel' when I visit http://xxxxxxxxx.localtunnel.example.com in my browser.

@defunctzombie I think var client_id = subdomain; needs to be changed to handle this use case. Perhaps check if subdomain has a dot and, if so, extract the substring up to the first dot?

Are you getting a `no active client` error? I am. I've been doing a little debugging, and logging `hostname` and `subdomain` just above [this line](https://github.com/localtunnel/server/blob/master/server.js#L49) yields `xxxxxxxxx.localtunnel.example.com` and `xxxxxxxxx.localtunnel` respectively. As a result, I get the error `no active client for 'xxxxxxxxx.localtunnel'` when I visit http://xxxxxxxxx.localtunnel.example.com in my browser. @defunctzombie I think `var client_id = subdomain;` needs to be changed to handle this use case. Perhaps check if `subdomain` has a dot and, if so, extract the substring up to the first dot?
lukehorvat commented 2015-10-08 11:42:30 +00:00 (Migrated from github.com)

Furthermore, http://localtunnel.example.com/?new (requested when the client starts up) results in subdomain's value being localtunnel. So it won't get to this line and the new_client function won't be called.

Furthermore, http://localtunnel.example.com/?new (requested when the client starts up) results in `subdomain`'s value being `localtunnel`. So it won't get to [this line](https://github.com/localtunnel/server/blob/master/server.js#L46) and the `new_client` function won't be called.
boris commented 2015-10-29 14:50:36 +00:00 (Migrated from github.com)

Having the same problem here. When using http://sub.domain.com it returns a 502.

lt --host http://sub.domain.com:1443 -p 9001
502

Error: localtunnel server returned an error, please try again
    at Request._callback (/usr/lib/node_modules/localtunnel/lib/Tunnel.js:54:13)
    at Request.self.callback (/usr/lib/node_modules/localtunnel/node_modules/request/main.js:122:22)
    at Request.emit (events.js:98:17)
    at Request.<anonymous> (/usr/lib/node_modules/localtunnel/node_modules/request/main.js:655:16)
    at Request.emit (events.js:117:20)
    at IncomingMessage.<anonymous> (/usr/lib/node_modules/localtunnel/node_modules/request/main.js:617:14)
    at IncomingMessage.emit (events.js:117:20)
    at _stream_readable.js:944:16
    at process._tickCallback (node.js:448:13)

But if I use http://domain.com:

lt --host http://domain.com:1443 -p 9001
your url is: http://jddrzcnonz.domain.com:1443
Having the same problem here. When using http://sub.domain.com it returns a 502. ``` lt --host http://sub.domain.com:1443 -p 9001 502 Error: localtunnel server returned an error, please try again at Request._callback (/usr/lib/node_modules/localtunnel/lib/Tunnel.js:54:13) at Request.self.callback (/usr/lib/node_modules/localtunnel/node_modules/request/main.js:122:22) at Request.emit (events.js:98:17) at Request.<anonymous> (/usr/lib/node_modules/localtunnel/node_modules/request/main.js:655:16) at Request.emit (events.js:117:20) at IncomingMessage.<anonymous> (/usr/lib/node_modules/localtunnel/node_modules/request/main.js:617:14) at IncomingMessage.emit (events.js:117:20) at _stream_readable.js:944:16 at process._tickCallback (node.js:448:13) ``` But if I use http://domain.com: ``` lt --host http://domain.com:1443 -p 9001 your url is: http://jddrzcnonz.domain.com:1443 ```
worg commented 2015-11-04 00:44:01 +00:00 (Migrated from github.com)

I think a startup flag should be provided that marks the current server as 'subdomain' server, thus allowing us to change the check performed here , I'll be glad to submit a PR

I think a startup flag should be provided that marks the current server as 'subdomain' server, thus allowing us to change the check performed [here](https://github.com/localtunnel/server/blob/master/server.js#L45) , I'll be glad to submit a PR
boris commented 2015-11-04 13:48:14 +00:00 (Migrated from github.com)

@worg sounds good. In fact, I found a workaround with the following modification on the server.js;
(here's the diff)

diff --git a/server.js b/server.js
index 17c2d9f..52db061 100644
--- a/server.js
+++ b/server.js
@@ -41,8 +41,11 @@ function maybe_bounce(req, res, bounce) {
         return false;
     }

-    var subdomain = tldjs.getSubdomain(hostname);
-    if (!subdomain) {
+    var subdomain = hostname.split(".")[0];
+    console.log(subdomain)
+
+    //var subdomain = tldjs.getSubdomain(hostname);
+    if (subdomain === 'tunnel') {
         return false;
     }

But, I believe a startup flag is a better solution.

@worg sounds good. In fact, I found a workaround with the following modification on the `server.js`; (here's the diff) ``` diff --git a/server.js b/server.js index 17c2d9f..52db061 100644 --- a/server.js +++ b/server.js @@ -41,8 +41,11 @@ function maybe_bounce(req, res, bounce) { return false; } - var subdomain = tldjs.getSubdomain(hostname); - if (!subdomain) { + var subdomain = hostname.split(".")[0]; + console.log(subdomain) + + //var subdomain = tldjs.getSubdomain(hostname); + if (subdomain === 'tunnel') { return false; } ``` But, I believe a startup flag is a better solution.
bbtx0 commented 2016-02-14 22:09:18 +00:00 (Migrated from github.com)

+1

+1
fuzziness commented 2016-04-19 11:10:02 +00:00 (Migrated from github.com)

+1

+1
defunctzombie commented 2017-12-12 15:19:53 +00:00 (Migrated from github.com)

There are a few PRs out to solve this issue; once those merge this will be resolved.

There are a few PRs out to solve this issue; once those merge this will be resolved.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: hoelee/server#31