在另一台设备上清理服务器3.0虚拟主机 [英] wamp server 3.0 virtual host on another device

查看:91
本文介绍了在另一台设备上清理服务器3.0虚拟主机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在其他设备(主要是移动设备)上查看我的网站.我正在将Wampserver 3.0与Apache 2.4.17一起使用.我还使用wampserver内置的虚拟主机功能来查看我的站点,我的代码不在wamp64 \ www \文件夹中,而是在我的documents文件夹中.我已经能够允许其他设备查看wampserver的默认页面,但是每当我转到我的网站时,我都会得到找不到合适的服务器DNS地址"

I am trying to view my site on other devices, mainly mobile devices. I am using Wampserver 3.0 with apache 2.4.17. I am also using the virtual host feature built in wampserver to view my site and my code is not in the wamp64\www\ folder, instead it is in my documents folder. I have been able to allow other devices view the wampserver default page but whenever I go to my website i get "fitly's server DNS address could not be found"

这是httpd-vhosts.conf文件

Here is the httpd-vhosts.conf file

<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>

推荐答案

这是我过去使用的解决方案.虽然我承认必须有其他 方式,我发现没有一种方法可以更快/更轻松地实现.

This is a solution I have used in the past. Although I admit there must be other ways, none that I have found are quicker/easier to implement.

这是不使用Fiddler的另一种方式

基本问题当然是,即使设备通过wifi连接到我们的路由器子网,我们也无法通过移动设备的名称来访问虚拟主机,因为设备浏览器不知道在哪里尝试使用它时,请找到我们的虚拟托管域名.

The basic problem is of course that we cannot address our Virtual Host by name from a mobile device, even when it is wifi connected to our routers subnet, because the devices browser does not know where to find our Virtual Hosted domain name when we try and use it.

如果不是所有移动设备都被锁定,并且像我一样,假设您不想jailbreak所有测试设备,那么我们不能轻易选择将虚拟主机的名称添加到设备的HOSTS文件中,当然确实存在,但是设备安全性阻止了我们对其的访问.

As most if not all mobile devices are locked down and assuming like me you dont want to have to jailbreak all your test devices, we cannot take the easy option of adding our Virtual Host's name to a devices HOSTS file, which of course does exists, but we are prevented by the devices security from accessing it.

因此,我使用Fiddler在服务器PC上创建反向代理,因此我可以使用192.168.1.10:8888这样的网站地址(我的Web服务器PC的ipaddress和端口号)并获取Fiddler来捕获该地址,并将其转换为http://fitly并将其传递给Apache,Apache将随后正确找到我的开发虚拟主机站点.

So I use Fiddler to create a reverse proxy on the Server PC so I can use a website address like 192.168.1.10:8888 (my web server PC's ipaddress and a port number) and get Fiddler to capture that address and convert it to http://fitly and pass that on to Apache which will then correctly find my development Virtual Hosted site.

为此,您将需要安装Fiddler 可在此处找到并且免费

For this you will need to install Fiddler which can be found here and is free

首先请确保您的虚拟托管域在运行WAMPServer(Apache)的PC上正常运行.

First make sure that your Virtual Hosted domain works properly on the PC running WAMPServer(Apache).

然后对Fiddler配置进行这些修改,不要担心它非常简单. 此处是有关如何执行此操作的说明Fiddler网站基本上是

Then make these amendments to the Fiddler config, dont worry its quite simple. Here are the instruction on how to do that on the Fiddler Site which are basically

  1. 单击工具>提琴手选项.确保已选中允许远程客户端连接".

  1. Click Tools > Fiddler Options. Ensure Allow remote clients to connect is checked.

单击工具> Fiddler选项,并确保选中允许远程客户端连接"复选框.

Click Tools > Fiddler Options, and ensure the "Allow remote clients to connect" checkbox is checked.

在出现提示时重新启动Fiddler.

Restart Fiddler if prompted.

单击规则">自定义规则".

Click Rules > Customize Rules.

在OnBeforeRequest处理程序*中,添加一行新代码:

Inside the OnBeforeRequest handler*, add a new line of code:

if ( oSession.host.ToLower() == "192.168.1.2:8888" ) { oSession.host = "fitly"; }

if ( oSession.host.ToLower() == "192.168.1.2:8888" ) { oSession.host = "fitly"; }

192.168.1.2是运行Apache的PC的IP地址,即我们已安装WAMPServer(Apache)和Fiddler的PC的IP地址.

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.

  1. 使用设备,转到http://192.168.1.2:8888. Fiddler现在应该捕获该地址,并使用您的虚拟主机的域名将其转发到Apache,以便Apache可以看到它并将您传递到正确的站点,类似的响应将发送回进行呼叫的设备.
  1. 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.

Of course you can use any port number you like it does not have to be 8888.

您还将发现Fiddler对于调试网站中的许多问题非常有用,因此不要仅凭其反向代理.

You will also find Fiddler very useful for debugging many issues with your website, so dont assume its just a reverse proxy alone.

这篇关于在另一台设备上清理服务器3.0虚拟主机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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