Every now and again I have to setup IIS and tomcat, this usually involves a gap of a year or so, so for my own sanity I have made some notes on how it sits together. Most of the issues involve jumping IIS versions.
I am assuming that the tomcat service is configured correctly, and I will only detail the tomcat to IIS setup.
We must download the ISAPI_rediect.dll ISAPI filter for IIS. ensure you have the correct version for your architecture (x86/x64).
http://apache.mirror.aussiehq.net.au//tomcat/tomcat-connectors/jk/binaries/
Extract the files into a location on the webserver, you will pointing a virtual directory at this location further on.
I love diagrams as it helps me visualise what is going on. So I have drawn a diagram to aid this
IIS
To get tomcat and IIS communicating we have to load an isapi filter into IIS that will handle the communications.
In my example I will be applying the isapi filter to a specific website in IIS, however you could if you wish add it at the server level and it will handle all sites within IIS.
First we have to tell IIS to allow the ISAPI filter. This is down at the server level within the ISAPI and CGI Restrictions.
Ok so now we go the site we want to allow the ISAPI filter to run on. And go to the ISAPI filters.
While still in the website in IIS, we need to add a virtual directory called Jakarta and point it to the path of isapi_redirect.dll.
Now click on the virtual directory and go to Handler Mappings, click “Edit Feature Permissions” and check “execute”
Ok so we have configured IIS. We now have to configure the properties files that are used by the dll.
Now the redirector can utilise the registry or configuration files. I will cover the config files as this allows you to run multiple redirectors with various configs.
Now in the same folder there should be a file called isapi_redirect.properties. This file provides the filter with its initial config.
isapi_redirect.properties
It gives the virtual directory location of the DLL withiin the website.
extension_uri
logfile location and log level
# Full path to the log file for the ISAPI Redirector
log_file=<physical path>\logs\isapi_redirect.log
# Log level (debug, info, warn, error or trace)
log_level=info
And the path to a couple of other properties files
# Full path to the workers.properties file
worker_file=<physical path>\conf\workers.properties.minimal
# Full path to the uriworkermap.properties file
worker_mount_file=<physical path>\conf\uriworkermap.properties
rewrite_rule_file=<physical path>\conf\rewrites.properties
As you can see I have placed the config files into a subfolder conf and the logs in logs folder, but they can exist anyway really.
So the dll uses this initial config file to provide further setup details.
rewrites.properties
I will ignore the rewrites.properties file as I don’t use it, but it basically allows you to rewrite the url.
This file tells the extension (isapi_redirect.dll) what constitues a valid request to pass to tomcat. In my case I want everything sent to the website
/*=worker1
So the wildcard means send everything to worker1. No whats worker1?
workers.properties.minimal
The worker is the process that actually communicates to the tomcat process. The workers.properties.minimal file contains the setup for the worker processes. I have only one called worker1 and it set up to call tomcat using ajp13 on port 8009 (usual port).
worker.worker1.type=ajp13
worker.worker1.host=localhost
worker.worker1.port=8009
The worker will send the request to tomcat and then handle the response back to IIS.
Once these have all been configured, ensure the tomcat process is running. Restart the website in IIS and everything should work.
I reference these blogs/pages which provide further excellent info.
http://jspors.blogspot.com/2009/01/setting-up-64-bit-tomcat-6-on-iis7.html
http://tomcat.apache.org/connectors-doc/reference/iis.html
http://apache.mirror.aussiehq.net.au//tomcat/tomcat-connectors/jk/binaries/
No comments:
Post a Comment