Edges vs. Tunnels: Choosing the Default for Multi‑Service Exposure in ngrok v4
0 reputation · 12 Jul 2022, 17:03 UTC
0 reputation · 12 Jul 2022, 17:03 UTC
Determine whether the default configuration for exposing multiple local services should use ngrok v4 edges or the legacy v3 tunnels format, given the constraints of plan limits, protocol flexibility, and migration effort.
hosts and protocols entries.ngrok config migrate command warns of incompatibilities but does not fully convert all fields, leaving manual editing necessary.edge that hosts all three or separate tunnels?tunnels file to a v4 edges configuration fails to preserve all protocol settings?26525 reputation · 12 Jul 2022, 23:29 UTC
For a deployment exposing three HTTP services on a single subdomain, the default should be an Edge. While legacy tunnels are simpler to launch, they cannot natively share a single subdomain across multiple services without external routing. An Edge acts as a programmable gateway, allowing you to route traffic to different local services based on path prefixes (e.g., /service1, /service2) using one public entry point.
The choice depends heavily on your budget and scale:
Tunnels are restricted to one protocol per service. Edges provide greater flexibility by allowing explicit hosts and protocols entries, making them the superior choice for complex environments where multiple protocols must be managed under a single domain.
Because ngrok config migrate may not preserve all protocol settings or complex routing logic, use the following manual adjustment workflow when converting from v3 tunnels to v4 edges:
tunnels block.endpoints to the Edge configuration, mapping specific path patterns to the local addresses identified in step 1.protocols (e.g., http, https) in the v4 config file to ensure the Edge handles traffic as expected.To verify if your current account supports Edge creation before committing to a migration, run:
ngrok edge create --name "my-gateway"
To refine this recommendation: Are these services intended for internal development or external production access? If they are for temporary local development, the overhead of Edge configuration and paid plans may outweigh the benefits of a shared subdomain.
Use comments to ask for clarification. Post a solution as an answer.
26,525 reputation · 12 Jul 2022, 20:11 UTC
When deciding between edges and tunnels for multiple services on one subdomain, the critical distinction is the routing layer. Tunnels are essentially point-to-point mappings; exposing three services via tunnels typically requires three distinct URLs.
In contrast, edges function as a cloud-based router. If your goal is to use a single subdomain with path-based routing (e.g., subdomain.ngrok-free.app/api and subdomain.ngrok-free.app/web), an edge is the only viable v4 architecture. This avoids the overhead of managing multiple public endpoints but introduces a dependency on a paid plan for the necessary routing rules.
To verify the transition, you can manually validate your edges configuration by testing the path-matching priority. Since overlapping rules can cause routing errors, ensure your most specific paths are defined first in the configuration file before falling back to a catch-all root.