2
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.

Homestead上のWebサイトをngrokで公開する

Posted at

ngrok とは

ngrokとはローカルサーバーをインターネット上へ公開することのできるサービスです。

Web開発の現場では、Webhookのテストによく使われていると思います。

基本的な使い方

http://localhost のWebサイトを指定する場合であれば、次のように起動します。

ngrok http 80

Homestead を用いた使い方

Hostヘッダを指定することで、Laravel Homestead上のWebサイトを公開することができます。

ngrok http <homestead_host_ip>:<port> -host-header=<homestead_domain>

HomesteadのIPアドレスが 192.168.10.10http://homestead.test のWebサイトを指定する場合であれば、次のように起動します。

ngrok http 192.168.10.10:80 -host-header=homestead.test

ngrok の設定ファイルを使った起動方法

設定ファイルに接続先を定義することで、次のようにコマンドを簡易化することができます。

ngrok start homestead

デフォルトの設定ファイルを上書きする場合は次のファイルを編集してください。

OS X /Users/example/.ngrok2/ngrok.yml
Linux /home/example/.ngrok2/ngrok.yml
Windows C:\Users\example\.ngrok2\ngrok.yml

トンネル名 homesteadanother を定義する例です。

ngrok.yml
  homestead:
    proto: http
    addr: 192.168.10.10:80
    host_header: homestead.test
  another:
    proto: http
    addr: 192.168.10.10:80
    host_header: another.test

ngrok start homesteadngrok start another が使えるようになりました。

2
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
2
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?