[mod_python] How to make a handler for static files?

Scott Chapman scott_list at mischko.com
Tue Feb 28 03:51:36 EST 2006

Jorey Bump wrote:
> Scott Chapman wrote:
>> Why would I want to experiment with a thing like this?  I want to be 
>> able to add virtual servers to my site without having to restart 
>> Apache and I want to further centralize things.
> If this is your only goal, consider using mass virtual hosting, instead:
> NameVirtualHost *:80
> <VirtualHost _default_:80>
>   # default host to catch probes and undefined hosts
>   ServerName server.example.net
>   ServerAdmin admin at example.net
>   DocumentRoot /var/www/vhosts/default
>   # refuse all requests to the default host
>   <Directory /var/www/vhosts/default>
>     Order allow,deny
>     Deny from all
>   </Directory>
>   ErrorDocument 403 "Access to this location is forbidden.
> </VirtualHost>
> <VirtualHost *:80>
>   ServerAdmin admin at example.net
>   # mass virtual hosting
>   # apache will look for DocumentRoot using name of requested host (%0)
>   VirtualDocumentRoot /var/www/vhosts/%0/site
>   # reconstruct self-referential URLs using hostname sent by client
>   UseCanonicalName Off
> </VirtualHost>
> The above configuration would serve requests for http://sub.example.com 
> from:
>  /var/www/vhosts/sub.example.com/site
> The only configuration necessary is to set up DNS, create the 
> appropriate directory, and upload the files. There is no need to restart 
> Apache. Hits to the default host are refused in the example, mainly to 
> reduce noise in the logs from worms and other probes. To log all hits to 
> a single file, just put %V at the start of your LogFormat string to 
> indicate the virtual host for the request. The modified common format 
> would look like this in httpd.conf:
> LogFormat "%V %h %l %u %t \"%r\" %>s %b" vcommon
> CustomLog /var/log/apache/vcommon_log vcommon

Thanks tons for the help!  I had not heard of Mass Virtual Hosting in Apache. 
It looks like it will be a good clean solution.


More information about the Mod_python mailing list