Skip to content

Localhost tunneling

Localhost tunneling is a networking technique used to expose a local development server to the public internet. This is achieved by using software to create a secure tunnel to a temporary server on a public network, which then forwards traffic to a specified port on the local machine^[400-devops-02-os-and-linux-basics-network-ngrok.md].

A key benefit of this approach is the ability to test webhooks and callbacks, such as those from GitHub Webhooks, LINE Bot, Telegram Bot, or Slack Bot, which require a publicly accessible URL to send data to the local environment^[400-devops-02-os-and-linux-basics-network-ngrok.md].

Tooling: ngrok

A common tool for this purpose is ngrok^[400-devops-02-os-and-linux-basics-network-ngrok.md].

Installation

ngrok can be downloaded directly from the official website or installed via package managers like Chocolatey on Windows^[400-devops-02-os-and-linux-basics-network-ngrok.md].

choco install [ngrok](<./ngrok.md>)

Usage

Once installed and authenticated, the tool creates a tunnel by forwarding a local port to a public domain^[400-devops-02-os-and-linux-basics-network-ngrok.md].

For example, to expose a local application running on port 8080:

[ngrok](<./ngrok.md>) http 8080

This command generates a temporary public URL (e.g., https://1bee-210-66-180-104.jp.ngrok.io) that routes traffic to http://localhost:8080^[400-devops-02-os-and-linux-basics-network-ngrok.md]. The software also provides a web interface, typically at http://localhost:4040, to inspect and replay incoming requests^[400-devops-02-os-and-linux-basics-network-ngrok.md].

Sources

^[400-devops-02-os-and-linux-basics-network-ngrok.md]