Imagine a use-case where you're already testing a service using ngrok and you want to spin up a different service and test that service on a different port.
Tricky situation, right?
That's where ngrok's power to run multiple tunnels simultaneously comes into the picture.
ngrok Agent configuration file:
The ngrok agent supports an optional, YAML configuration file which provides you with the power to run multiple tunnels simultaneously as well as to tweak some of its more advanced settings.
-
So, the default location of the ngrok agent configuration depends on your operating system. So, you can simply write:
ngrok config check
This will validate and print the location of the configuration file. For the main operating systems, their default file locations are:
Linux: ~/.config/ngrok/ngrok.yml
MacOS (Darwin): ~/Library/Application Support/ngrok/ngrok.yml
Windows: "%HOMEPATH%\AppData\Local\ngrok\ngrok.yml"
- Open the config file and replace the file with the following contents:
version: "2"
authtoken: 2aC32ipSr9Q9jGkNRAlgq8MnKtD_3DtHjjhsgdgsnTE6feu # add your auth token you got from ngrok dashboard
tunnels:
default-server:
proto: http
addr: 8000
domain: supposedly-choice-monkey.ngrok-free.app # insert your static domain that you claimed from ngrok dashboard
second-server:
proto: http
addr: 3000-
After you've saved the file. You can try spinning multiple tunnels with a single command:
ngrok start --all -
You should be able to see something like:
Voila! You can clearly see two tunnels running simultaneously. If you want to tweak around a bit. You can refer to the official documentation 1
Rather than using an automatically generated uuid like url ( https://b341-122-161-241-254.ngrok-free.app) everytime you spin up ngrok, you can actually claim your own static domain name on ngrok dashboard.
- Go to your ngrok dashboard 2
- Scroll a bit down to Deploy your app online section
-
Click on Static Domain to claim your free static domain. and you're done. You can spin up the ngrok with the static domain (
supposedly-choice-monkey.ngrok-free.appin my case) via the following command:ngrok http --domain=supposedly-choice-monkey.ngrok-free.app 3000