
		Dynamic Virtual Hosting - mod_dynvhost
			    !@funkcity.com
	

 The "mod_dynvhost" module will create pseudo name based VirtualHosts 
on the fly. All you need is a directory with the fully qualified domain
name  ( FQDN ) of your virtual site and the module will take care of
the rest.

1. Set up & dependancies.
2. What does it do?
3. What does it not do / What to lookout for?
4. Configuring
5. Logging

1. Set up & dependancies:

	1 - Set up the apache config line ( see INSTALL ).
	2 - Point your DNS record for your shiny new domain at the IP of
	    your apache box.
	3 - Put some content into your directory and point a browser
	    at it, done!

2. What does it do ? :

	mod_dynvhost will do these things when a request comes through :

	1 - Automatically change the DocumentRoot to match that directory. 
	2 - Set up a "webmaster@virtualdomain.com" ServerAdmin directive, 
	    this is seen upon any errors the server encounters.
	3 - Change the "ServerName" directive to your sites FQDN.	
	4 - Handle "/cgi-bin/" requests to the virtual host.
	5 - Handle "/icons/" for directory listings.
	6 - Allow user '~' directories under each Virtual Host.
	7 - Restrict CGIs to a minimum UID / GID ( block sys accounts from
	    executing CGIs). If either ID is under the min it will return
	    an 'HTTP_FORBIDDEN' error.

	The behavior for "/icons/" and "/cgi-bin/" directories is thus,
	if a local directory under the virtual hosts root directory
	exists ( e.g. /www/Virtuals/www.mydomain.com.au/icons ).
	Then the "/icons/" request will map to that directory,
	if that local directory does not exists, then mod_dynvhost
	falls through to the default apache ServerRoot ( in my case
	that works out to be "/usr/local/apache/icons" ).
	"/cgi-bin/" requests are much the same.

3. What does it not do / What to lookout for ? :

	Seperate log files ( yet ).
	Listening on ports other than 80
	IP based hosting ( duh )
	Probably a lot mode, but that's why you test it and let me know :-)

	Just note that if the Virtual site has the '/cgi-bin/' 
	then _all_ files inside will be treated as CGI, so images
	and html will not be served properly in there.

	If '/icons/' is found then all icons will be served from there,
	so make sure you have a copy of any icon file you will need.

4. Configuring :

EXAMPLE httpd.conf entry and mappings :

<DynamicVirtualHost /usr/local/apache/htdocs/Virtuals/>
HomeDir /Homes
</DynamicVirtualHost>

Requests will map like this :

        www.mydomain.com/~donky                 : /usr/local/apache/htdocs/Virtuals/www.mydomain.com/Homes/donky/
        www.mydomain.com/                       : /usr/local/apache/htdocs/Virtuals/www.mydomain.com/
        www.mydomain.com/blah                   : /usr/local/apache/htdocs/Virtuals/www.mydomain.com/blah
        www.mydomain.com/cgi-bin/blah.cgi       : /usr/local/apache/htdocs/Virtuals/www.mydomain.com/cgi-bin/blah
                                                  If it exists, otherwise it will fall back to the cgi-bin
                                                  configured in the main apache httpd.conf config.

If you want your VirtualHost users to be able to use .cgi's you can add something like this line to your httpd.conf :

        AddHandler cgi-script .cgi .pl

Then to limit CGI access to only certain users (eg. donky) a line like this will work :

	<Directory "/usr/local/apache/htdocs/Virtuals/www.mydomain.com/Homes/donky/cgi-bin">
		Options ExecCGI
	</Directory>

Or for all users of the domain 'www.mydomain.com' use this :

        <Directory "/usr/local/apache/htdocs/Virtuals/www.mydomain.com/Homes/"> 
                Options ExecCGI
        </Directory>
	
5. Logging :

You might also want to add the Hostname into your custom apache log format
otherwise you won't know what domain is serving the file.

My log lines line in the config look like this :
LogFormat "%v %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined_plus
CustomLog /usr/local/apache/logs/access_log combined_plus

The '%v' is the virtual hostname. My logs look like this :
my.virtual.domain 10.0.0.1 - - [17/Feb/2000:19:18:26 +1100] "GET /manual/images/sub.gif HTTP/1.0" 304 - "-" "Mozilla/4.7 [en] (WinNT; I)"

Then you can use the 'split-logfile' perl script that comes with apache in the $APACHE/src/support directory to write
out all the seperate log files.


Cherio!
