# ngrok for tunneling

You have a login for https://dashboard.ngrok.com (it should be in 1password)

If you haven't installed it yet on your Mac:

1. Download the exec file from here: [https://dashboard.ngrok.com/get-started](https://dashboard.ngrok.com/get-started)
2. Place that file in my `~/code` directory on my Mac
3. Run the command found on this page [https://dashboard.ngrok.com/get-started](https://dashboard.ngrok.com/get-started) to connect my ngrok authtoken

### Run bc.ngrok.io

While working on ZipMessage, I upgraded ngrok so that I could use one standard domain each time.  I set up bc.ngrok.io for this purpose.

First, ensure the ngrok.yml (<-- this resides in \~/.ngrok2/ngrok.yml) contains the following, which assumes that the project I'm currently working on will have its localhost pointing to port `5000` which ZipMessage does.

```
authtoken: (my auth token)
remote_management: null

tunnels:
  bc:
    proto: http
    hostname: bc.ngrok.io
    addr: 127.0.0.1:5000
```

Then run this terminal shortcut that I set up:

```
ngbc
```

That is my terminal shortcut which will run the following (first it CDs to \~/code, then it runs `./ngrok start bc` )

```
cd ~/code && ./ngrok start bc
```

### Run a random ngrok URL

First, run the server for one of your projects so that you can see it at localhost

Then:

```
cd ~/code
./ngrok http 3000
```

That should provide you with the URL where you can view the tunneled server.

If this is a Rails project, then you might see a Rails error telling you that you need to add that URl to the config file.  Copy/paste that provided code and place it at the top of `config/environments/development.rb`

