LoginSignup
5
4

More than 1 year has passed since last update.

ngrokを使用して複数ポートをhttps化する

Last updated at Posted at 2022-06-19

はじめに

WebAPIのエンドポイントを同時に2つ設定したかったので、
ngrokでトンネルを設定して複数ポートをhttpsで立ててみました。

事前準備

  • ngrokのアカウント登録
  • 設定ファイルに認証情報を追加

目次

1.環境
2.トンネルの設定
3.トンネルの起動
4.最後に
5.参考

1. 環境

  • macOS Monterey:12.3

2. トンネルの設定

設定ファイルの場所はOSによって異なり、それぞれ以下になります。

  • Linux: "~/.config/ngrok/ngrok.yml"
  • MacOS (Darwin): "~/Library/Application Support/ngrok/ngrok.yml"
  • Windows: "%HOMEPATH%\AppData\Local\ngrok\ngrok.yml"

設定を書き換える

version: "2"
authtoken: XXXXXXXXX

// 以下を追加
tunnels:
  httpbin:
    proto: http
    addr: 8080
  demo:
    proto: http
    addr: 9090

上記では「httpbin」と「demo」というトンネル名で設定しています。
トンネル名は任意のもので構いません。

3 トンネルの起動

トンネル名を指定して起動

ngrok start httpbin demo

全てのトンネルを起動

ngrok start --all

これで複数ポートがhttps化されます。

4 最後に

ngrokの読み方は「エングロック」だそうです...

5 参考

5
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
5
4