New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only support top level domain #31

Closed
bastengao opened this Issue Aug 28, 2015 · 8 comments

Comments

Projects
None yet
7 participants
@bastengao

bastengao commented Aug 28, 2015

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

This comment has been minimized.

Show comment
Hide comment
@lukehorvat

lukehorvat Oct 8, 2015

Contributor

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?

Contributor

lukehorvat commented Oct 8, 2015

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?

@lukehorvat

This comment has been minimized.

Show comment
Hide comment
@lukehorvat

lukehorvat Oct 8, 2015

Contributor

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.

Contributor

lukehorvat commented Oct 8, 2015

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.

@boris

This comment has been minimized.

Show comment
Hide comment
@boris

boris Oct 29, 2015

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

boris commented Oct 29, 2015

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

This comment has been minimized.

Show comment
Hide comment
@worg

worg Nov 4, 2015

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

worg commented Nov 4, 2015

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

@boris

This comment has been minimized.

Show comment
Hide comment
@boris

boris Nov 4, 2015

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

boris commented Nov 4, 2015

@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 added a commit to worg/server that referenced this issue Nov 10, 2015

@gabrieleds

This comment has been minimized.

Show comment
Hide comment
@gabrieleds

gabrieleds commented Feb 14, 2016

+1

1 similar comment
@fuzziness

This comment has been minimized.

Show comment
Hide comment
@fuzziness

fuzziness commented Apr 19, 2016

+1

@defunctzombie

This comment has been minimized.

Show comment
Hide comment
@defunctzombie

defunctzombie Dec 12, 2017

Member

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

Member

defunctzombie commented Dec 12, 2017

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment