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?
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?
No it doesn't. This fork by @whitecolor does. I recall that he made a PR ages ago, but was not merged yet.
No it doesn't. This [fork](https://github.com/whitecolor/localtunnel-server) by @whitecolor does. I recall that he made a PR ages ago, but was not merged yet.
eyep, doesn't work. The client (under Win10x64) throws an error:
> lt --host http://sub.someserver.com/ -l 127.0.1.1 -p 80
%APPDATA%\Roaming\npm\node_modules\localtunnel\bin\client:48
throw err;
^
Error: localtunnel server returned an error, please try again
at Request._callback (%APPDATA%\Roaming\npm\node_modules\localtunnel\lib\Tunnel.js:53:27)
at Request.self.callback (%APPDATA%\Roaming\npm\node_modules\localtunnel\node_modules\request\request.js:188:22)
at emitTwo (events.js:106:13)
at Request.emit (events.js:194:7)
at Request.<anonymous> (%APPDATA%\Roaming\npm\node_modules\localtunnel\node_modules\request\request.js:1171:10)
at emitOne (events.js:96:13)
at Request.emit (events.js:191:7)
at IncomingMessage.<anonymous> (%APPDATA%\Roaming\npm\node_modules\localtunnel\node_modules\request\request.js:1091:12)
at Object.onceWrapper (events.js:293:19)
at emitNone (events.js:91:20)
The server itself doesn't seem to react to the request (it does serve 404 when accessed directly, however), the only line in the output:
2017-12-25T00:08:25.434Z localtunnel server listening on port: 4001
The same installation listening from a root domain works fine.
If you are not going to fix it, at least remove the example from the Readme that indicates it can work on a subdomain and tell people to run it only from root.
eyep, doesn't work. The client (under Win10x64) throws an error:
```
> lt --host http://sub.someserver.com/ -l 127.0.1.1 -p 80
%APPDATA%\Roaming\npm\node_modules\localtunnel\bin\client:48
throw err;
^
Error: localtunnel server returned an error, please try again
at Request._callback (%APPDATA%\Roaming\npm\node_modules\localtunnel\lib\Tunnel.js:53:27)
at Request.self.callback (%APPDATA%\Roaming\npm\node_modules\localtunnel\node_modules\request\request.js:188:22)
at emitTwo (events.js:106:13)
at Request.emit (events.js:194:7)
at Request.<anonymous> (%APPDATA%\Roaming\npm\node_modules\localtunnel\node_modules\request\request.js:1171:10)
at emitOne (events.js:96:13)
at Request.emit (events.js:191:7)
at IncomingMessage.<anonymous> (%APPDATA%\Roaming\npm\node_modules\localtunnel\node_modules\request\request.js:1091:12)
at Object.onceWrapper (events.js:293:19)
at emitNone (events.js:91:20)
```
The server itself doesn't seem to react to the request (it does serve 404 when accessed directly, however), the only line in the output:
```
2017-12-25T00:08:25.434Z localtunnel server listening on port: 4001
```
NGINX config:
```
upstream localtunnel-server-subdomain {
server 127.0.0.1:4001;
}
server {
listen 80;
server_tokens off;
server_name sub.someserver.com *.sub.someserver.com;
root /var/opt/localtunnel-subdomain;
index index.html index.htm;
location / {
proxy_pass http://localhost:4001;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Proto http;
proxy_set_header X-NginX-Proxy true;
proxy_set_header Upgrade $http_upgrade;
proxy_redirect off;
}
}
```
The same installation listening from a root domain works fine.
If you are not going to fix it, at least remove the example from the Readme that indicates it can work on a subdomain and tell people to run it only from root.
Yes it still doesn't work for hostnames with subdomains.
The code snippet below shows that localtunnel-server treats requests with subdomains as created instance which won't create clients for them, and it will continue return 404 to the client CLI.
server.on('request', (req, res) => {
// without a hostname, we won't know who the request is for
const hostname = req.headers.host;
if (!hostname) {
res.statusCode = 400;
res.end('Host header is required');
return;
}
// Doesn't handle subdomain
const clientId = GetClientIdFromHostname(hostname);
if (!clientId) {
appCallback(req, res);
return;
}
if (manager.hasClient(clientId)) {
manager.handleRequest(clientId, req, res);
return;
}
res.statusCode = 404;
res.end('404');
});
function GetClientIdFromHostname(hostname) {
// Also get the server's subdomain
return tldjs.getSubdomain(hostname);
}
If this is the case, I hope localtunnel-server can add this features to fulfill its statement in README.md or at least delete this part from it.
You can set up DNS entries for your domain.tld and *.domain.tld (or sub.domain.tld and *.sub.domain.tld).
"Which just could not work and is waste of time for those who don't know this error."
Yes it still doesn't work for hostnames with subdomains.
The code snippet below shows that localtunnel-server treats requests with subdomains as **created** instance which won't create clients for them, and it will continue return 404 to the client CLI.
server.on('request', (req, res) => {
// without a hostname, we won't know who the request is for
const hostname = req.headers.host;
if (!hostname) {
res.statusCode = 400;
res.end('Host header is required');
return;
}
// Doesn't handle subdomain
const clientId = GetClientIdFromHostname(hostname);
if (!clientId) {
appCallback(req, res);
return;
}
if (manager.hasClient(clientId)) {
manager.handleRequest(clientId, req, res);
return;
}
res.statusCode = 404;
res.end('404');
});
function GetClientIdFromHostname(hostname) {
// Also get the server's subdomain
return tldjs.getSubdomain(hostname);
}
If this is the case, I hope localtunnel-server can add this features to fulfill its statement in `README.md` or at least delete this part from it.
> You can set up DNS entries for your domain.tld and *.domain.tld (or sub.domain.tld and *.sub.domain.tld).
"Which just could not work and is waste of time for those who don't know this error."
@William-An yeah, actually I forked both client and server, found the problem and almost fixed it, but then something else got broken. so I dropped it altogether and set it for root and custom port.
@William-An yeah, actually I forked both client and server, found the problem and almost fixed it, but then something else got broken. so I dropped it altogether and set it for root and custom port.
Based on my reading of this issue this will resolve it. If not; please re-open with a more detailed description of your setup and what is not working.
I have added the _--domain_ option to handle situations where the localtunnel server is setup on a subdomain.
https://github.com/localtunnel/server/commit/86dce49dd1d40a64a2f121ff3aa271719417810f
Based on my reading of this issue this will resolve it. If not; please re-open with a more detailed description of your setup and what is not working.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
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?
No it doesn't. This fork by @whitecolor does. I recall that he made a PR ages ago, but was not merged yet.
thanks! is the repository still maintained?
eyep, doesn't work. The client (under Win10x64) throws an error:
The server itself doesn't seem to react to the request (it does serve 404 when accessed directly, however), the only line in the output:
NGINX config:
The same installation listening from a root domain works fine.
If you are not going to fix it, at least remove the example from the Readme that indicates it can work on a subdomain and tell people to run it only from root.
@whitecolor's fork is broken as well btw.
@Spown @whitecolor's fork works for me...it's just not up to date.
Yes it still doesn't work for hostnames with subdomains.
The code snippet below shows that localtunnel-server treats requests with subdomains as created instance which won't create clients for them, and it will continue return 404 to the client CLI.
If this is the case, I hope localtunnel-server can add this features to fulfill its statement in
README.mdor at least delete this part from it.@Spown The Nginx conf does not seem to cause this error but the code does.
@William-An yeah, actually I forked both client and server, found the problem and almost fixed it, but then something else got broken. so I dropped it altogether and set it for root and custom port.
I have added the --domain option to handle situations where the localtunnel server is setup on a subdomain.
https://github.com/localtunnel/server/commit/86dce49dd1d40a64a2f121ff3aa271719417810f
Based on my reading of this issue this will resolve it. If not; please re-open with a more detailed description of your setup and what is not working.