Search code examples
localhostvagrantngrok

Accessing ngrok web interface on a Vagrant box


I have a Vagrant box I'm using for local development. I'm working on a webhook, which is being called from outside; so I'm thinking of using ngrok.com to proxy requests to my Vagrant environment. I'm new to this ngrok thing.

I'm trying to figure out how to access ngrok's web interface, which is normally at http://127.0.0.1:4040. Of course, that doesn't work from my browser, because it's outside of the Vagrant box, so its localhost is not the Vagrant's localhost.

I (think I) have the Vagrant's IP address. I found it in a config.yaml file (yes, with an a), under vm: network: private_network: 192.168.nnn.nnn

Thanks for your help.


Solution

  • When trying to access a site in a VM, put ngrok in the host machine, and invoke it with:

    ngrok http -host-header=rewrite mydomain.com:80
    

    You'll need to access your site (in host machine's browser) with:

    http://123456.ngrok.io
    

    But it will rewrite it to mydomain.com.

    And you'll be able to access your ngrok dashboard (in host machine's browser) with:

    http://127.0.0.1:4040
    

    Docs at https://ngrok.com/docs#host-header. Best of luck!