31

我正在尝试使用“ngrok http -host-header = client1.dev 80”在我的站点目录中隧道客户端站点,访问 url 时得到 404。经过一些实验,如果我将 index.html 文件放在主目录中,它将显示该文件。不确定为什么主目录中的文件有效,而站点目录中的文件无效。我一定在这里遗漏了一些东西……有什么想法吗?

目录结构:

www
  |home
  |sites
    | client1
    | client2
      ... 

vhost.conf:

<Directory "/www">
Options Indexes MultiViews FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>

<Virtualhost *:80>
VirtualDocumentRoot "/Users/myname/www/home/wwwroot"
ServerName home.dev
UseCanonicalName Off
</Virtualhost>

<Virtualhost *:80>
VirtualDocumentRoot "/Users/myname/www/sites/%1/wwwroot"
ServerName sites.dev
ServerAlias *.dev
UseCanonicalName Off
</Virtualhost>
4

3 回答 3

81

酷你所有的配置都很好,你只需要执行命令

ngrok http -host-header=rewrite home.dev:80

ngrok http -host-header=rewrite sites.dev:80
于 2015-08-10T11:04:42.240 回答
39

对我来说,它只适用于:

ngrok http -host-header=sites.dev 80

将 sites.dev更改为您的虚拟主机名

来源:虚拟主机(MAMP、WAMP 等)

于 2017-02-21T14:34:10.267 回答
5

如果你想要一个更永久的配置,你可以编辑你的~/.ngrok2/ngrok.yml配置文件。

tunnels:
  test: # the name of your tunnel to call from the command line
    addr: 80 # Your localhost port
    proto: http
    host_header: test.localhost # Your localhost virtualhost

然后你可以从你的命令行运行

ngrok start test
于 2018-08-14T13:46:57.350 回答