通过ngrok隧道一个localhost子目录? [英] Tunnel a localhost subdirectory through ngrok?

查看:710
本文介绍了通过ngrok隧道一个localhost子目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目标:想要使用ngrok共享网站预览,这会创建一个隧道,从中可以看到我的本地主机,其网址类似于 mywebsite.ngrok.io

Objective: want to share a website preview using ngrok, which creates a tunnel from which my localhost can be seen with an url of something like mywebsite.ngrok.io

问题:我使用WAMP,我的localhost文件夹如下所示:

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

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

要访问我在浏览器中键入 localhost / website1 / 的网站,我想只隧道该URL,可能的解决方案是:

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


  1. 设置虚拟主机,我会经历手动设置虚拟主机的麻烦,然后我得到类似于website1.dev的东西,然后我会把它传递给ngrok作为主机头HTTP请求,喜欢

  1. Setting up a Virtual host, I would go through the hassle of manually setting up a virtual host, then I get something like website1.dev, and then I would pass it to ngrok as the host header in the HTTP request, like that:

ngrok http -host-header=website1.dev 80

我不明白主机头是什么,为什么可以我传递了一个相对网址,如 localhost / website1 / ,还有什么是重写选项?

I didn't understand what the host header is though, and why can't I pass a relative url like localhost/website1/, also what is the rewrite option?

有没有更好的方法来完成我的目标是以更简单的方式,也许通过WAMP别名?

Is there a better way to accomplish my objective in an easier way, maybe going through WAMP aliases?

推荐答案

如果你使用Apache Vhost,你只需执行exec命令

If you make do with Apache Vhost you just have to exec command

ngrok http -host-header =重写YOUR-LOCAL-DOMAIN:PORT

别忘了编辑主机文件解析@IP< - > YOUR-LOCAL-DOMAIN

Dont forgot to edit host file for resolution @IP <-> YOUR-LOCAL-DOMAIN

这篇关于通过ngrok隧道一个localhost子目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆