Skip to content

Virtualhosts over a network

pgib edited this page Nov 30, 2010 · 1 revision

Introduction

Traditionally, hosts created with virtualhost.sh only work from the host itself; that is, other computers (like a PC, for example) couldn't see the individual sites you were developing/hosting. Using dyndns.com, it is now possible to access your hosts externally. (Note that this includes Windows running inside Parallels, VMWare Fusion, or Sun Virtual Box.)

Get setup with DynDNS.com

  1. Signup for an account at dyndns.com.
  2. Add a new Dynamic DNS host.
  3. Choose a hostname and domain. For this example, we'll use virtualhost and gotdns.org, respectively.
  4. Check the Yes, alias ".hostname.domain" to same settings checkbox.
  5. Enter your computer's local IP address. eg. 10.0.1.4
  6. Click on the Create Host button.

Now, anything?.virtualhost.gotdns.org is going to point at your machine from within your network. To ensure this works if your IP address changes, download the DynDNS Updater client. (The big download box on the right side of the page.) Configure it to use your computers local interface rather than the public IP it can detect.

Configure virtualhost.sh

Create a file in your home folder called .virtualhost.sh.conf, and define the WILDCARD_ZONE to be your new host:

echo 'WILDCARD_ZONE="virtualhost.gotdns.org"' >> ~/.virtualhost.sh.conf

When this is set, a ServerAlias will be defined for any virtualhost you create. So, if you create a virtualhost called awesomesite, you can then access it at awesomesite.virtualhost.gotdns.org. If you want to enable this on any virtualhosts you have already created, simply run the script again, and it will overwrite the original Apache virtualhost file.

Clone this wiki locally