LoginSignup
3
4

More than 5 years have passed since last update.

ngrokで一時的なローカルウェブアプリケーションの公開

Posted at

ngrokは手許で検証しているウェブアプリケーションを手軽に外部から接続できる中継アプリケーションです。
デプロイ前のアプリケーションを一時的に外部接続して試験するなどの使い道が考えられます。

ngrokをつかってみる

インストール

手許のOSXではhomebrewでの構成ができなかったので、公式ダウンロードページからのダウンロードにて入手しました。

https://ngrok.com/download

入手したzipファイルを展開し、利用できる状態にします。

Authtokenを取得

利用する際に必要になるAuthtokenを取得します。
ngrok auth で取得したAuthtokenを設定して下さい。

起動

Safariでは正しく動かないようなので、Chrome/Firefoxで稼働を確認しました。
以下の例では

  • ユーザーhoge:パスワードfugaでのbasic認証を設定
  • ローカルのHTTP8080を外部に公開

という指定を行っています。

% ./ngrok http -auth="hoge:fuga" 8080

接続する一時URLなどがコンソールに表示されますので、指定に従いブラウザで確認して下さい。
http://127.0.0.1:4000 は管理コンソール画面となります。

ngrok by @inconshreveable                                  (Ctrl+C to quit)

Tunnel Status                 online
Version                       2.0.19/2.0.19
Web Interface                 http://127.0.0.1:4040
Forwarding                    http://xxxxxxxx.ngrok.io -> localhost:8080
Forwarding                    https://xxxxxxxx.ngrok.io -> localhost:8080

Connections                   ttl     opn     rt1     rt5     p50     p90
                              0       0       0.00    0.00    0.00    0.0

Enjoy!

3
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
4