[plug] re: Apache virtual host

Jon Miller jlmiller at mmtnetworks.com.au
Tue Jun 3 20:09:28 WST 2003


The problem here is that the 192.168.0.1 box is on a VPN that can only get to the Internet by going through another gateway (192.168.1.3).  But since they have their own web server, I just want to redirect any request for 192.168.0.1 (203.111.222.223) to go to that server.  Any requests for 203.111.222.224 should be local to the request (192.168.1.3).
So If I understand you correctly, I should put in the virtualhost header the ip address as it would be from an outside request (203.111.222.223). Is this correct?

Thanks

Jon L. Miller, MCNE, CNS
Director/Sr Systems Consultant
MMT Networks Pty Ltd
http://www.mmtnetworks.com.au

"I don't know the key to success, but the key to failure
 is trying to please everybody." -Bill Cosby



>>> ryan at is.as.geeky.as 6:04:32 PM 3/06/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