3

The config file of ngrok allows only a single authtoken line, and all resources available to you as a user (e.g., reserved hostnames) are based on the account associated with the authtoken.

If you have multiple ngrok accounts--for example, a professional (work) account and a personal account--and you want to use them with different projects, your only option is to add --config secondary_filename.yml to the command-line arguments to make use of another config.

How can you use your environment manager to switch to another ngrok account based on environment variables?

I am a Python user, so my use case applies mainly to virtualenvwrapper/workon, but this can probably equally apply to other environment managers (Ruby bundler?)

Cory
  • 1,530
  • 2
  • 11
  • 15

3 Answers3

8

you can specify a config file

https://ngrok.com/docs#config-location

my config was in ~/.ngrok2/ngrok.yml

i simply created a different config file ~/.ngrok2/myapp.yml

copy your other authtoken in there. and then to start it, use this command:

ngrok http 3000 --subdomain=mysubdomain -config=myapp.yml

clientelle
  • 91
  • 1
  • 3
2

I recommend you compile ngrok 1.7 and use it as you like without restrictions.

Source https://github.com/inconshreveable/ngrok/

Tutorial compiling: https://www.svenbit.com/2014/09/run-ngrok-on-your-own-server/

John Vargas
  • 71
  • 1
  • 5
0

Until ngrok implements environment-variable-based configuration, you can achieve this in virtualenvwrapper by doing the following. I'm assuming the name of your project is MYPROJECT.

  1. Create a second config file with your personal account. I will name this config file ngrok-MYPROJECT.yml. Set the value of authtoken to the account token for your account which is associated with MYPROJECT.

  2. chmod +x ~/.virtualenvs/MYPROJECT/bin/postactivate

  3. Edit the postactivate script you just edited, and add the following code:

ngrok () 
{
    command ngrok "$@" --config=$HOME/.ngrok2/ngrok-MYPROJECT.yml 
}

When you run workon again, ngrok will now be the shell function above. Running ngrok will execute the alternate config file you created in step 1.

Cory
  • 1,530
  • 2
  • 11
  • 15