[TriLUG] Running Apache on 2 ip addresses

Aaron S. Joyner aaron at joyner.ws
Fri Apr 23 12:42:23 EDT 2004


>
>
>What is the best way to accomplish what I want to do?  
>
Well, any of the things you describe are possible, but you asked what 
the "best" way is.  That's subjective, but I'll see if I can help.

Generally speaking, unless there's a *specific* reason why you want 
these IP addresses on different nics (say throughput, security 
considerations, etc), then it's simpler (in my mind at least) to have 
one nic with two IPs.  There are certainly advantages to dividing up 
between two nics under certain circumstances (failover being one big one 
- no need to take down the machine right away if a nic dies, just change 
a little bit of configuration), but if it's just a general config, one 
nic with two IPs is probably simpler from a physical standpoint.

Regardless of how you configure the NICs and IP addresses (as long as 
they work), apache's setup is still the same.  Tell apache to listen on 
all IPs, and do name based virtual hosting:

> Listen 80    # Don't specify an IP address with the Listen directive
> # Listen 443   # You can also use the same syntax for SSL, note: 
> there's a lot more than this to SSL
> NameVirtualHost *

Then setup your individual virtual server containers to listen to 
certain names:

> <VirtualHost *>
>     ServerName www.example.com
>     DocumentRoot /home/example.com
> </VirtualHost>
> <VirtualHost 1.2.3.4>
>     ServerName site2.example.com
>     DocumentRoot /home/site2
> </VirtualHost>

The first of those virtual hosts will respond to www.example.com on any 
IP address.  The second one will respond to site2.example.com only on 
1.2.3.4.  That should be enough to get you started toward configuring 
Virtual Hosts in apache.  If you have more specific questions, hit the 
docs or post more details about the specifics.  :)

Aaron J.


spain at ncssm.edu wrote:

>I have a server with 2 NICs each with an Public IP address on the Internet.
>One IP will server internal web applications and public streaming streams
>and the other will serve 3 public websites.  
> 
>As of right now, I have 1 instance of apache running.. and it's listening on
>port 80 of all ip addresses.. 
> 
>My vhost config isn't working correctly.. all the vhosts I've setup default
>to the main /var/www/html content with is the fedora core test page " you've
>successfully installed a webserver" .. 
> 
>My goal:  
>    *  the goal is to have 2 ip addresses assigned to this server and have
>multiple sites assigned to each individual address as needed.  currently I
>have 6 sites to setup but it will grow to probably about 20.. after I'm done
>with all the web app programming.. 
> 
>What is the best way to accomplish what I want to do?  
> 
>a)  Keep the 2 ipaddresses assigned to 2 nics and start 2 instances of httpd
>daemon that will listen each ip address  and serve content accordingly
>b) assign the 2 ipaddresses to 1 NIC  and run 2 daemons to listen to each
>IP?
>c)  or can 1 httpd daemon listen and serve vhosts across 2 different ip
>addresses?
> 
>Any advice is greatly appreciated.. Pls email me if I need to clarify my
>email.. 
> 
>  _____  
>
>Sincerely,
>Jamil Hassan Spain
>NC School of Science and Mathematics | External Programs 
>Phone: 919-416-2641
>Web: www.dlt.ncssm.edu <http://www.dlt.ncssm.edu/> 
>Email: spain at ncssm.edu <mailto:spain at ncssm.edu> 
>  _____  
>
> 
> 
>  
>




More information about the TriLUG mailing list