1 <?xml version="1.0" encoding="ISO-8859-1"?>
3 <!ENTITY project SYSTEM "project.xml">
5 <document url="iis.html">
9 Licensed to the Apache Software Foundation (ASF) under one or more
10 contributor license agreements. See the NOTICE file distributed with
11 this work for additional information regarding copyright ownership.
12 The ASF licenses this file to You under the Apache License, Version 2.0
13 (the "License"); you may not use this file except in compliance with
14 the License. You may obtain a copy of the License at
16 http://www.apache.org/licenses/LICENSE-2.0
18 Unless required by applicable law or agreed to in writing, software
19 distributed under the License is distributed on an "AS IS" BASIS,
20 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 See the License for the specific language governing permissions and
22 limitations under the License.
25 <title>IIS HowTo</title>
26 <author email="hgomez@apache.org">Henri Gomez</author>
27 <author email="shachor@il.ibm.com">Gal Shachor</author>
28 <author email="yoavs@apache.org">Yoav Shapira</author>
29 <date>$Date: 2010-03-15 16:40:37 +0100 (Mon, 15 Mar 2010) $</date>
32 <section name="Introduction">
34 This document explains how to set up IIS to cooperate with Tomcat.
38 Normally IIS can not execute Servlets and Java Server Pages (JSPs),
39 configuring IIS to use the JK ISAPI redirector plugin will let IIS send servlet and
40 JSP requests to Tomcat (and this way, serve them to clients).
44 It is recommended that you also read the
45 <a href="../generic_howto/workers.html">Workers HowTo</a> document
46 to learn how to setup the working entities between your web server and Tomcat Engines.
47 For more detailed configuration information consult the Reference Guide for
48 <a href="../reference/workers.html">workers.properties</a>,
49 <a href="../reference/uriworkermap.html">uriworkermap</a>
50 and <a href="../reference/iis.html">IIS</a>.
54 <subsection name="Document Conventions and Assumptions">
56 ${tomcat_home} is the root directory of tomcat.
57 Your Tomcat installation should have the following subdirectories:
61 ${tomcat_home}\conf - Where you can place various configuration files
64 ${tomcat_home}\webapps - Containing example applications
67 ${tomcat_home}\bin - Where you place web server plugins
72 In all the examples in this document ${tomcat_home} will be <b>c:\tomcat</b>.
73 A worker is defined to be a tomcat process that accepts work from the IIS server.
78 <subsection name="Supported Configuration">
80 The IIS-Tomcat redirector was developed and tested on:
83 WinNT4.0-i386 SP4/SP5/SP6a (should be able to work with other service packs), Win2K and WinXP and Win98
86 IIS4.0 and PWS4.0 (numerous people have working IIS 5 and IIS 6 configurations)
89 Tomcat 3.2 and later, Tomcat 4.x, Tomcat 5 and 5.5 and Tomcat 6
95 The redirector uses <b>ajp12</b> and <b>ajp13</b> to send requests to the Tomcat containers. There is also an option to use Tomcat in process,
96 more about the in-process mode can be found in the in process howto.
100 <subsection name="IIS 5 and 6 Notes">
102 There are extra steps you need to take for configuring Tomcat with IIS 5 and 6. Please see the appropriate links from
103 <a href="http://wiki.apache.org/tomcat/Tomcat/Links">Tomcat Useful Links</a>.
107 <subsection name="IIS 7 notes">
109 There is a known bug in IIS that may result in incomplete log messages. See <a
110 href="https://issues.apache.org/bugzilla/show_bug.cgi?id=45769">bug 45769</a>
115 <subsection name="Who support ajp protocols ?">
117 The ajp12 protocol is only available in Tomcat 3.2.x and 3.3.x.
121 The <b>ajp12</b> has been <b>deprecated</b> with Tomcat 3.3.x and you should use instead
122 <b>ajp13</b> which is the only ajp protocol known by Tomcat 4.x, 5 and 5.5 and Tomcat 6.
126 Of course Tomcat 3.2.x and 3.3.x also support ajp13 protocol.
130 Others servlet engines such as <b>jetty</b> have support for ajp13 protocol
135 <subsection name="How does it work ?">
139 The IIS-Tomcat redirector is an IIS plugin (filter + extension), IIS load the redirector plugin and calls its
140 filter function for each in-coming request.
143 The filter then tests the request URL against a list of URI-paths held inside uriworkermap.properties,
144 If the current request matches one of the entries in the list of URI-paths,
145 the filter transfers the request to the extension.
148 The extension collects the request parameters and forwards them to the appropriate worker using the defined
149 protocol like <b>ajp13</b>.
152 The extension collects the response from the worker and returns it to the browser.
160 <section name="Installation">
162 A pre-built version of the ISAPI redirector server plugin, isapi_redirect.dll, is available under
163 the win32/i386 directory of tomcat-connectors distribution.
164 For those using Netscape as your browser, try downloading a zip version of the file, if available.
165 There can be problems using Netscape to download DLL files.
167 You can also build a copy locally from the source present in tomcat-connectors distribution.
169 The Tomcat redirector requires three entities:
173 <b>isapi_redirect.dll</b> - The IIS server plugin, either obtain a pre-built DLL or build it yourself (see the build section).
176 <b><a href="../reference/workers.html">workers.properties</a></b> - A file that describes the host(s) and port(s) used by the workers (Tomcat processes).
177 A sample workers.properties can be found under the conf directory.
180 <b><a href="../reference/uriworkermap.html">uriworkermap.properties</a></b> - A file that maps URL-Path patterns to workers.
181 A sample uriworkermap.properties can be found under the conf directory as well.
187 The installation includes the following parts:
191 Configuring the ISAPI redirector with a default /examples context and checking that you can serve servlets with IIS.
194 Adding more contexts to the configuration.
201 <section name="Configuring the ISAPI Redirector">
203 In this document I will assume that isapi_redirect.dll is placed in
204 <b>c:\tomcat\bin\win32\i386\isapi_redirect.dll</b> and
205 that the properties files which you created are in <b>c:\tomcat\conf</b>.
210 In the registry, create a new registry key named
211 <b>"HKEY_LOCAL_MACHINE\SOFTWARE\Apache Software Foundation\Jakarta Isapi Redirector\1.0"</b>
214 Add a string value with the name <b>extension_uri</b> and a value of <b>/jakarta/isapi_redirect.dll</b>
217 Add a string value with the name <b>log_file</b> and a value pointing to where you want your
218 log file to be (for example <b>c:\tomcat\logs\isapi.log</b>).
221 Add a string value with the name <b>log_level</b> and a value for your log level
222 (can be debug, info, error or emerg).
225 Add a string value with the name <b>worker_file</b> and a value which is the full path
226 to your workers.properties file (for example <b>c:\tomcat\conf\workers.properties</b>)
229 Add a string value with the name <b>worker_mount_file</b> and a value which is the full path
230 to your uriworkermap.properties file (for example <b>c:\tomcat\conf\uriworkermap.properties</b>)
233 Using the IIS management console, add a new virtual directory to your IIS/PWS web site.
234 The name of the virtual directory must be jakarta.
235 Its physical path should be the directory where you placed isapi_redirect.dll
236 (in our example it is c:\tomcat\bin\win32\i386).
237 While creating this new virtual directory assign it with execute access.
240 Using the IIS management console, add isapi_redirect.dll as a filter in your IIS/PWS web site.
241 The name of the filter should reflect its task (I use the name tomcat),
242 its executable must be our c:\tomcat\bin\win32\i386\isapi_redirect.dll.
243 For PWS, you'll need to use regedit and add/edit the <b>"Filter DLLs"</b> key under
244 <b>HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\W3SVC\Parameters</b>.
245 This key contains a "," separated list of dlls (full paths) -
246 you need to insert the full path to isapi_redirect.dll.
249 If you're using IIS 6.0 you must also do the following:
251 Using the IIS management console, add the Jakarta Isapi Redirector to the Web
254 <li>Right-click on Web Service Extensions and choose Add a new Web Service
256 <li>Enter tomcat for the Extension Name.</li>
257 <li>Add the isapi_redirect.dll to the required files.</li>
258 <li>Check the Set extension status to Allowed.</li>
259 <li>Click on OK.</li>
263 Restart IIS (stop + start the IIS service), make sure that the tomcat filter is marked with a green up-pointing arrow.
264 Under Win98 you may need to <b>cd WINDOWS\SYSTEM\inetsrv</b> and type PWS /stop
265 ( the DLL and log files are locked - even if you click the stop button,
266 PWS will still keep the DLLs in memory. ). Type pws to start it again.
271 That's all, you should now start Tomcat and ask IIS to serve you the /examples context.
272 Try <a href="http://localhost/examples/jsp/index.html">http://localhost/examples/jsp/index.html</a> for example and
273 execute some of the JSP examples.
276 If this does not work successfully, refer to the Troubleshooting section below for help on correcting the problem.
279 <subsection name="Adding additional Contexts">
281 The examples context is useful for verifying your installation,
282 but you will also need to add your own contexts. Adding a new context requires two operations:
287 Adding the context to Tomcat (I am not going to talk about this).
290 Adding the context to the ISAPI redirector.
295 Adding a context to the ISAPI redirector is simple, all you need to do is to edit
296 your uriworkermap.properties and to add a line that looks like:
300 /context/*=worker_name
304 Workers and their name are defined in workers.properties, by default workers.properties comes
305 with a single pre-configured worker named <b>"defworker"</b> so you can use it.
306 As an example, if you want to add a context named "shop", the line that you should add to
307 uriworkermap.properties will be:
314 After saving uriworkermap.properties restart IIS and it will serve the new context.
316 The above should be all you need for IIS to pass through to Tomcat any request for any URI which corresponds
317 to a Tomcat context (webapp).
321 <subsection name="Advanced Context Configuration">
323 If your webiste is very busy (more than 100 requests/second, or more than 100 simultaneous client connections),
324 it might sometimes be desirable to have IIS serve static content (html, gif, jpeg etc.) directly,
325 even if these files are part of a context served by Tomcat. Allowing IIS to serve such files directly may
326 avoid the small overhead consisting of passing the request to Tomcat via the redirector, and may free up
327 Tomcat somewhat, by using it only to process requests that only Tomcat can handle (e.g. requests to JSP pages and java servlets).
330 For example, consider the html and gif files in the examples context : you could serve these files directly
331 with IIS; there is no need to serve them from the Tomcat process.
333 <warn>However, you should be very careful when you implement the following configuration style, because by doing so you are
334 in fact providing a "back-door" to IIS, and allowing it to serve files out of a Tomcat context without Tomcat's knowledge,
335 thus bypassing any security
336 restrictions which Tomcat itself and the Tomcat context (webapp) may place on those files.</warn>
338 Making IIS serve static files that are part of the Tomcat contexts requires the following:
341 Configuring IIS to know about the Tomcat contexts
344 Configuring the redirector to leave the static files for IIS
350 Adding a Tomcat context to IIS requires the addition of a new IIS virtual directory that covers the Tomcat context.
351 For example adding a /example IIS virtual directory that covers the c:\tomcat\webapps\examples directory.
355 Configuring the redirector is somewhat harder, you will need to specify the exact
356 URL-Path pattern(s) which you want Tomcat to handle (usually only JSP files and servlets).
357 This requires a change to the uriworkermap.properties :
360 For the examples context it requires to replace the following line
361 /examples/*=defworker
362 with the following two lines
363 /examples/*.jsp=defworker
364 /examples/servlet/*=defworker
369 As you can see the second configuration is more explicit, it actually instruct the redirector
370 to redirect only requests to resources under /examples/servlet/ and resources under /examples/
371 whose name ends with .jsp.
375 You can even be more explicit and provide lines such as:
378 /example/servletname=defworker
383 that instructs the redirector to redirect all requests whose URL-path matches the leading string "/example/servletname"
384 to the worker named defworker.
389 <subsection name="Protecting the content of your Tomcat contexts">
390 <p>Once again, be aware that by allowing IIS to access the content of your Tomcat context directly, you are
391 potentially bypassing Tomcat's protection of that content. You should thus make sure to protect this content
392 at the IIS level if needed, by using the corresponding IIS management console functions.
395 In particular, each servlet application (context) has a special directory named WEB-INF,
396 which contains sensitive configuration data and Java classes, and which should always be kept hidden from web users.
397 Using the IIS management console it is possible to protect the WEB-INF directory from user access, but considering that
398 this is a general requirement, and considering that it is easy to forget to implement this protection
399 at the IIS level, the redirector plugin does it automatically for you, and it will reject any request
400 which contains WEB-INF in its URL-path.
404 <subsection name="Advanced Worker Configuration">
406 Sometimes you may want to serve different contexts with different Tomcat processes
407 (for example to spread the load among different machines).
408 To achieve such a goal you will need to define several workers and assign each context to its own worker.
411 Defining additional workers is done in the workers.properties file. This file includes two types of entries:
416 # An entry that lists all the workers defined
417 worker.list=worker1, worker2
418 # Entries that define the host and port associated with each of these workers
419 worker.worker1.host=localhost
420 worker.worker1.port=8009
421 worker.worker1.type=ajp13
422 worker.worker2.host=otherhost
423 worker.worker2.port=8009
424 worker.worker2.type=ajp13
429 The above example defined two workers, now we can use these workers to serve two different contexts
430 each with its own worker:
432 example uriworkermap.properties fragment
439 As you can see the <b>examples</b> context is served by <b>worker1</b> while the
440 <b>webpages</b> context is served by <b>worker2</b>.
444 More information on using and configuring workers in the <a href="../generic_howto/workers.html">Workers HowTo</a>
445 and in the <a href="../reference/workers.html">worker.properties configuration reference</a>.
452 <section name="Building ISAPI redirector">
454 The redirector was developed using Visual C++ Ver.6.0, so having this environment is a prerequisite if you want
455 to perform a custom build. You should also have the IIS developer SDK.
457 The steps that you need to take are:
460 Change directory to the isapi plugins source directory.
463 Make the source with MSDEV
467 <note>Change directory to the isapi plugins source directory</note>
468 <typedos>cd c:\home\apache\jk\iis</typedos>
469 <note>Build the sources using MSDEV</note>
470 <typedos>MSDEV isapi.dsp /MAKE ALL</typedos>
474 If msdev is not in your path, enter the full path to msdev.exe.
475 This will build both release and debug versions of the redirector plugin.
476 An alternative will be to open the isapi workspace file (isapi.dsw) in msdev and
477 build it using the build menu.
481 <section name="Troubleshooting">
483 It is easy to have the ISAPI redirector not work the first time you try to install it.
486 If this happens to you, here are some steps to follow to try to correct the problem.
489 These steps aren't guaranteed to cover all possible problems,
490 but they should help find the typical mistakes.
493 If you make any corrections during these steps, restart the IIS service as described above in the last step
494 of the installation, then retry the step.
497 <p>To enable error tracking, make sure web site activity is being logged.
498 For PWS 4.0 make sure "Save Web Site Activity Log" is checked in the Advanced Options of the Personal Web Manager.
502 Note: These steps assume your <b>worker_mount_file</b> setting points to an unmodified copy of the
503 <b>uriworkermap.properties</b> file.<br/>
504 Results may be misleading if <b>worker_mount_file</b> points to a modified <b>uriworkermap.properties</b>
505 or the <b>uriworkermap.properties-auto</b> file.<br/>
506 It is also assumed that the <b>"/examples" context</b> works correctly if you access Tomcat directly.
509 <subsection name="Win98">
511 Start the IIS service and Tomcat.
514 Check for the presence of the ISAPI redirector log file you specified in the log_file setting.
515 If not found, verify the following:
519 Check the "Filter DLLs" setting in the "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\W3SVC\Parameters"
520 key and make sure the path is correct.
523 Check the spelling of the "HKEY_LOCAL_MACHINE\SOFTWARE\Apache Software Foundation\Jakarta Isapi Redirector\1.0" key.
524 Case isn't important, but an incorrect letter will prevent the isapi_redirect.dll from finding its registry settings.
527 Check the log_file setting for typos, name and data. Also insure the directory in which the log file will appear already exists.
529 If the above are set correctly, the ISAPI redirector should be able to create the log file.
532 Invoke the URL <a href="http://localhost/examples/jsp/index.html">http://localhost/examples/jsp/index.html</a>
534 Case is important in Tomcat. The characters following "localhost" in the URL must be lower case.
535 If the page fails to appear, stop the IIS service (required to view the IIS log file).
536 Then examine the last line in the IIS log file in found in SYSTEM/LogFiles/W3SVC1 :
539 If the last line contains:
542 GET "/examples/jsp/index.html HTTP/1.1" 404
545 then the ISAPI redirector is not recognising that it should be handling requests for the "/examples" context.
550 Check the extension_uri name for typos.
553 Check the worker_file setting for typos, name and data.
556 Check the worker_mount_file setting typos, name and data.
558 If these are set correctly, the ISAPI redirector should recognise that it should handle requests for the "/examples" context.
561 <p>If the last line contains something like:
565 GET "/jakarta/isapi_redirect.dll HTTP1.1"
569 then the ISAPI redirector is recognising that it should handle the request,
570 but is not successful at getting Tomcat to service the request.
574 You should check the HTTP error code following GET "/..." :
584 Make sure you entered the URL correctly.
587 Make sure the virtual directory created was called "jakarta".
588 It should display in Personal Web Manager as "/jakarta" (without the quotes).
591 Make sure the extension_uri data begins with "/jakarta/" (without the quotes).
602 Make sure that "isapi_redirect.dll" follows "/jakarta/" in the extension_uri setting.
605 Check the workers.properties file and make sure the port setting for worker.ajp12.port is the same as the port specified in the server.xml for the "Apache AJP12 support".
617 Make sure you have checked Execute Access
618 for the jakarta virtual directory in the Advanced Options of the Personal Web Manager.
623 If the above settings are correct, the index.html page should appear in your browser.
624 You should also be able to click the Execute links to execute the JSP examples.
629 <subsection name="WinNT/Win2K/WinXP">
631 Start the World Wide Web Publishing Service and Tomcat.
634 Check for the presence of the ISAPI redirector log file you specified in the log_file setting.
635 If not found, check the following:
639 Check the "executable" you set for the filter in the IIS Management Console and make sure the path is correct.
641 <li>Check the spelling of the "HKEY_LOCAL_MACHINE\SOFTWARE\Apache Software Foundation\Jakarta Isapi Redirector\1.0" key.
642 Case isn't important, but an incorrect letter will prevent the isapi_redirect.dll from finding its registry settings.
645 Check the log_file setting for typos, name and data. Also insure the directory in which the log file will appear already exists.
647 If the above are set correctly, the ISAPI redirector should be able to create the log file.
651 Check the tomcat filter you added and make sure its status shows a green upward-pointing arrow.
652 If not, check the following:
656 Check the worker_file setting for typos, name and data.
659 Check the worker_mount_file setting typos, name and data.
661 If the above are set correctly, the green upward-pointing arrow should appear, even if the other settings are wrong.
665 Invoke the URL <a href="http://localhost/examples/jsp/index.html">http://localhost/examples/jsp/index.html</a>
666 in your browser. Case is important in Tomcat. The characters following "localhost" in the URL must be lower case.
667 If the page fails to appear, examine the last line in the IIS server log file in found in SYSTEM32/LogFiles/W3SVC1.
671 The last line should contain something like: GET "/jakarta/isapi_redirect.dll HTTP1.1",
672 which indicates the ISAPI redirector is recognising that it should handle the request.
676 You should check the HTTP error code following GET "/..." :
686 Make sure you entered the URL correctly.
697 Make sure the virtual directory created was called "jakarta".
700 Make sure that the extension_uri setting is correct.
703 Check the workers.properties file and make sure the port setting for worker.ajp12.port is the same as the port specified in the server.xml for the "Apache AJP12 support".
715 Make sure you have checked Execute Access for the jakarta virtual directory in the
716 Advanced Options of the Personal Web Manager.
721 If the above settings are correct, the index.html page should appear in your browser.
722 You should also be able to click the Execute links to execute the JSP examples.