Skip to content

Instantly share code, notes, and snippets.

@bijay-shrestha
Last active July 5, 2019 09:55
Show Gist options
  • Save bijay-shrestha/66825233308e07d99ec9293e6a1ee5c3 to your computer and use it in GitHub Desktop.
Save bijay-shrestha/66825233308e07d99ec9293e6a1ee5c3 to your computer and use it in GitHub Desktop.

Install ngrok

  1. Download ngrok for your favorite OS.
  2. Unzip and, if you want, add it to your path (Move it to /usr/local/binor use your favorite command)

$ unzip /path/to/ngrok.zip

  1. Remember, you need to add ngrok to your path or use ./path/to/ngrok
$ ngrok help

Exposing HTTP’s Services

$ ngrok http 8080

Then, you can see the ngrok UI in your terminal, for example:

ngrok by @inconshreveable
 
Tunnel Status           online
Version                 2.2.8
Web Interface           http://127.0.0.1:4040
Forwarding              http://92832de0.ngrok.io  -> localhost:8080
Forwarding              
https://92832de0.ngrok.io -> localhost:8080 
Connnections            ttl     opn     rt1     rt5     p50     p90
                        0       0       0.00    0.00    0.00    0.00

In this example, you can access to your service (localhost:8080) through https://92832de0.ngrok.io Sure, https it’s hot to go!

Now, you can access to your localhost from anywhere, including the International Space Station (ISS).

Awesome, right?

What, are you using Virtual Hosts? Not problem.

You just need include the host-header flag:

$ ngrok http -host-header=myservice.local.vh port

For example, if I wanna expose this virtual host: f1soft.local.vh:80

$ ngrok http -host-header=jotarios.local.vh 80

Credits

Jorge L. Rios

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment