Run Multiple Tunnels with a Single NGrok Agent
A simple solution for running multiple NGrok tunnels from a single agent
Recently, I've been developing a platform and trying to integrate a web api, web app, and Keycloak locally. Everything runs as expected via localhost, but when trying to create a docker compose file, things become a bit more complicated. The simple localhost
addresses no longer work or redirect properly because each docker container is a separate host.
Normally, I use NGrok to help with these scenarios, but when trying to start a second ngrok tunnel, I received the following error:
ERROR: authentication failed: Your account is limited to 1 simultaneous ngrok agent sessions.
ERROR: You can run multiple simultaneous tunnels from a single agent session by defining the tunnels in your agent configuration file and starting them with the command `ngrok start --all`.
ERROR: Read more about the agent configuration file: https://ngrok.com/docs/secure-tunnels/ngrok-agent/reference/config
ERROR: You can view your current agent sessions in the dashboard:
ERROR: https://dashboard.ngrok.com/agents
ERROR:
ERROR: ERR_NGROK_108
ERROR: https://ngrok.com/docs/errors/err_ngrok_108
ERROR:
After a bit of searching, I came across this on Stackoverflow showing how to update the configuration for multiple tunnels on a single agent.
# Find your ngrok config
ngrok config check
# Open your ngrok config
code /the/file/from/config/check.yml
# Update the configuration
version: "3"
agent:
authtoken: xyz
tunnels:
service_1:
addr: 1234
proto: http
service_2:
addr: 1235
proto: http
service_3:
addr: 1236
proto: http
# Start ngrok
ngrok start --all
This allowed me to authenticate with Keycloak via my api's swagger page, after updating the redirect url inside of the keycloak admin portal.