Two www domains, one machine

Two www domains, one machine

Post by Jim Thoma » Thu, 24 May 2001 22:56:00



Hi,

I've got an apache web server up and running on a RH6.2 system.  Right
now this is the only box I've got sitting on a public IP address, but
I've got 28 more IP's at my disposal.

I'd like to use IP aliasing to get this machine to answer to two IP
addresses instead of one, and use the second IP address to host a
separate web site (on the same machine).

Will I need to run two httpd's to do this, or can apache be configured
to choose a different directory hierarchy based on the IP over which the
request was received?

Can anyone recommend a HOWTO?

--

Senior Applications Engineer          Web:     http://www.bittware.com
Bittware, Inc                         Tel:              (703) 779-7770
Reality continues to ruin my life. - Calvin

 
 
 

Two www domains, one machine

Post by Tim Hayne » Fri, 25 May 2001 05:56:40



> I've got an apache web server up and running on a RH6.2 system. Right now
> this is the only box I've got sitting on a public IP address, but I've
> got 28 more IP's at my disposal.

> I'd like to use IP aliasing to get this machine to answer to two IP
> addresses instead of one, and use the second IP address to host a
> separate web site (on the same machine).

You should really do it with 3 IP#s: have apache listening on two of them
and regard one as the `base' address (ie eth0, with :1 and :2 being the
service addresses). Want to know why? Think `httpd', `httpd', `sshd' and
`nmap' in that order. Nice.

Quote:> Will I need to run two httpd's to do this, or can apache be configured to
> choose a different directory hierarchy based on the IP over which the
> request was received?

Relevants bits you want in an httpd.conf:

| Listen a.b.c.d:80
| Listen v.x.y.z:80
|
| NameVirtualHost a.b.c.d
| NameVirtualHost v.x.y.z
|
| <VirtualHost a.b.c.d:80>
|         ServerName www.abcd.com
|         ServerAlias www.abcd.org
|         DocumentRoot /var/www/hosts/abcd
|         <Location />
|           Order allow,deny
|           Allow from all
|         </Location>
| </VirtualHost>
|
|
| <VirtualHost v.x.y.z:80>
|         ServerName www.vxyz.com
|         ServerAlias www.vxyz.org
|         DocumentRoot /var/www/hosts/vxyz
|         <Location />
|           Order allow,deny
|           Allow from all
|         </Location>
| </VirtualHost>

Quote:> Can anyone recommend a HOWTO?

Oh, definitely. What next, a relevant one? ;)

Actually, the best docs are probably those to be found at
<http://httpd.apache.org/docs/mod/core.html>.

~Tim
--

How to get to Sesame Street?                | http://piglet.is.dreaming.org

 
 
 

Two www domains, one machine

Post by Dean Thompso » Fri, 25 May 2001 09:52:18


Hi Jim,

Quote:> I've got an apache web server up and running on a RH6.2 system.  Right
> now this is the only box I've got sitting on a public IP address, but
> I've got 28 more IP's at my disposal.

> I'd like to use IP aliasing to get this machine to answer to two IP
> addresses instead of one, and use the second IP address to host a
> separate web site (on the same machine).

Okay, you are aware that the WWW community is moving away from having a
separate IP address for each WWW site that you look after.  What you would
like to achieve can be achieved through NamedVirtual hosts and virtual host
directives.  Hence you can put a lot of WWW services on the same IP address if
you wish.

Quote:> Will I need to run two httpd's to do this, or can apache be configured
> to choose a different directory hierarchy based on the IP over which the
> request was received?

If you want to use two IP addresses (and I hope it is possible for you to use
one) then you will be able to do it all from the one machine.  It is just a
matter of changing the bind and listen directives and establishing a couple of
virtualhost directives at the end of the httpd configuration file.

Quote:> Can anyone recommend a HOWTO?

You can check out the IP-Aliasing HOWTO (http://www.linuxdoc.org) if you want
to put the two IP addresses on the same network card, but other than that you
should be able to follow the steps with the documentation on the apache.org
site.  There is no explicit HOWTO available which describes what you want to
do but you can piece if together.

See ya

Dean Thompson

--
+____________________________+____________________________________________+

| Bach. Computing (Hons)     | ICQ     - 45191180                         |
| PhD Student                | Office  - <Off-Campus>                     |
| School Comp.Sci & Soft.Eng | Phone   - +61 3 9903 2787 (Gen. Office)    |
| MONASH (Caulfield Campus)  | Fax     - +61 3 9903 1077                  |
| Melbourne, Australia       |                                            |
+----------------------------+--------------------------------------------+

 
 
 

Two www domains, one machine

Post by Jim Thoma » Fri, 25 May 2001 23:23:57



> You should really do it with 3 IP#s: have apache listening on two of them
> and regard one as the `base' address (ie eth0, with :1 and :2 being the
> service addresses). Want to know why? Think `httpd', `httpd', `sshd' and
> `nmap' in that order. Nice.

Thanks for the clues, Tim, but I'm a bit dense.  Can you elaborate?  I
suppose you might be hinting that I should use IP chains (or similar) to
block access to all ports on eth0:[12] except port 80 and open the ssh
port (23?) on eth0?  How does nmap play into this?

Quote:> Relevants bits you want in an httpd.conf:

[snip]
That was very informative.  I did find a page at apache.org that talks
about virtual hosts, but it was not as concise as your example.
Thanks.  

Quote:

> > Can anyone recommend a HOWTO?

> Oh, definitely. What next, a relevant one? ;)

heh heh.  Yeah, that's what I had in mind.  But I already found relevent
info (as mentioned above).  Here's a link for posterity:
http://www.apache.org/docs-2.0/vhosts/index.html

Quote:

> Actually, the best docs are probably those to be found at
> <http://httpd.apache.org/docs/mod/core.html>.

Thanks again!

--

Senior Applications Engineer          Web:     http://www.bittware.com
Bittware, Inc                         Tel:              (703) 779-7770
Reality continues to ruin my life. - Calvin