[plug] re: Apache virtual host

James Devenish devenish at guild.uwa.edu.au
Tue Jun 3 18:13:18 WST 2003


In message <sedce2ae.069 at mmtnetworks.com.au>
on Tue, Jun 03, 2003 at 06:02:09PM +0800, 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?

The Apache docs are most explicity in having "Virtual Host
Documentation" page with a heading "Name-based Virtual Hosts
(One IP address, multiple web site)"

Apache 1:
<http://httpd.apache.org/docs/vhosts/name-based.html>
Apache 2:
<http://httpd.apache.org/docs-2.0/vhosts/name-based.html>

> 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  

Be *careful* about the use of the word "redirected". It has specific
meaning for web servers (RFC 2616, Section 10.3, "Redirection 3xx"),
and is probably incorrect for what you are trying to ask for.

> On the one web server I want to be able to redirect any requests to
> their server located at 192.168.0.1.

So what does 203.111.222.224 have to do with it?

> Do I do this with the following virtual host directive?
> 
> # <VirtualHost 192.168.0.1>
> #    ServerName www.domian.com.au

The above line means "when a request is received at 192.168.0.1 and
within that request the hostname is specified by the web browser as
www.domain.com...". Therefore, that configuration belongs on the
computer that has IP address 192.168.0.1. Note that www.domain.com.au
need not be set to 192.168.0.1, but if it isn't (and it shouldn't be),
then you need to be proxying the web requests from a public IP address
through to 192.168.0.1. If, 192.168.0.1 is the SAME machine as
www.xyz.com.au, then you need simply ask Apache to listen on both IP
addresses and use the same VirtualHost instructions for both.  (If you
have no need for 192.168.0.1, then you don't even need Apache to listen
on that address -- it could just listen on the public IP address.)

On the other hand, if you had www.xyz.com.au pointing to 203.111.222.223
(Host A) but the web pages are served by 192.168.0.1 (Host B, a separate
computer from Host A), then 192.168.0.1 can have the configuration that
you posted but 203.111.222.223 needs some different.  For example:

<VirtualHost 203.111.222.223>
    ServerName www.domain.com.au
    ServerAdmin admin at domain.com.au
    ProxyPass / http://192.168.0.1/
    ProxyPassReverse / http://192.168.0.1/
</VirtualHost>

This is just an example. You might not even want to be using Apache on
203.111.222.223. The correct (robust, secure, efficient) solution will
depend on information that you have not provided.




More information about the plug mailing list