[Novalug] Point multiple IPs to one server?

Jeff Stoner leapfrog at freeshell.org
Thu Jan 3 14:00:58 EST 2008


On Thu, 3 Jan 2008, Joel Fouse wrote:

> Hmm...a follow-up question on this.  What about when the box is actually
> on a vlan, and currently it only "knows" (at the OS level) of an
> internal IP address (192.168-type) but it receives traffic from a public
> routable IP?  For the time being (pre-multiple-IPS) it works fine,
> because Apache is just configured to listen to any port 80 traffic.  How
> does the multiple public IP thing work out in this scenario, through to
> the Apache configs?

Then you have to use name-based virtual hosting. It doesn't matter which 
IP the request comes in on, they all get routed to the internal 
192.168.x.y address. What distinguises each request will be a Host: header 
sent by the user agent. Apache will use that header to decide which 
virtual host will handle the request.

NameVirtualHost *:80

<VirtualHost *:80>
    # The first defined virtual host is the default virtual host
    # any request that doesn't have a Host: header or a configured
    # virtual host to handle it will land here
    DocumentRoot /var/www/default
</VirtualHost>

<VirtualHost *:80>
    ServerName www.site1.cop
    ServerAlias shop.site1.cop download.site1.cop
    DocumentRoot /var/www/site1
</VirtualHost>

<VirtualHost *:80>
    ServerName www.flintstones.cop
    DocumentRoot /var/www/fred
</VirtualHost>

http://httpd.apache.org/docs/2.0/vhosts/name-based.html

--Jeff

"I am not available for comment"




More information about the Novalug mailing list