コマンドを打つだけ
ホームディレクトリで以下のコマンドを実行する
./ngrok http 3000
上記は「localhost:3000」を外部に公開したい場合の記述である。
「localhost:8080」を公開したい場合は「3000」の部分を「8080」に書き換えれば良い。
実行すると、以下のような表示がされる。
ngrok by @inconshreveable (Ctrl+C to quit)
Session Status online
Account xxxxxxxxx@gmail.com (Plan: Free)
Version 2.3.40
Region United States (us)
Web Interface http://127.0.0.1:4040
Forwarding http://xxxxxxxxxxxxxxx.ngrok.io -> http://localhost:3000
Forwarding https://xxxxxxxxxxxxxxxxx.io -> http://localhost:3000
Connections ttl opn rt1 rt5 p50 p90
0 0 0.00 0.00 0.00 0.00
ForwardingのhttpまたはhttpsのURLにアクセスすると、「localhost:3000」と同じ内容が表示されることが確認できる。
ngrokは基本的にこれだけでOK。超簡単。