wamp server 3.0 virtual host on another device

前端 未结 1 620
礼貌的吻别
礼貌的吻别 2021-01-17 01:00

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 wampserv

相关标签:
1条回答
  • 2021-01-17 01:38

    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.

    Here is another way, without using Fiddler

    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.

    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.

    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.

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

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

    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. Click Tools > Fiddler Options. Ensure Allow remote clients to connect is checked.

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

    3. Restart Fiddler if prompted.

    4. Click Rules > Customize Rules.

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

    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.

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

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

    0 讨论(0)
提交回复
热议问题