Virtual Web Server Hosting under OSF1 and NCSA HTTPD 1.5.2



What is virtual hosting?

Virtual hosting allows one physical machine to act as a host multiple unique web servers. Unique, in this instance, means having an IP address which is not the same as the hosting machine or any of the other servers on that machine.

For example, virtual hosting would allow you to have the web servers for www.foo.com(IP of 192.192.192.154) and www.bar.com (IP of 192.192.192.253) on one machine called goofball.foobar.com (IP of 192.192.192.1).

Configuring the HTTPD Server

The first step in configuring any machine to use virtual hosts is to properly modify the httpd.conf file. Under NCSA 1.5.2, virtual hosting is explicitly supported by use of the <VirtualHost;> section of the httpd.conf file.

<VirtualHost; 192.192.192.154 Optional>
DocumentRoot /www-foo
ServerName www.foo.com
ResourceConfig foo_srm.conf
ErrorLog /var/log/foo-httpd-error.log
TransferLog /var/log/foo-httpd-transfer.log
AgentLog /var/log/foo-httpd-agent.log
RefererLog /var/log/foo-httpd-referer.log
</VirtualHost>
The first line, <VirtualHost; 147.72.1.74 Optional>, specifically references the IP address of the web site. It must point to a legitimate IP address in order for it to work.

The DocumentRoot line points to the default directory from which the html documents for that web site will be served.

The ServerName is, of course, the name of the web site which corresponds to the IP address defined. The ServerName line is optional.

The next line, ResourceConfig, allows you to define a unique srm.conf file for that specific web site. If you don't define a unique srm.conf file it will automatically use the default srm.conf file defined earlier in httpd.c onf.

The remaining lines are used to place the various logs in specific log files. If these are not defined all logged information will go into the default log files previously defined in httpd.conf.

There are additional commands that you can place inside of the VirtualHost sction. For more information on these commands look at the comments within the httpd.conf file and at the NCSA Web Site.

Configuring the Interface on the Host Machine

The interface must also be configured to recognize the ip address of the virtual web servers. If this isn't done then all of the requests that go to that server will be ignored and eventually die an untimely death. Configuration of an interface is a relat ively trivial task if the alias command is supported by the ifconfig program.

Under OSF1 V3.2 to create an aliased ip address you simply need to enter
ifconfig interface ip_address alias
eg. ifconfig tu0 192.192.192.154 alias

This will effectively bind the named ip address to the named interface device.

However, if you enter the ifconfig alias at the command line it will lose this information after any sort of reboot. In order to make this a permanent change you will need to modify the /etc/rc.config file.

...
DISPLAYTYPE=
HOSTNAME="titania.pps.pgh.pa.us"
NUM_NETCONFIG="2"
MAX_NETDEVS="24"
NETDEV_0="tu0"
NETDEV_1="tu0"
NETDEV_2=
...
IFCONFIG_0="192.192.192.1 netmask 255.255.255.0"
IFCONFIG_1="192.192.192.154 netmask 255.255.255.0 alias"
IFCONFIG_2=
IFCONFIG_3=
...
There are three lines that you will have to be specifically concerned about:

NUM_NETCONFIG="N" where N is the total number of interfaces you are configuring. In the above example, two interfaces are being configured even though it is only one physical device.

NETDEV_X="interface" where X is the sequential number of total number of devices being configured and where "interface" referes to the device name.

IFCONFIG_X="ip.address netmask netmask.value [alias]"

After making the modification to the rc.config table you will need to restart the network services using /usr/sbin/rcinet restart. This will shut down all internet connectivity while it is restarting so you don't want to do during peak hours.

Limitations

OSF1 can only do virtual hosting for addresses within its subnet. The size of subnet can vary widely depending on how the network has been configured. If you have what is know as a 24bit subnet and the machine's address is 192.192.192.1 then all the virtu al hosts must exist between 192.192.192.2 and 192.192.192.254. Smaller and larger subnets also exist. You should contact the system or network administrator to get a valid address. If the virtual hosts ip adress is outside of the subnet it may lead to som e very erratic behaviour.

Problems discovered

One significant problem was found while setting up virtual hosting. For some reason after the restart the aliased ip address was being treated as the primary ip address. This prevented the machine from NFS mounting a remote file system because that IP add ress had no permission to do so.

This was corrected by shutting down the aliased interface with ifconfig down and then manually deleting the route from the routing table.

After further modifications to the rc.config table it was no longer a problem. The original instructions for modifiying the rc.config file included enter a :N after interface where N is number of the interface starting from 0.

For example:

NETDEV_0="tu0"
NETDEV_1="tu0:1"
NETDEV_2="tu0:2"
and so forth. Removing the :N value, for some reason, allowed the system to work properly.

 

Return to Server Information

 

Revision 1.0:Aug 30, 1996:CJR