I have no idea where to start from so sorry in advance if this topic has already been discussed.
I usually develop web sites using my laptop as a development server, and recently I needed to test a web site using various mobile devices that can connect via wifi. Having no real AP, I set up a ad-hoc network using my laptop's wireless card and the devices can correctly browse the Internet and access the laptop's web server. The setup is as follows:
- subnet: 192.168.1.0/24
- gateway to the Internet (wired adsl router/modem): 192.168.1.1
- laptop: 192.168.1.64 (eth0, wired if connected to the gateway) and 192.168.1.32 (eth1, wifi if somewhat bridged to eth0)
- mobile devices (same for all, I only use one of them at any time for simplicity): 192.168.1.11 with default gw 192.168.1.1
Now, if I open either 192.168.1.32 or 192.168.1.64 from the mobile devices, I correctly get the default host of my Apache configuration. However I usually work with virtual hosts for many practical reasons, one of which being Drupal's peculiar implementation of multi-sites. For those who don't know how this works, Drupal takes the request's hostname and searches into its sites/ subdirectories for an appropriate configuration file. So, for example, suppose I request www.example.com, then Drupal would search for a config file in the following directories:
sites/www.example.com/
sites/example.com/
sites/com/
sites/default/
So I decided to adopt the following style of virtual hosts: if the website I'm working on will be accessible using www.example.com I set up a sites/www.example.com/ directory and create a virtual host for local.www.example.com so Drupal have no trouble finding it. I've been told this is suboptimal from a dns point of view since I'd have to create an authoritative entry for example.com and turn Bind on only when I'm supposed to access the local copy, which is weird. However, if this is the only path I can follow, I still have some problems with Bind's configuration, as I couldn't find any guide that tells me in a clear, noob-friendly way, how to set up such an entry. On the other hand, I was wondering if I could set up an authoritative entry for local, so I could access www.example.com.local and tell in some way (which I don't even know if this is possible) Apache to put www.example.com instead of www.example.com.local in the relevant environment variable.
Anyway, I have a last problem, sort of: when I launch Bind in debug mode with high verbosity, and make 192.168.1.32 as the primary dns for the devices, the output doesn't say anything about requests being made from the devices to Bind, so I'm not even sure it comes into play.
As you can see, I'm a complete noob at these matters, but I'm eager to learn, so any help/pointer will be appreciated.
sorry for the delay, I finally found a solution after lots of experiments. First of all, here's the zone file I use for the local. domain:
to which I can add lines like
which results in the ability to query for www.example.com.local, and that's one thing.
In order to take into account of Drupal's weird behaviour, I actually found a solution that doesn't prevent me from working with the real remote www.example.com while working on a local copy, except that I had to set a zone for local.www.example.com and the host line for www which results in the odd and long www.local.www.example.com... frankly a bit too much to keep my mental health. I'll go for the local. way and s/.local// the database dump I'm going to deploy to the production server.
Thanks to everyone that replied.
One other solution is to setup a little proxy on your desktop machine (where you develop and host your sites with your multiple virtual hosts). For example, on Windows you could use Fiddler. If you are running Mac OS X or Linux, you can give a try to Charles (but it's not free).
Under Fiddler, you have to activate the option "Allow remote computers to connect" on the "Connections" tab of the options window.
Then you have to configure your mobile device to use the proxy. This can easily be done in the WiFi settings of the mobile device.
I expect that when you create your VirtualHost on your local web server you also edit your
hosts
file so that you can browse your sites locally. Now, you would like your mobile device to do the same.This is where the proxy comes into place. The proxy is able to read your local hosts file (
C:\Windows\System32\drivers\etc\hosts
or/etc/hosts
) so this means that your mobile device will be automatically routed to your local web server.What is also interesting with this solution, is that you can simulate slow traffic networks and clearly see what your mobile device actually downloads (quite useful when using media queries and responsive images).
I found this article that very well explains how to do it : Testing a Mac OS X web site using a local hostname on a mobile device
Well honestly you may have overcomplicated your situation, you don't really need bind as you can just enter
192.168.1.32 example.com
into your host file. If you want to learn how to use bind though try seeing what happens when you lookup that domain in NSlookup and see what it tells you, that can help a lot.