Web Trenches

Railo – Multiple contexts on ONE instance

For a specific installation of Railo, I had to make a single instance of Railo run multiple sites (contexts) in IIS that share one domain name.  Normally you would make separate contexts by modifying server.xml and specifying a different domain name for each site/context.  Like this…

<Host name="site1.domain.com" appBase="webapps">
<Context path="" docBase="E:\webroot1" />
<Host name="site2.domain.com" appBase="webapps">
<Context path="" docBase="E:\webroot2" />

However, in my case I needed the two separate contexts to run on ONE domain name with different ports.  To do this, you need to set up separate services (not separate servers).  Then, using the Boncode IIS connector, connect the separate sites to those services.

These steps assume that your IIS sites are already set up and running and separate ports, and Railo is installed.

  1. Edit {railo install}\tomcat\conf\server.xml
    • copy the entire <Service> node and all its contents to create a new <Service> node.  
    • Remove the Connector node in the new Service that has 8888 as the port.
    • Change the Connector node that has your other port (usually 8009) to a new available port – 8010 for example.
  2. Save server.xml and Restart Railo.  You now have two services running on separate ports.  These are not the same ports the websites will run on, just internal ports used by Tomcat and IIS.
  3. Uninstall the Boncode connector that installed with Railo (older versions don't have this).  To do this, run the uninstaller that is in the AJP13 folder.  (If you don't have an uninstaller, you can just stop IIS and Railo, and then delete the folder.  This will break your Railo sites, but the steps below will fix them.)
  4. Delete the folder {railo install}/AJP13/
  5. Download a clean version of Boncode (http://tomcatiis.riaforge.org/) and extract to {railo install}/AJP13
  6. Run the BonCode installer
    • On the step for the AJP port, enter the port for your first/original service as defined in server.xml (usually 8009)
    • On the step for Global vs Site installs, choose "Let me choose specific sites".  THIS IS IMPORTANT
    • Choose the IIS site for your first context, then complete the installer.
  7. Go test your first site.  It should work and have its own context.  You should also notice it created a /BIN folder in your webroot with your settings file, including the service port you set up.
  8. Now, run the BonCode installer AGAIN.
  9. Repeat steps 6-7 above, but on step 6 enter the port for the second Service node you set up (in step 1 above).
When complete you should have two IIS sites with the same domain name, running on one Tomcat instance, in separate contexts.  Each will have its own Web admin, but they will share the Server admin.  http://dev.mydomain.edu:7070/ and http://dev.mydomain.edu:7071/ for example.  You can add more of these if you want repeating the steps and adding another <service> node in server.xml.

Leave a Reply

Your email address will not be published. Required fields are marked *