Tunnel subdirectory localhost via ngrok?

Purpose: I want to share viewing a website using ngrok, which creates a tunnel, from which you can see my local host with a URL of something like mywebsite.ngrok.io

Problem: I use WAMP, and my localhost folder looks something like this:

 localhostdirectory |-- website1 |-- website2 |-- etc 

To access the website, I type in the text localhost/website1/ in the browser, I would like to tunnel only this URL, possible solutions:

  • Configuring a virtual host I would encounter the problem of manually configuring a virtual host , then I get something like website1.dev, and then I will pass it to ngrok as the host header in the HTTP request, like this :

     ngrok http -host-header=website1.dev 80 

    I did not understand what the host header is, and why I can not pass the relative URL, for example localhost/website1/ , and what is the rewrite option?

  • Change the folder directory of my local host folder to the website folder, I would prefer not to.

Is there a better way to accomplish my task in a simpler way, perhaps by going through the WAMP aliases?

+13
virtualhost wamp localhost ngrok
source share
3 answers

If you agree with Apache Vhost, you just need to execute the exec command

ngrok http -host-header=rewrite YOUR-LOCAL-DOMAIN:PORT

I did not forget to edit the host file for permission @IP IP YOUR-LOCAL-DOMAIN

+22
source share

I tried the below way.

When I ran $./ngrok http 80 ngrok listened to localhost:80 which shows the dashboard because the apache server is running on port 80 . Then I tried to run a subfolder on a different port, which solved the problem. Suppose you have a project in xyz and you want ngrok to point to it. Then do the following

 $ cd /opt/lampp/htdocs/xyz $ php -S localhost:8080 

Here, 8080 is any unused port. localhost:8080 direct points on xyz and then open another terminal

$./ngrok http 8080

In doing so, ngrok will listen on port 8080 your xyz .

Hope this helps !!

+3
source share

After you configure the ngrok address to point to localhost on port 80, you can access your sites by their names. Example:

 ngrok http -subdomain=dev 80 

Website Access1:

 dev.ngrok.io/website1 
+2
source share

All Articles