Index: [Article Count Order] [Thread]

Date: Mon, 21 Feb 2005 16:36:00 -0500
From: Lloyd Zusman <ljz@asfast.com>
Subject: [webricken:140] Virtual hosts and inherited directory mappings
To: webricken@notwork.org
Message-Id: <m3mztxk33z.wl%ljz@asfast.com>
X-Mail-Count: 00140

I'm using the virtual host mechanism of WEBrick, and I'm trying to make
use of shared directories.  I'm not sure what is the best way to do
this, and I'm wondering if you folks could give me recommendations.

Here's what I'm doing:

I create a main server which is an instance of WEBrick::HTTPServer.
Then, I create a number servers for my virtual hosts.  Each of these is
is also an instance of WEBrick::HTTPServer.  I then use the
#virtual_host method to connect these to the main server.

I want these virtual hosts to inherit directory mappings from the main
server, or from some sort of central resource.

For example:

  mappings for main server (mainserver.com):

    /img    =>   /var/www/img
    /icons  =>   /var/www/icons

  mappings for virtual host 1 (virthost1.com):

    /img    =>   /var/www/virthost1/img

  mappings for virtual host 2 (virthost2.com):

    /icons  =>   /var/www/virthost2/icons

  mappings for virtual host 3 (virthost3.com):

    [none]

I want virtual host 1 to inherit the /icons mapping from
the main server.

I want virtual host 2 to inherit the /img mapping from
the main server.

I want virtual host 3 to inherit both the /img and /icons
mappings from the main server.

In other words:

  mainserver.com/img    =>   /var/www/img
  mainsercer.com/icons  =>   /var/www/icons

  virthost1.com/img     =>   /var/www/virthost1/img
  virthost1.com/icons   =>   /var/www/icons

  virthost2.com/img     =>   /var/www/img
  virthost2.com/icons   =>   /var/www/virthost2/icons

  virthost3.com/img     =>   /var/www/img
  virthost3.com/icons   =>   /var/www/icons

I don't want to have to specify the inherited mappings for each virtual
host.  That way, if I happen to change the mappings for the main server,
these changes will automatically be seen and used by the virtual hosts.

How would you folks recommend that I do this via webrick?

Thanks in advance.


-- 
 Lloyd Zusman
 ljz@asfast.com
 God bless you.