Ngrok: Configuration file without custom subdomain

Created on 22 Jun 2015  路  34Comments  路  Source: inconshreveable/ngrok

Hi,

I would like to use yml configuration file but I can't set subdomain to false, and the configuration parser set a subdomain based on tunnel name (only for paid subscriptions)

https://github.com/inconshreveable/ngrok/blob/master/src/ngrok/client/config.go#L124

It would be nice being able to do something like that :

tunnels:
  website:
    addr: 80
    proto: http
    subdomain: false

Most helpful comment

This issue is fixed in 2.1.1. It's available for download via the beta channel: https://dl.equinox.io/ngrok/ngrok/beta

Simply not specifying the subdomain or hostname option will get you a random tunnel defined via the configuration file or API.

It will not be available in the stable channel for a month or so to ease the migration path while people work through updating their configuration files because it's a backwards incompatible change. More information is here: https://ngrok.com/docs#compat-2.1

All 34 comments

I agree, this is an open bug and will be fixed soon.

+1

+1

+1

+1

some news about this issue ? @inconshreveable

+1

Working on getting a fix out for this. This is an issue where the ngrok client 'assumes' that you want to set the subdomain of a tunnel to be equal to the name of the tunnel, so it always creates custom subdomains when using the configuration file. Some people rely on this behavior and breaking changes are not possible. There will be some kind of 'version' identifier in the configuration file that you'll have to set to change this behavior.

Is there a workaround? For example downgrade?

+1

This bug basically means you can't use the config file with a free plan; which makes running multiple tunnels a pain. Still, that's what bash scripting is for (;

@pospi Could you explain better, how bash scripting can help? You can't run several instances of ngrok and you can't run it with config entries. Doesn't this mean that you can't run multiple tunnels at all (it one of them is http/https)?

Oh, really? That's not been my experience. I kinda winged it and guessed, if you run two daemons then the latter will bind its info service to port 4041 instead of 4040. Assuming you have an application that's running two proxies for different ports (a webserver on port 3080 and API service on port 3081, say), this should work:

killall ngrok

pushd ~/Downloads
  ./ngrok http 3080 > /dev/null &
  ./ngrok http 3081 > /dev/null &

  echo "Waiting for ngrok to warm up..."
  sleep 10s

  proxy1=`curl -s http://localhost:4040/api/tunnels | node -pe "JSON.parse(require('fs').readFileSync('/dev/stdin').toString()).tunnels[0].public_url"`
  proxy2=`curl -s http://localhost:4041/api/tunnels | node -pe "JSON.parse(require('fs').readFileSync('/dev/stdin').toString()).tunnels[0].public_url"`

  echo "Frontend exposed @ ${proxy1}"
  echo "API exposed @ ${proxy2}"
popd

Obviously that requires you unpacked ngrok into your downloads folder and have node installed so you can parse the output, but you could use any other JSON parsing utility (like jq?) to do that.

edit: I should also point out that the order it lists its tunnels in seems unpredictable, and it spawns both an http and https listener by default. You might get the wrong scheme in the URLs it spits out so just be aware of paying attention to what you're copying.

From my experience second instance of ngrok fails with:

Tunnel session failed: Your account is limited to 1 simultaneous client

Oh, that'd be because I've authed with their servers then. I suppose they don't want people scripting huge amounts of them anonymously, which is fair enough. Try it again after following instructions here- https://ngrok.com/docs#authtoken

However, I've found workaround:

  1. Start ngrok http <whatever>.
  2. Add tcp tunnels by http_proxy= curl -i -H 'content-type: application/json' -d '{"addr":"22","proto":"tcp","name":"ssh"}' http://127.0.0.1:4040/api/tunnels

Obviously, this workaround doesn't allows several http tunnels.

@pospi You are obviously not right. They not allowing any tunnels for unauthed clients.

@inconshreveable Is this still being worked on? (Or alternatively, will the v2 client be open-sourced soon?) A simple workaround like using subdomain: * to indicate a randomly generated subdomain should be pretty simple to implement, and would have the advantage of not breaking backward compatibility.

@inconshreveable any update on this?

+1

+1
Note that this affects API usage too, POSTing this:
{"name":"carol","proto":"http","addr":"localhost:8080"}
or this:
{"name":"carol","proto":"http","addr":"localhost:8080","subdomain":""}
generates this:
{"error_code":103,"status_code":502,"msg":"failed to start tunnel","details":{"err":"Custom subdomains are only available for paid plans. Upgrade at https://dashboard.ngrok.com/billing/plan"}}

@rdnetto's solution is nice and simple (from our point of view).

any update on this?

Consider me a +1 for all these issues, I don't really care what the subdomain is as long as I can get the url outputted in the ngrok.connect callback.

Any news?

It's a very simple issue.

Any news?
Please update us on your plans about this issue.

+1

+1

+1

The same parameters work on the command line. It only doesn't work when the parameters are saved in a configuration file. The ngrok command assumes that the name of the tunnel to be the name of the subdomain, and it could not be disabled. I tried:

    subdomain: ""

and

    subdomain: *

and

    subdomain:

but it didn't work!

+1

@inconshreveable commented on 25 Jun 2015
I agree, this is an open bug and will be fixed soon.

Any update on this?

is this f* issue going to be fixed?

+100

This issue is fixed in 2.1.1. It's available for download via the beta channel: https://dl.equinox.io/ngrok/ngrok/beta

Simply not specifying the subdomain or hostname option will get you a random tunnel defined via the configuration file or API.

It will not be available in the stable channel for a month or so to ease the migration path while people work through updating their configuration files because it's a backwards incompatible change. More information is here: https://ngrok.com/docs#compat-2.1

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cleocn picture cleocn  路  6Comments

gauravrc picture gauravrc  路  4Comments

silverrajat88 picture silverrajat88  路  4Comments

wujunze picture wujunze  路  9Comments

alexforever86 picture alexforever86  路  5Comments