使用ngrok使用vhost设置定位开发站点

pau*_*and 19 virtualhost tunneling ngrok

我正在尝试使用"ngrok http -host-header = client1.dev 80"在我的站点目录中挖掘客户端站点,访问URL时我得到404.经过一些实验,如果我在主目录中放入一个index.html文件,它将显示该文件.不确定为什么主目录中的文件有效,而站点目录中的文件则不然.我一定在这里遗漏了什么......有什么想法吗?

目录结构:

www
  |home
  |sites
    | client1
    | client2
      ... 
Run Code Online (Sandbox Code Playgroud)

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>
Run Code Online (Sandbox Code Playgroud)

小智 50

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

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

ngrok http -host-header=rewrite sites.dev:80
Run Code Online (Sandbox Code Playgroud)


Dio*_*mes 18

对我来说它只适用于:

ngrok http -host-header=sites.dev 80
Run Code Online (Sandbox Code Playgroud)

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

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


Ale*_*abe 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
Run Code Online (Sandbox Code Playgroud)

然后你可以从命令行运行

ngrok start test
Run Code Online (Sandbox Code Playgroud)