LoginSignup
20
9

More than 5 years have passed since last update.

ngrokをubuntu18.04上にインストール

Posted at

ngrok を使って気軽に手元のサーバを外部に公開する方法です

ngrok とは

ngrok
https://ngrok.com/

自分の開発環境を外部からアクセス可能にするためのツールです。
Firewall等の設定を考えなくていいので楽です。

インストール

https://ngrok.com/download
上記のURL画面中央左に、Download for Linuxという大きいボタンがあるので
そこからzipファイルを取得する。

ngrokのあるフォルダに移動(設定を変えていなければ /home/[ユーザ名]/ダウンロード)
$ unzip ngrok-stable-linux-amd64.zip
解凍されてできたディレクトリを/usr/binへコピーする。
$ sudo cp ngrok /usr/bin/

上記の設定が終わり、ngrokへアクセスできることを確認する。
$ ngrok version
ngrok version 2.2.8

アクセス方法

80番ポートを外部に公開する
$ ngrok http 80

なにやら表示されるので、アクセスURLをコピーし、ブラウザでアクセスする。

ngrok by @inconshreveable
(Ctrl+C to quit)
Session Status                online
Session Expires               7 hours, 59 minutes
Version                       2.2.8
Region                        United States (us)
Web Interface                 http://127.0.0.1:4040
                              ↓↓↓これでアクセスできる↓↓↓
Forwarding                    http://xxxxxxxx.ngrok.io -> localhost:80
Forwarding                    https://xxxxxxxx.ngrok.io -> localhost:80
Connections                   ttl     opn     rt1     rt5     p50     p90
0       0       0.00    0.00    0.00    0.00

$ curl http://[ランダムな文字列].ngrok.io

ユーザ登録するとドメイン設定できたりするらしいですが、割愛。

20
9
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
20
9