« Google Web Toolkit v1.5.2 Released | Main | Tomcat Logging - Logging X-Forwarded-For in Tomcat 6 »

09/06/2008

Connecting IIS with Tomcat using isapi_redirect

UPDATE

This article has been updated. It is now a HOWTO. You can find HOWTO: Set Up IIS and the Jakarta isapi_redirect Connector at the newly launched HOWTO section on this site.

This seems to be a popular search topic--getting the ISAPI_redirect (aka mod_jk) working in IIS. Setting this up can, surprisingly, be a real hassle. With the preview release of Microsoft's Application Request Routing add-on for IIS7, this may not be a big issue for much longer. For those of you who feel leery about version 1.0 of anything from Microsoft (and even more timid to roll out an early beta on production systems), then the only game in town for connecting IIS to a tomcat/jboss/jetty/geronimo etc., server is to use the isapi_redirect.dll from the tomcat connectors project.

Download the latest binary of isapi_redirect.dll from the tomcat connectors download mirrors area. At the time of this writing, the latest version is named isapi_redirect-1.2.26.dll.

You will also need to create a few text files. One is a workers.properties file, which is not much different from the type you'd create for apache, one is named uriworkermap.properties (which serves a similar role to the JkMounts you would place in an apache config), and one is a .reg file that you will use to import settings into your Windows system registry.

Create a directory off the root of whatever drive you want on your IIS server and call it whatever you want but it should be something descriptive like c:\tomcat\connector or something like that. Create a subdirectory called "bin" and a second subdirectory called "conf". Save isapi_redirect-1.2.26.dll into the bin directory. Make a copy of it and call it "isapi_redirect.dll". The three text files will be created in the 'conf' directory. Create a third directory off of c:\tomcat\connector named "logs". isapi_redirect.dll is an ISAPI Filter, so you don't need to worry about registering it first to get it to work. Simply load it up into your existing ISAPI filter property tab in IIS. Don't worry--it is not going to work yet. Not until the other items below are completed.

If you are using IIS5 or IIS6, you will also need to modify the allowable Web Service Extensions and enable support for isapi_redirect.dll. Open the IIS Manager, go to Web Service Extensions. Create a new extension, name it "jakarta connector" and input the path to the isapi_redirect.dll and then check the box to enable it.

If you are using IIS7, you pretty much do the same thing but you don't enable if from the Web Service Extension setting--you double click the ISAPI and CGI Restrictions setting and add it there.

While you're in the IIS Manager, create a virtual directory off the root of your web site, name it "jakarta", and point it to your c:\tomcat\connector\bin directory. Execute permissions are OK.

Next, create a file named modjk.reg. Add the following values into the file--these are bare minimums and all paths assume you have everything sitting in c:\tomcat\connector:

REGEDIT4

[HKEY_LOCAL_MACHINE\SOFTWARE\Apache Software Foundation\Jakarta Isapi Redirector\1.0]
"server_root"="C:\\tomcat\\connector\\" "extension_uri"="/jakarta/isapi_redirector.dll"
"worker_file"="C:\\tomcat\\connector\\conf\\workers.properties"
"log_file"="C:\\tomcat\\connector\\logs\mod_jk.log"
"worker_mount_file"="C:\\tomcat\connector\conf\uriworkermap.properties"
"log_level"="INFO"

Save the file, then right-click on it and and select the "Merge" command. This will import it into the windows registry.

Create workers.properties. A basic workers.properties for connecting to a local tomcat instance will look like the following:

worker.list=local

worker.local.port=8009
worker.local.host=localhost
worker.local.type=ajp13
worker.local.lbfactor=1

That's enough to get you started. The last file you'll create is uriworkermap.properties. A basic one for a tomcat-hosted web application named "coolWebApp" will look like this:

/coolWebApp/*=local

Then restart IIS and you are done. You can verify that the ISAPI filter loaded by re-opening Internet Service Manger and checking your loaded ISAPI filters. If it is not loaded, re-check your registry settings because there is a mistake there somewhere. The following outline might help in keeping everything together:


  1. Download isapi_redirect from Tomcat Connectors site
  2. Create local directories for binaries, configuration files, and logs
  3. Create mod-jk.reg file and merge it into the registry
  4. Create workers.properties
  5. Create uriworkermap.properties
  6. Install ISAPI filter in IIS
  7. Create jakarta virtual directory
  8. Restart IIS


Microsoft IIS 7 Implementation and Administration (Mastering)

TrackBack

TrackBack URL for this entry:
https://www.typepad.com/services/trackback/6a01156fbc6fe6970c0115722881c2970b

Listed below are links to weblogs that reference Connecting IIS with Tomcat using isapi_redirect:

Comments