Few days ago there was a post from Jerry Asher titled "[AOLSERVER] virtual hosting options and a fantasy ...." mentioning my proposals. I would like to present them fully to the public.
Indeed I've got two AOLserver improvement proposals. They are based on how we use AOLserver at Zjednoczenie.com, but are probably useful in general. We will also provide our implementation for both proposals which is in fact quite simple, because it utilizes mechanisms already available in AOLserver C code. I. Support for name-based url filters and handlers. For certain applications it is essential to manage several different url-spaces which are accessed by different DNS names (HTTP host headers). Real life examples are our Content Management System (CMS) manging many websites with different url-spaces or quite a few of sites we've build that present different url-space with different DNS name (co-branding). In those application you have to be able to handle many different url-spaces in one AOLserver 3.x series server (one collection of tcl libraries, nsvs, db pools, etc.), not from separate servers what is available in AOLserver 4.x series server. Currently in one server you cannot register two filters or url handlers under the same url pattern to handle request from different sources identified for example by HTTP host header. I propose to add ?-vserver vserver? switch to tcl procs managing url filters and handlers, eg. ns_register_filter ?-vserver vserver? when urlpattern proc ?arg? ns_regster_proc ?-noinherit? ?-vserver? urlpattern proc ?arg? It would allow to manage many url-spaces identified by vserver string. Current implementation of urltrie in nsd/urlspace.c (data structure to handle url-space) already allows to have many url-spaces identified by server parameter value (vserver string). Additional command ns_server has to be added to manage mappings from HTTP host header to vserver string. ns_vserver register VSERVER HOST ?HOST? ; # register host -> vserver mapping ns_vserver unregister HOST ?HOST? ;# unregister host -< vserver mapping ns_vserver get HOST ; # gets VSERVER for given HOST ns_vserver delete ?-noinherit? VSERVER ; # unregister all hosts related to given VSERVER which is needed to delete the vserver ns_vserver hosts ?-noinherit? VSERVER ; # list of registered hosts for given VSERVER ns_vserver base VSERVER ; # get base vserver for given vserver By using specially crafted vserver names it is very simple to implement url-space inheritance, eg. vs11::vs1::server1 means that vs11 inherits from vs1 which inherits from server1 and in opposite server1 is base for vs1 which is base for vs11. II. Enhanced url-space management API When you try to re-use certain AOLserver application components in many project you have to be able to map specific website url-space to your fixed components file-system layout. This is the approach taken by OpenACS and its packaging system. To achieve it OpenACS uses its own request processor fully rewritten in TCL though there is full internal support for virtual url-spaces (urltrie structure defined in nsd/urlspace.c) in AOLserver. But there is also very limited API for using it. I propose to define a few Tcl commands which will expose this functionality. ns_register_filter ?-vserver vserver? when method url adp ?arg? ns_register_proc ?-noinherit? ?-vserver vserver? method url proc ?arg? ns_register_adp ?-noinherit? ?-vserver vserver? method url adp ?arg? ns_register_proxy ?-noinherit? ?-vserver vserver? method url proxyURL ?arg? ns_url2file ?-vserver vserver? url ns_url2file_map ?-noinherit? ?-vserver vserver? url path ?arg? ns_url2file_arg ?-vserver vserver? url ns_register_filter and ns_register_proc are already there and are referenced for completeness ns_register_adp works for adp like ns_register_proc for Tcl procs and was already added to AOLserver 4.x series after my proposal some time ago ns_register_proxy is and interface to TCP proxying as implemented by nsvhr module. It would allow to handle part of url-space by some back-end. I disagree that there are already other solutions that do that better. They do it really good indeed but they don't provide you with the possibilities that gives you having that in AOLserver. For example with ns_register_proxy command you can easily integrate IMP webmail running on Apache under /webmail url subtree. By using AOLserver filters you can implement single authorization for your application and /webmail urlspace. Using Apache, Squid or LVS as a front-end you cannot achieve it. ns_url2file_* family allows to define directory and file mapping. For example you can map url prefix to whole directory tree or map single url to single file with -noinherit option. These command expose in Tcl functionality of alias.c module described in old AOLserver C manual available for example from http://www.tcl.tk/man/aolserver3.0/c-app2.htm. Those commands become very useful when used with ?-vserver vserver? option described in my first proposal. In my company Zjednoczenie.com we implemented both proposals for AOLserver 3.5.1. The implementation only extends current Tcl API, doesn't require changes to C API and adds no substantial overhead in request processing. So I would be pleased if it would be incorporated into the core. Here are details about our implementation. You get our implementation of those proposal from http://miniacs.zjednoczenie.com/download/vserv2.tgz This is AOLserver distribution prepared internally at Zjednoczenie.com On RedHat Linux you can build it with (I've build it on other Linuxes/Unixes but then it needs some tweaking): tar xzf nsdz7.tgz make prepare ; make Our modifications are kept as patches that are applied to standard AOLserver tarball during build process or separate modules. I will describe them briefly: * vserv-0.2: vserv.patch - patch to AOLserver core enabling vservers vserv.c - ns_vserver command implementation To use vserver we will have to change Ns_UrlSpecificGet to Ns_VServerUrlSpecificGet. They have the same API but the former implements vserver inheritance. In few places we'll had to change Ns_ConnServer to Ns_ConnVServer to get vserver instead of server from the request. There is no change to C API, because we simply pass vserver instead of server in may places. We could always get server from vserver by simple string operations. * nsvhr: nsvhr.c.binary.patch - patch to allow binary file upload through nsvhr nsvhr.c.patch - patch with ns_register_proxy command * nsurl2file: nsurl2file.c - based on alias.c, ns_url2file_map and ns_url2file_arg * nsregisteradp: nsregisteradp.c - implements ns_register_adp command for 3.x series AOLserver, in 4.x series it is already included into the core * as_location: as_location.c - installs custom LocationProc essential for name-based virtual hosting that returns location rather from HTTP host header then from config file settings (works like Apache directive UseCanonicalName Off described in http://httpd.apache.org/docs/mod/core.html#usecanonicalname). I've prepared a test cases for both proposals. After adding the following 127.0.0.1 localhost hostA hostA1 hostA2 hostB hostC hostD to you /etc/hosts you can run it by make test It is based on Tcl test framework and may be useful as a part of general test case framework for AOLserver. Presenting this proposal I would like to thank Piotr Szuca <[EMAIL PROTECTED]> for doing vserver implementation, Damian Czupryn <[EMAIL PROTECTED]> for his work on quite a few AOLserver enhancements and my colleges from Zjednoczenie.com for testing all of this in real life applications. I'm open to discussion about presented proposals and their implementations. Tomasz Kosiak <[EMAIL PROTECTED]> I. To remove yourself from this list: Send a message to "[EMAIL PROTECTED]" with the following text in the BODY of your message: signoff aolserver II. For a complete list of listserv options please visit: http://listserv.aol.com/ III. For more AOLserver information please visit: http://www.aolserver.com/
