はなちるのマイノート

Unityをメインとした技術ブログ。自分らしくまったりやっていきたいと思いますー!

localtunnelを利用して開発中のローカルサーバーを一時的に公開する

はじめに

今回はlocaltunnelを紹介したいと思います。

localtunnel exposes your localhost to the world for easy testing and sharing! No need to mess with DNS or deploy just to have others test out your changes.

localtunnelは、簡単なテストと共有のために、あなたのローカルホストを世界に公開します!あなたの変更を他の人がテストするために、DNSやデプロイを混乱させる必要はありません。

GitHub - localtunnel/localtunnel: expose yourself

インストール

グローバルにインストールする場合は以下のコマンドを打ち込みます。

$ npm install -g localtunnel

使い方

ltコマンドを利用するだけでtunnelが開始されます。またポート番号を指定してください。

$ lt --port 3000
your url is: https://good-shirts-repair.loca.lt

発行されたURLに移動すると、以下のような画面が表示されます。

localtunnel

どうやら悪用されるケースが増えたせいで、公開している人のpublic IPを入力しないといけないようになったみたいです。

To access the website, please confirm the tunnel creator's public IP below.
If you don't know what it is, please ask whoever you got this link from.
This password-like gate is now sadly required since too many phishing portals are being hosted via localtunnel and I'm getting bombarded with abuse notices.

// DeepL翻訳
アクセスするには、以下のトンネル作成者の公開IPを確認してください。
もしそれが何かわからない場合は、このリンクを手に入れた人に聞いてみてください。
localtunnel経由でホストされているフィッシングポータルがあまりに多く、私が不正利用通知を受けるようになったため、このパスワードのようなゲートが悲しいかな必要になったのです。


public IPの調べ方も記載されており、自身のローカルPCでコマンドを打った場合はhttps://ipv4.icanhazip.comにアクセスすると調べることができます。

If you're the developer...
To get your public IP address you can do any one of these:

If you're running localtunnel on a local computer, go to this link in your browser: https://ipv4.icanhazip.com

If you're running localtunnel on a remote computer run one of these commands via ssh or remote terminal to get the remote public IP:
curl ipv4.icanhazip.com or wget -q -O - ipv4.icanhazip.com
Your public/WAN IP will essentially be your tunnel password, so you'll need to share it with your link visitors in order for them to access your content.

// DeepL翻訳
あなたが開発者なら...
パブリックIPアドレスを取得するには、以下のいずれかを実行します:

ローカルコンピュータでlocaltunnelを実行している場合、ブラウザで次のリンクにアクセスしてください: https://ipv4.icanhazip.com

リモートコンピューターでlocaltunnelを実行している場合、sshまたはリモートターミナル経由で以下のコマンドのいずれかを実行し、リモートパブリックIPを取得します:
curl ipv4.icanhazip.com または wget -q -O - ipv4.icanhazip.com

あなたのパブリック/WAN IPは、本質的にあなたのトンネルのパスワードになるので、彼らがあなたのコンテンツにアクセスするために、あなたのリンクの訪問者とそれを共有する必要があります。

発行されたURLにアクセスする

発行されたURLにアクセスすると、外部からアクセスすることができます。

実際に利用している様子