[plug] re: Apache virtual host

Ryan ryan at is.as.geeky.as
Tue Jun 3 18:04:32 WST 2003


On Tue, 2003-06-03 at 18:02, Jon Miller wrote:
> I have Apache installed on a RHL72 server.  I would like to know how do I go about setting up a virtual host for 2 private companies using the same ipaddress from the internet?
> In other words, if someone is looking for xyz.com.au (203.111.222.223) they are automatically redirected to ip address 203.111.222.224  
> On the one web server I want to be able to redirect any requests to their server located at 192.168.0.1. Do I do this with the following virtual host directive?
> 
> # <VirtualHost 192.168.0.1>
> #    ServerAdmin admin at domain.com.au
> #    DocumentRoot /var/www/html/public_html
> #    ServerName www.domian.com.au
> #    ErrorLog logs/domain.com.au-error_log
> #    CustomLog logs/domain.com.au-access_log common
> # </VirtualHost>
> 

The IP listed in the VirtualHost block header is the IP address it will
listen to requests on and the ServerName or ServerAlias is the domains
it will respond to on that IP.

When you add more than one virtual host for the same IP, you will
probably get an error - and the answer is:

   NameVirtualHost 203.111.222.223:80

If 192.168.0.1 is the same box as 203.111.222.223, then that would work
if you sepcify the external IP in the VirtualHost tag.  What you listed
would work internally, but requires the external IP in the local IP
place to work externally.  I often list them both depending on the
network setup.

If 192.168.0.1 is another box behind the first, you need more.

To make it then go to a different physical web server you want to use
the proxy_module and ProxyPass/ProxyPassReverse directives within the
virtual host block.

As an example, on of my boxes has a webmail virtual host that diverts to
another internal web server, and in the virtual host declaration for it
I have this:

  ProxyPass        / http://10.2.1.20/
  ProxyPassReverse / http://10.2.1.20/

It doesn't have to be an internal web server either, you can do all
sorts of wonderfully messy stuff with it.

Ryan




More information about the plug mailing list