I wanted to automate as much as possible the process of configuring the Apache Tomcat Redirector for IIS 7. You can find detailed how-to documents describing how to configure the ISAPI filter manually, but I couldn’t find any ready-made scripts to automate the process using IIS 7’s AppCmd command. My goal is eventually to get Apache and an IIS front-end running in Windows Azure, but this will have to wait for another post!
The first thing you need to do is of course to download the ISAPI filter binaries from the Apache repository. Be careful to download the 64bit version if you run a 64bit OS, like Windows Server 2008 R2, or you will see error messages when IIS tries to load the IIS filter.
The other thing I couldn’t find immediately are the sample configuration files that are mentioned in the Apache documentation (workers.properties and uriworkermap.properties); I finally found them in the source archive, so I would advise you to download this as well, and look in the conf directory for the samples.
Then you need to organize things somewhat on your drive; I arranged the various files like so:
A couple notes:
And now, the isapi_redirect.properties file:
# Configuration file for the Jakarta ISAPI Redirector
# The path to the ISAPI Redirector Extension, relative to the website
# This must be in a virtual directory with execute privileges
# Full path to the log file for the ISAPI Redirector
# Log level (debug, info, warn, error or trace)
# Full path to the workers.properties file
# Full path to the uriworkermap.properties file
And now we need to configure IIS so that it will run the ISAPI filter; there are basically four tasks we need to accomplish:
And without further ado, the script!
for /f "tokens=*" %i in ('appcmd.exe list site /text:name') do set SITE=%i
appcmd.exe set config /section:isapiCgiRestriction /+[@start,description='Tomcat',path='C:\jk\isapi\isapi_redirect.dll',allowed='true']
appcmd.exe set config /section:isapiFilters /+[@start,name='Tomcat',path='C:\jk\isapi\isapi_redirect.dll']
appcmd.exe add vdir /app.name:"%SITE%/" /path:/jakarta /physicalPath:c:\jk\isapi
appcmd.exe set config "%SITE%/jakarta" /section:system.webServer/handlers /accessPolicy:Read,Write,Execute
Here are a few details about what is going on:
I hope this helps, at least it Worked On My Machine! ™