另一台设备上的 wamp server 3.0 虚拟主机
wamp server 3.0 virtual host on another device
我正在尝试在其他设备(主要是移动设备)上查看我的网站。我将 Wampserver 3.0 与 apache 2.4.17 一起使用。我还使用 wampserver 内置的虚拟主机功能来查看我的站点,我的代码不在 wamp64\www\ 文件夹中,而是在我的文档文件夹中。我已经能够允许其他设备查看 wampserver 默认页面,但是每当我访问我的网站时,我都会得到 "fitly's server DNS address could not be found"
这是 httpd-vhosts.conf 文件
<VirtualHost *:80>
ServerName localhost
DocumentRoot C:/wamp64/www
<Directory "C:/wamp64/www/">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName fitly
DocumentRoot c:/users/juan/documents/fitly
<Directory "c:/users/juan/documents/fitly/">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
这是我过去使用过的解决方案。虽然我承认肯定还有别的
我发现 none 的方法是 quicker/easier 来实施。
Here is another way, without using Fiddler
基本问题当然是我们无法通过移动设备通过名称寻址我们的虚拟主机,即使它通过 wifi 连接到我们的路由器子网,因为设备浏览器当我们尝试使用它时不知道在哪里可以找到我们的虚拟托管域名。
由于大多数(如果不是全部)移动设备都被锁定,并且假设您像我一样不想 jailbreak
所有测试设备,我们不能简单地将我们的虚拟主机名称添加到设备HOSTS 文件,该文件当然存在,但设备安全性阻止我们访问它。
所以我使用 Fiddler
在服务器 PC 上创建一个反向代理,这样我就可以使用像 192.168.1.10:8888
这样的网站地址(我的网络服务器 PC 的 IP 地址和端口号)并获得 Fiddler
捕获该地址并将其转换为 http://fitly
并将其传递给 Apache,然后 Apache 将正确找到我的开发虚拟托管站点。
为此你需要安装 Fiddler
which can be found here and is free
首先确保您的虚拟托管域在 PC 运行 WAMPServer(Apache) 上正常工作。
然后对Fiddler
配置进行这些修改,不用担心,这很简单。 Here are the instruction on how to do that on the Fiddler Site 基本上是
Click Tools > Fiddler Options. Ensure Allow remote clients to connect is checked.
Click Tools > Fiddler Options, and ensure the "Allow remote clients to connect" checkbox is checked.
Restart Fiddler if prompted.
Click Rules > Customize Rules.
Inside the OnBeforeRequest handler*, add a new line of code:
if ( oSession.host.ToLower() == "192.168.1.2:8888" ) {
oSession.host = "fitly";
}
192.168.1.2
being the ip address of the PC running Apache i.e. the IP Address of the PC we have installed WAMPServer(Apache) and Fiddler.
- Using the device, go to
http://192.168.1.2:8888
. Fiddler should now capture that address and forward it on to Apache using the domain name of your Virtual Host so Apache can see it and pass you to the right site, similiarly responses will be sent back to the device that made the call.
当然你可以使用任何你喜欢的端口号,不必是 8888
.
You will also find Fiddler very useful for debugging many issues with your website, so dont assume its just a reverse proxy alone.
我正在尝试在其他设备(主要是移动设备)上查看我的网站。我将 Wampserver 3.0 与 apache 2.4.17 一起使用。我还使用 wampserver 内置的虚拟主机功能来查看我的站点,我的代码不在 wamp64\www\ 文件夹中,而是在我的文档文件夹中。我已经能够允许其他设备查看 wampserver 默认页面,但是每当我访问我的网站时,我都会得到 "fitly's server DNS address could not be found"
这是 httpd-vhosts.conf 文件
<VirtualHost *:80>
ServerName localhost
DocumentRoot C:/wamp64/www
<Directory "C:/wamp64/www/">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName fitly
DocumentRoot c:/users/juan/documents/fitly
<Directory "c:/users/juan/documents/fitly/">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
这是我过去使用过的解决方案。虽然我承认肯定还有别的 我发现 none 的方法是 quicker/easier 来实施。
Here is another way, without using Fiddler
基本问题当然是我们无法通过移动设备通过名称寻址我们的虚拟主机,即使它通过 wifi 连接到我们的路由器子网,因为设备浏览器当我们尝试使用它时不知道在哪里可以找到我们的虚拟托管域名。
由于大多数(如果不是全部)移动设备都被锁定,并且假设您像我一样不想 jailbreak
所有测试设备,我们不能简单地将我们的虚拟主机名称添加到设备HOSTS 文件,该文件当然存在,但设备安全性阻止我们访问它。
所以我使用 Fiddler
在服务器 PC 上创建一个反向代理,这样我就可以使用像 192.168.1.10:8888
这样的网站地址(我的网络服务器 PC 的 IP 地址和端口号)并获得 Fiddler
捕获该地址并将其转换为 http://fitly
并将其传递给 Apache,然后 Apache 将正确找到我的开发虚拟托管站点。
为此你需要安装 Fiddler
which can be found here and is free
首先确保您的虚拟托管域在 PC 运行 WAMPServer(Apache) 上正常工作。
然后对Fiddler
配置进行这些修改,不用担心,这很简单。 Here are the instruction on how to do that on the Fiddler Site 基本上是
Click Tools > Fiddler Options. Ensure Allow remote clients to connect is checked.
Click Tools > Fiddler Options, and ensure the "Allow remote clients to connect" checkbox is checked.
Restart Fiddler if prompted.
Click Rules > Customize Rules.
Inside the OnBeforeRequest handler*, add a new line of code:
if ( oSession.host.ToLower() == "192.168.1.2:8888" ) { oSession.host = "fitly"; }
192.168.1.2
being the ip address of the PC running Apache i.e. the IP Address of the PC we have installed WAMPServer(Apache) and Fiddler.
- Using the device, go to
http://192.168.1.2:8888
. Fiddler should now capture that address and forward it on to Apache using the domain name of your Virtual Host so Apache can see it and pass you to the right site, similiarly responses will be sent back to the device that made the call.
当然你可以使用任何你喜欢的端口号,不必是 8888
.
You will also find Fiddler very useful for debugging many issues with your website, so dont assume its just a reverse proxy alone.