1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

ローカル環境でSSLを使って外部公開したい(ngrokの使い方)

Posted at

ngrokの使い方メモです。

ローカル環境でSSLを公開したい場合があります。自分の場合はソーシャルログインのテストがしたかったためです。facebookログインではhttps通信が必須となりますので。

ngrokを使う

ngrokはローカル環境のhttps化をいい感じにやってくれます。

インストール

下記の公式サイトからインストールします。
https://ngrok.com/

ログインはしてもしなくてもいいみたいです。

ダウンロードして解凍したngrok.exeを任意の場所に保存します。

正常に起動するか確かめます。

$ ./ngrok version 
ngrok version 2.3.35

ngrokの起動

ローカルのポート番号を指定して起動します。

./ngrok http 80  

Ctrl+cで停止します。

Dockerを利用する場合でもコンテナ内にインストールする必要はなく、ホストOSでngrokが使えればよいので、localhostならこの方法で大丈夫です。

ブラウザでアクセス

ngrokが立ち上がると下のように表示がありますので、ブラウザではForwardingのところにあるhttps://xxxx.ngrok.xxxxでアクセスできます。


Session Status                online
Session Expires               7 hours, 59 minutes
Version                       2.3.35
Region                        United States (us)
Web Interface                 http://127.0.0.1:4040
Forwarding                    http://c4927277.ngrok.io -> http://localhost:80
Forwarding                    https://c4927277.ngrok.io -> http://localhost:80

Connections                   ttl     opn     rt1     rt5     p50     p90     
                              0       0       0.00    0.00    0.00    0.00    
1
2
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
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?