← 返回命令列表

Linux command

ngrok 命令

网络

复制后可按需替换文件名、目录或参数。

常用示例

Expose local port

ngrok http [8080]

Expose with custom domain

ngrok http --domain=[myapp.ngrok-free.app] [8080]

TCP tunnel

ngrok tcp [22]

Start named tunnel from config

ngrok start [tunnel-name]

Start all tunnels from config

ngrok start --all

Set authentication token

ngrok config add-authtoken [token]

TLS tunnel

ngrok tls [443]

Expose with basic auth

ngrok http --basic-auth="[user]:[password]" [8080]

Check configuration file validity

ngrok config check

Diagnose connectivity

ngrok diagnose

说明

ngrok creates secure tunnels from a public endpoint to a locally running service. It exposes local servers to the internet through a public URL without deploying or configuring firewalls. Common use cases include webhook development, demo presentations, testing mobile backends, and remote access to local services. The web inspection interface (default at localhost:4040) allows real-time traffic inspection and replay.

参数

http _PORT_
Create HTTP tunnel to local port.
tcp _PORT_
Create TCP tunnel.
tls _PORT_
Create TLS tunnel (does not terminate TLS).
start _name_
Start named tunnel(s) from configuration file.
config _SUBCOMMAND_
Manage ngrok configuration (add-authtoken, check, edit).
diagnose
Run connectivity diagnostics to ngrok service.
service _action_
Manage ngrok as a system service (install, start, stop, restart, uninstall).
--domain _NAME_
Custom domain for tunnel endpoint.
--region _REGION_
Region for tunnel (us, eu, ap, au, sa, jp, in).
--log _path_
Write logs to file or "stdout"/"stderr".
--basic-auth _USER:PASSWORD_
Add HTTP basic authentication to the tunnel.
api _SUBCOMMAND_
Access the ngrok API (e.g., list tunnels, manage reserved domains).
--help
Display help information.

FAQ

What is the ngrok command used for?

ngrok creates secure tunnels from a public endpoint to a locally running service. It exposes local servers to the internet through a public URL without deploying or configuring firewalls. Common use cases include webhook development, demo presentations, testing mobile backends, and remote access to local services. The web inspection interface (default at localhost:4040) allows real-time traffic inspection and replay.

How do I run a basic ngrok example?

Run `ngrok http [8080]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does http _PORT_ do in ngrok?

Create HTTP tunnel to local port.