Project

General

Profile

Mod evhost » History » Revision 18

Revision 17 (hoffie, 2008-10-18 21:46) → Revision 18/23 (nitrox, 2008-10-18 21:51)

 [[TracNav(DocsToc)]] 
 h1. {{{ 
 #!rst 
 ======================== 
 Enhanced Virtual-Hosting 
 ======================== 

 *Module: mod_evhost* ------------------ 
 Module: mod_evhost 
 ------------------ 

 {{>toc}} .. meta:: 
   :keywords: lighttpd, virtual hosting 
  
 .. contents:: Table of Contents 

 h2. Description 
 =========== 

 mod_evhost builds the document-root based on a pattern which contains 
 wildcards. Those wildcards can represent parts of the submitted hostname 
 
 <pre> 
   
 

 :: 
  
   %% => % sign 
   %0 => domain name + tld 
   %1 => tld 
   %2 => domain name without tld 
   %3 => subdomain 1 name 
   %4 => subdomain 2 name 
 </pre> 

   evhost.path-pattern = "/home/www/servers/%3/pages/" 


 h2. 

 Options 
 ======= 

 evhost.path-pattern  
   pattern with wildcards to be replace to build a documentroot 


 h2. Samples 
 ======= 


 *User vhosts* User vhosts 
 ------------ 


 <pre> 
   :: 

   $HTTP["host"] =~ "users\.example\.org" { 
       evhost.path-pattern = "/home/%4/public_html/" 
   } 
 </pre> 

 http://johndoe.users.example.org/ => /home/johndoe/public_html/ 

 h2. General Example 
 ---------------- 

 <pre> 
   :: 

   server.document-root = "/home/user/sites/" 
   evhost.path-pattern    = "/home/user/sites/%0/site/" 
 </pre> 

 


 If example.org is requested, and /home/user/sites/example.org/site/ is found, that path becomes the docroot. 

 If example.net is requested but is not found in ''/home/user/sites/ then the docroot remains as /home/user/sites/ 

 This is actually a bad example. server.document-root should never point to the directory with your evhost subdirs. 

 Let us assume we got foo.example.com and bar.example.com pointing to the server. 

 
 for foo.example.com we have /home/user/sites/foo.example.com/site but for bar no directory exists. 

 For foo.example.com we configure auth via: 

 <pre> 
   :: 

   $HTTP["host"] == "foo.example.com" { 
     auth.require = ( "/" => ... 
     )  
   } 
 </pre> 

 If we now access http://bar.example.com/foo.example.com/site/ we bypass the configured auth in the vhost block. 

 A better example would be 

 <pre> 
   :: 

   server.document-root = "/home/user/sites/default/site" 
   evhost.path-pattern    = "/home/user/sites/%0/site/" 
 </pre>