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:
C:. +---conf | uriworkermap.properties | workers.properties | +---isapi | isapi_redirect.dll | isapi_redirect.properties | \---logs
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 extension_uri=/jakarta/isapi_redirect.dll # Full path to the log file for the ISAPI Redirector log_file=C:\jk\logs\isapi_redirect.log # Log level (debug, info, warn, error or trace) log_level=info # Full path to the workers.properties file worker_file=C:\jk\conf\workers.properties # Full path to the uriworkermap.properties file worker_mount_file=C:\jk\conf\uriworkermap.properties
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!
PATH %PATH%;%SystemRoot%\System32\inetsrv 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 iisreset.exe /restart
Here are a few details about what is going on:
I hope this helps, at least it Worked On My Machine! ™