Railo: Dynamic host configuration

BlueDragon and Railo Add comments

Probably the biggest advantage with ColdFusion is the simple installer and the way it hides all the complexities of JRUN and Java from you and most of the time just works right out of the big. One of the simplicities of which is requiring you to only create a web site on the web server and it just works. With Railo it is more complex as you also need to add a host entry to the servlet container (railo, Tomcat, Jboss etc).

Thankfully with Railo this extra step can be avoided as well with a simple regular expression that effectively generates the host entry on the fly. This does however only work on Resin, so if you are using another servlet container I think you are out of luck, but I'm not expert so don't take my word for it, check the docs or ask on the relevant forums if you can use a regex in the host entry.

 

The following single host entry is what I am using on cfmldeveloper.com for the free hosting and simply requires that you stick to a standardised directory format for the home directory of all your sites.

 

This example presume all the sites are located at

 

d:\wwwoot\[domain name]\wwwroot

 

You can of course modify it for your own requirements.

 

The regex also strips the www from the domain name before evaluating it so that this is not used in the path name. Without this it would evaluate www.mydomain.com and mydomain.com as different paths.

 

   1: <host regexp="(?:www\.)?(.+)">
   2:  
   3:         <host-name>${host.regexp[1]}</host-name>
   4:         <root-directory>D:/wwwroot/${host.regexp[1]}</root-directory>
   5:         <web-app id="/" root-directory="wwwroot">
   6:                   <!-- enable/disable directory browsing -->
   7:                   <servlet servlet-name="directory" servlet-class="com.caucho.servlets.DirectoryServlet"/>
   8:         </web-app>
   9:     </host>

0 responses to “Railo: Dynamic host configuration”

Leave a Reply

Leave this field empty

Powered by Mango Blog. Design and Icons by N.Design Studio