1 Web Server - Multiple Names

2007-12-25 11:57:00

Great Responses, thank you all. This summary is quite lenghty.

I will give the short answers, but still include all replies

for posterity. If anyone has ever wanted to set up their web server

this way,,this mail contains all the info you'll need.

ORIGINAL POSTING:

> I have a SparcUltra running Sol2.5 as my web server

> running NCSA HTTPd NCSA/1.5.2

>

> I would like to configure it so that it could be accessed by

> different names and display a web page determined by what name

> it is called by.

>

SOLUTION: The only way to do it is to configure multiple interfaces

           on your web server and use the VirtualHost feature of the

           server software. A number of people recommended switching

           to Apache's web server. I've had no problems with NCSA so

           I stuck with it.

  **NOTE: This worked for my application - an intranet web server.

    By reading through all the replies I got, you may find more

    in depth and useful information.

1 I selected the address 159.75.3.35 as my additional ip address and

   had it added to the NIS hosts map

2. Added the following entry to httpd.conf:

<VirtualHost 159.75.3.35>

        DocumentRoot /user/eng_web/pdeng

        ServerName pdeng

        ResourceConfig /user/eng_web/http/conf/pdeng.conf

        ErrorLog logs/pdengerror_log

        TransferLog logs/pdengaccess_log

        AgentLog logs/pdengagent_log

        RefererLog logs/pdengreferer_log

        </VirtualHost>

3. Created a conf file for pdeng (See ResourceConfig above)

   For this all I did was copy my srm.conf to pdeng.conf and altered the

   Following entries:

        DocumentRoot /user/eng_web/pdeng

Now I got the new ip address working

4. Create /etc/hostname.le0:2 which contains 159.75.3.35

5. Set up the new interface

   # ifconfig le0:2 159.75.3.35 up

6. # ping 159.75.3.35

   159.75.3.35 is alive

7. Restart the web server and all is working.

CREDITS AND REPLIES

Special Thanks to Clay Irving, Chad Adams, Daniel Beaudry and

  Jochen Bern. Their information was so complete, that it couldn't

  have been easier to setup unless they came over and did it for me :)

Clay Irving <clay@garpac.com>

Chad Adams <u2ti9cma@crrel41.crrel.usace.army.mil>

Daniel Beaudry <Daniel.Beaudry@enter-net.com>

ServerAdmin WebMaster@enter-net.com

Jochen Bern <bern@penthesilea.uni-trier.de>

Dan Pritts <danno@fv.com>

Marcelo Maraboli <maraboli@dcsc.utfsm.cl>

Alex Finkel <afinkel@pfn.com>

Christian.Masopust@tmn.sie.siemens.at (Christian Masopust)

 "Matthew J. Hill" <MHILL@graver.com>

"Feeney, Tim" <Tim.Feeney@fmr.com>

Richard Snyder <rsnyder@eos.hitc.com>

"Brian T. Wightman" <wightman@sol.acs.uwosh.edu>

"Alfredo Sola" <asola@intelideas.com>

Kent Clarstroem <kent@istiden.pp.se>

Kevin Davidson <tkld@cogsci.ed.ac.uk>

Charles Gagnon <charles@Grafnetix.COM>

ALL REPLIES IN TOTAL:

********************************************************************************

Clay Irving <clay@garpac.com>

I'll walk you through an example:

Let's say your system has an IP address of 151.151.151.20 and you want

to configure 151.151.151.21:

ifconfig le0:1 151.151.151.21 up

This brings the interface up immediately, but you'll want to bring it up

on reboot -- In /etc create a file called hostname.le0:1 -- the content

of

the file is:

151.151.151.21

Ping the new IP address. If it's alive, configure your Web server.

Et voila!

********************************************************************************

Chad Adams <u2ti9cma@crrel41.crrel.usace.army.mil>

 I run an NCSA web server currently running 8 alternate IP addresses

and serving 9 different web "sites". It works quite excellent,

actually. If

you have the IP addresses to spare, I would recommend it. It's actually

very easy to set up. I'll enclose my config files:

/etc/rc2.d/S99crrel:

ifconfig le0 0.0.0.0

down

ifconfig le0:30 144.3.144.30 netmask

255.255.252.0

ifconfig le0:31 144.3.144.31 netmask

255.255.252.0

ifconfig le0:32 144.3.144.32 netmask

255.255.252.0

ifconfig le0:33 144.3.144.33 netmask

255.255.252.0

ifconfig le0:34 144.3.144.34 netmask

255.255.252.0

ifconfig le0:35 144.3.144.35 netmask

255.255.252.0

ifconfig le0:36 144.3.144.36 netmask

255.255.252.0

ifconfig le0 144.3.144.13

up

ifconfig le0:30

up

ifconfig le0:31

up

ifconfig le0:32

up

ifconfig le0:33

up

ifconfig le0:34

up

ifconfig le0:35

up

ifconfig le0:36 up

httpd.conf :

<VirtualHost

144.3.144.30>

DocumentRoot

/export/home/e1paopms

ServerName

www.nab.usace.army.mil

ResourceConfig

conf/srm-nab.conf

</VirtualHost>

                                                                               

<VirtualHost

144.3.144.31>

DocumentRoot

/opt/NCSA-httpd/htdocs-crrel.31

ServerName

www.crrel.usace.army.mil

ResourceConfig

conf/srm-crrel.conf

TransferLog

logs/crrel_access.log

</VirtualHost>

                                                                               

<VirtualHost

144.3.144.32>

DocumentRoot

/opt/NCSA-httpd/htdocs-testweb.32

ServerName

testweb.crrel.usace.army.mil

ResourceConfig

conf/srm-testweb.conf

</VirtualHost>

             .

             .

             .

that's it! Reboot the machine (or just execute the rc2.d script) and

you're

all set. I hope this helps, let me know if you need more info.

:)

        Chad Adams

********************************************************************************

Daniel Beaudry <Daniel.Beaudry@enter-net.com>

Create a new file called /etc/hostname.le0:X, X beeing the last in

sequence number of /etc/hostname.le files. Write in the name of the

new web site. Like: In /etc/hostname.le0:2 We have:

www.dimalt.com

Modify the file /var/dns/db.Your.C.Class_address

Add the new IP address for this virtual web site Example:

4 IN PTR www.dimalt.com. ; Sparc 5, le0:2

Dont forget to change the DNS version file

Create a file /var/dns/db.DOMAINE_NAME

In fact, you can copy your primary db.domain_name and modify it to

reflect the settings for the new domain. Dont forget to change the

DNS version file

Add a new entry in /var/dns/named.boot to look like this:

primary dimalt.com db.dimalt

Add the entry for this virtual web site in /etc/inet/hosts to look like

this

206.116.122.4 www.dimalt.com

Tell the named there are changes in config files.

ps -ef |grep named Remember process ID of named

Kill -HUP processid

Enable the new address in the kernel ex:

ifconfig le0:2 206.116.122.4 -trailers up

Configure the Web server for the new virtual site.

Create a directory for this new site

Modify the file /opt/local/httpd/conf/httpd.conf

Here is a truncated sample of my file:

<VirtualHost 206.116.122.4 Required>

ServerName www.dimalt.com

ServerAdmin WebMaster@enter-net.com

ResourceConfig conf/srm.conf

DocumentRoot /home/http/dimalt

</VirtualHost>

Add a index.html page in the directory of the new virtual site

Stop and restart the web server

/etc/init.d/httpd stop

/etc/init.d/httpd start

Test it from your prefered browser.

Daniel Beaudry

********************************************************************************

Jochen Bern <bern@penthesilea.uni-trier.de>

It's the ONLY Way. The Request comes with a Server IP# and a Server

Port Number tagged onto it, NOT a (supposed) Server Name, and having

httpd listen to several Ports simultaneously is hard to program while

having it listen to Port X "on any IP# considered local" is trivial.

My virtual WWW Server isn't currently visible from the Outside (cause

our central Router's Admin is a Dork :-{ ), but I *have* two Servers

running on the same Machine (Solaris 2.4) and can vouch that it's

simple to set up. Look:

zeus:/home/bern% cat /etc/rc2.d/S99local

#!/bin/sh

#

# start/stop the local stuff

case "$1" in

'start')

        PATH=/usr/local/bin

        if [ -x /pub/etc/httpd ]; then

                /usr/sbin/ifconfig le0:1 136.199.54.188 up netmask + \

                        broadcast + -trailers

                /pub/etc/httpd

        fi

        ;;

'stop')

        for DAEMON in /pub/etc/httpd ; do

                PID=`/usr/bin/ps -ef | grep $DAEMON | awk '{print $2}'`

                if [ ! -z "$PID" ] ; then

                        /usr/bin/kill ${PID} 1> /dev/null 2>&1

                fi

        done

        ;;

esac

exit 0

zeus:/pub/etc/httpd-config% tail -20 httpd.conf | head -10

<VirtualHost 136.199.54.188 Required>

DocumentRoot /pub/public/WWW/static/WEP

ServerName WWW.WEP.Uni-Trier.DE

ResourceConfig httpd-config/WEP-srm.conf

ErrorLog /pub/Logs/httpd/WEP/error_log

TransferLog /pub/Logs/httpd/WEP/access_log

AgentLog /pub/Logs/httpd/WEP/agent_log

RefererLog /pub/Logs/httpd/WEP/referer_log

</VirtualHost>

zeus:/pub/etc/httpd-config% diff srm.conf WEP-srm.conf

7c7

< DocumentRoot /pub/public/WWW/static/Root


---
> DocumentRoot /pub/public/WWW/static/WEP
11c11
< UserDir public_html
---
> UserDir public_html_WEP
27c27
< ScriptAlias /cgi-bin/ /pub/public/WWW/bin/Root/cgi-bin/
---
> #ScriptAlias /cgi-bin/ /pub/public/WWW/bin/Root/cgi-bin/

(That last Change prevents CGI-bins on www.wep.uni-trier.de; There are
currently none installed, so I prefer to have the whole Thing disabled.)

R
********************************************************************************
Dan Pritts <danno@fv.com>

My understanding is that configuring it for multiple IP addresses
is the only way to do this. The system has no way of knowing what
the requested hostname was when the query comes in, by that time
it has been translated to an IP number.

If you give it multiple IP numbers then it does have a way of knowing.

I've talked to folks who've done this with solaris with no problems.
********************************************************************************
Marcelo Maraboli <maraboli@dcsc.utfsm.cl>
I have multiple name to different pages in the single server using
NCSA 1.5.2a HTTPD using virtual hosts.

you need to have the multiple IP on the single ethernet card using
/etc/hostname.le0:1 /etc/hostname.le0:2 and so on..

you put this new IP in an DNS wit antoher name, ie, www2.your.domain.edu

and configure the virtual host on httpd.conf and creat
a new_srm.conf file for each virtual host.

works fine for me..
********************************************************************************
Alex Finkel <afinkel@pfn.com>
I don't use NCSA httpd, but I would have recommended using virtual IP
addresses. The capability is built into Solaris, so I wouldn't have any
reservations about using it. Each virtual interface would have it's own
name which would be it's fully qualified name and not simply an alias.

The only possible drawback is if you are running short of IP addresses
on
the server's segment. Also, if you use Legato Networker/Solstice Backup
I
have heard of folks getting license errors but otherwise it should not
cause any problems.

- Alex

********************************************************************************
Christian.Masopust@tmn.sie.siemens.at (Christian Masopust)
I don't know much about NCSA-httpd (if it really supports VirtualHosts),
but try to use Apache! It's really great, configuration is as easy as
NCSA and it really supports VirtualHost.

If you can't figure it out with the Apache-documentation
(www.apache.org)
send me a mail and I'll give you my configuration files...
********************************************************************************
"Matthew J. Hill" <MHILL@graver.com>
i do not believe NCSA httpd has this capability, though the feature
may well have been added since i last checked. you will want to use
apache httpd anyway, it is a much better product in any case. the
VirtualHost _is_ the correct way to do this procedure, and, unless i
am mistaken, the only way. what you want to do, after all, is set up
virtual hosts, right? one machine that will answer to multiple names
and appear to 'be' more than one machine, by providing different web
pages to each one. you will, also, need to provide a separate IP
address for each name you have, and set up your machine to answer to
all of the addresses. that is how the web daemon will know which
address the hit is coming from. else, if you have all the names
pointing to the same IP address, it will think all the hits are
coming to the same name (only the IP address is passed to the machine
when a connection is made.)
********************************************************************************
"Feeney, Tim" <Tim.Feeney@fmr.com>
Not sure why you are not comfortable with the multiple ip addresses, it
is quite easy to setup on Solaris. The problem that you run into with
the same IP address but different names is that the tcp/ip packets only
have the ip address as an identifier. So when you look up the ip
address you will always get the same name (ie. gethostbyaddr() will
always return sandia). Look in the FAQ regarding setting up the
multiple IP addresses for one card. This is the only way that I am
aware of to perform what you need, and how you need it.
********************************************************************************
Richard Snyder <rsnyder@eos.hitc.com>
If you're not stuck on using NCSA I'd suggest using Apache
(http://www.apache.org) instead. The virtual hosting is quite easy to
set up.
You will have to use a different IP for each of the virtual servers.
Use
multiple hostname.le0, hostname.leo:1, etc files to allow the machine to
listen
for multiple IPs. The documentation that comes with Apache should be
self
explanatory. If you have any other questions or I was too vague, I'd be
happy
to help.
********************************************************************************
"Brian T. Wightman" <wightman@sol.acs.uwosh.edu>
I think virtual hosts might be the way you want to go. You set up:

ifconfig le0:1 up xxx.xxx.xxx.xxx netmask + broadcast +

for each virtual address you want to have show up. The "1" in the
above example should be changed to a unique number for each interface.
********************************************************************************
"Alfredo Sola" <asola@intelideas.com>
Either configure multiple IP addresses, which is the standard
method, or use a Netscape server, in which case only Netscape clients
(not
sure about M$'s IExplore) would see the second and further servers.

My machine has multiple addresses and works just fine. I'm using DNS.
Feel free to e-mail me for more info.
********************************************************************************
Kent Clarstroem <kent@istiden.pp.se>
You should try Roxen (http://www.roxen.com/), it will give you many
times the speed you currently have, use less memory (which in the end
means even more speed, as you get more memory for OS buffers), provide
multihosting in a simple and innovative way with html-setup, use your
current cgi-bin's and imagemaps without any changes and last but not
least, IT'S FREE!

If you have any questions, please, don't hesitate to ask!
********************************************************************************
Kevin Davidson <tkld@cogsci.ed.ac.uk>
Each name must have a separate IP address. You can't do it with a
single IP address. Virtual addresses under Solaris are easy. Just pick
another couple of IP addresses on the same subnet and ifconfig them
up.

eg if your IP address is 123.4.5.6 and your netmask is 255.255.255.0
then you could do
ifconfig le0:1 address 123.4.5.7 up
ifconfig le0:2 address 123.4.5.8 up

and your host will now respond to all three IP addresses. Give each
one a different name in your DNS and hosts tables.
Put those names in the appropriate /etc/hostname.{le0,le0:1,le0:2}
file to automate this at reboot.

********************************************************************************
Charles Gagnon <charles@Grafnetix.COM>
I think the virtual host method is not only the *proper* method but the
*only* method also.

The setup is not only done thru HTTPD though, you need to setup
something like
VIF to allow your machine to hld more than one IP address.

--
Mark Belanger
Software Technician * Email : mjb@ltx.com *
LTX Corporation * Voice : (617) 467-5021 *
LTX Park at University Ave * Fax : (617) 329-6880 *
Westwood, MA 02090-2306, USA

Comments

Got something to say?

You must be logged in to post a comment.