views:

659

answers:

2

I have been working on a drupal test site for a while, which has a bunch of virtual hosts set up like this:

<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot "/path/to/root"
ServerName testsite1.example.com
</VirtualHost>

I have been using a modified host file to view each of these test sites, along the lines of:

12.0.0.1 localhost
20.02.2.22 testsite1.example.com
20.02.2.22 testsite2.example.com
20.02.2.22 testsite3.example.com

This has worked fine, however now I need to send the sites over to some people remotely who are not technical enough to modify their own host files and see it the way I do.

Is there a way I could set up Apache so that the url "http://20.02.2.22/testsite1" would forward to testsite1.example.com internally? I am using Drupal, and the site setup needs to see the "testsite1.example.com" so that it can correctly choose the instance to select. I have been looking through apache rewrite, but I am a bit of a newb at this so any help is much appreciated.

A: 

testsite1.example.com will only be resolved on your machine, so you cannot redirect. You can set up proxy with mod_proxy. Hope this works for you:

<VirtualHost *:80>
  ServerAdmin [email protected]
  DocumentRoot "/path/to/root"
  ServerName testsite1.example.com
  ServerAlias 20.02.2.22
  <Location /testsite1/>
    ProxyPass http://testsite1.example.com/ 
  </Location>
</VirtualHost>
vartec
This came close, but instead of simply sending the request internally, it causes the browser to request testsite1.example.com, which doesn't exist. Thanks though, mod_proxy is a great direction it seems.
jacobangel
A: 

The way I show my local test sites is a combination of Dynamic DNS and port-forwarding.

Internally, my Drupal site is at [my machine ip] or localhost.

I setup a free dynamic dns name to my IP and then on my router, accept incoming requests on port to route to [my machine ip]

That way, they can see yoursite.dyndns.com, but its looking at your local copy.

Bright Plum