Setting Ngrok with Docker or Vagrant

Ngrok is great tool, to set it up to work with docker and your specific localhost you need to have account, make authtoken command and then run following to receive both http and https versions of your local environment exposed to internet.

 ngrok http -host-header=example.local 8700 #rewrite the Host header to 'example.local'

so if your docker is set to example.local:8700, this will work, also if it is plain 80 port, you should also state that. For Vagrant you will need a bit more

ngrok http -host-header=example.local example.local:8023

as we need to ensure that traffic is forwarded to the local hostname of your vagrant instance.

To check status and requests, use this dashboard locally http://127.0.0.1:4040/inspect/http

 

Edit:
Above solutions can cause infinite loops as they are rewriting headers, to not experience that you can use directly commands like which will work in that case

   ngrok http https://localhost:8443    # forward to a local https server