bottleneck testcase based on rubbos
[bottlenecks.git] / rubbos / app / tomcat-connectors-1.2.32-src / xdocs / webserver_howto / nes.xml
1 <?xml version="1.0" encoding="ISO-8859-1"?>
2 <!DOCTYPE document [
3   <!ENTITY project SYSTEM "project.xml">
4 ]>
5 <document url="nes.html">
6
7   &project;
8 <copyright>
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
15  
16        http://www.apache.org/licenses/LICENSE-2.0
17  
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.
23 </copyright>
24 <properties>
25 <title>SunOne -- Netscape/iPlanet HowTo</title>
26 <author email="hgomez@apache.org">Henri Gomez</author>
27 <author email="jim@apache.org">Jim Jagielski</author>
28 <author email="shachor@il.ibm.com">Gal Shachor</author>
29 <author email="mturk@apache.org">Mladen Turk</author>
30 <date>$Date: 2009-04-07 23:11:25 +0200 (Tue, 07 Apr 2009) $</date>
31 </properties>
32 <body>
33 <section name="Introduction">
34 <p>
35 This document explains how to set up Sun ONE Web Server previously known as
36 Netscape web servers to cooperate with Tomcat. 
37 </p>
38
39 <p>
40 Normally the Sun ONE Web Servers come with their own Servlet engine, 
41 but you can also configure them to send servlet and JSP requests to Tomcat 
42 using the NSAPI redirector plugin.
43 </p>
44
45 <p>
46 It is recommended that you also read the <a href="../generic_howto/workers.html">Workers HowTo</a> document
47 to learn how to setup the working entities between your web server and Tomcat Engines.
48 </p>
49
50
51 <subsection name="Document Conventions and Assumptions">
52 <p>
53 ${tomcat_home} is the root directory of tomcat. 
54 Your Tomcat installation should have the following subdirectories:
55
56 <ul>
57 <li>
58 ${tomcat_home}\conf - Where you can place various configuration files
59 </li>
60 <li>
61 ${tomcat_home}\webapps - Containing example applications
62 </li>
63 <li>
64 ${tomcat_home}\bin - Where you place web server plugins
65 </li>
66 </ul>
67 </p>
68 <p>
69 In all the examples in this document ${tomcat_home} will be <b>c:\tomcat</b>.
70 A worker is defined to be a tomcat process that accepts work from the Sun ONE Web Server.
71 </p>
72 </subsection>
73
74
75 <subsection name="Supported Configuration">
76 <p>
77 The NSAPI-Tomcat redirector was developed and tested on:
78 <ul>
79 <li>
80 WINNT 2000/XP/2003 (should be able to work with other service packs) and some Unixes
81 </li>
82 <li>
83 Sun ONE Web Server 6.1
84 </li>
85 <li>
86 Tomcat 4.1.x , Tomcat 5.0.x and Tomcat 5.5.x
87 </li>
88 </ul>
89 </p>
90
91 <p>
92 The redirector uses <b>ajp12</b> and <b>ajp13</b> to send requests to the Tomcat containers. 
93 There is also an option to use Tomcat in process, 
94 more about the in-process mode can be found in the in process howto.
95 </p>
96 </subsection>
97
98 <subsection name="Who support ajp protocols ?">
99 <p>
100 The ajp12 protocol is only available in Tomcat 3.2.x and 3.3.x.
101 </p>
102
103 <p>
104 The <b>ajp12</b> has been <b>deprecated</b> with Tomcat 3.3.x and you should use instead 
105 <b>ajp13</b> which is the only ajp protocol known by Tomcat 4.0.x, 4.1.x, 5.0.x, 5.5.x and 6.
106 </p>
107
108 <p>
109 Of course Tomcat 3.2.x and 3.3.x also support ajp13 protocol.
110 </p>
111
112 <p>
113 Others servlet engines such as <b>jetty</b> have support for ajp13 protocol
114 </p>
115
116 </subsection>
117
118
119 <subsection name="How does it work ?">
120 <p>
121 <ol>
122 <li>
123 The NSAPI-Tomcat redirector is an Netscape service step plugin, 
124 Netscape load the redirector plugin and calls its service handler 
125 function for request that are assigned to the "servlet" configuration object.
126 </li>
127 <li>
128 For each in-coming request Netscape will execute the set of NameTrans directives 
129 that we added to obj.conf, the assign-name function will check if it's from 
130 parameter matches the request URL.
131 </li>
132 <li>
133 If a match is found, assign-name will assign the servlet object name to the request. 
134 This will cause Netscape to send the request to the servlet configuration object.
135 </li>
136 <li>
137 Netscape will execute our jk_service extension. The extension collects the 
138 request parameters and forwards them to the appropriate worker using the ajp13 protocol 
139 (the worker="defworker" parameter in jk_service inform it that the worker for this request is named <b>defworker</b>).
140 the workers properties files, <b>workers.properties</b>, will indicate that defworker use ajp13 protocol.
141 </li>
142 <li>
143 The extension collects the response from the worker and returns it to the browser.
144 </li>
145 </ol>
146 </p>
147 </subsection>
148
149 </section>
150
151 <section name="Installation">
152 <p>
153 A pre-built version of the NSAPI redirector, nsapi_redirect.dll, may be available under 
154 the win32/i386 directory of tomcat-connectors distribution. 
155 For those using Netscape as your browser, try downloading a zip version of the file, if available. 
156
157 You can also build a copy locally from the source present in tomcat-connectors distribution.
158
159
160 The Tomcat redirector requires two entities:
161 <ul>
162 <li>
163 nsapi_redirect.dll (Windows) -or- nsapi_redirector.so (Unix) - The NSAPI server plugin, either obtain a pre-built DLL/so or build it yourself 
164 (see the build section).
165 </li>
166 <li>
167 workers.properties - A file that describes the host(s) and port(s) used by the workers (Tomcat processes). 
168 A sample workers.properties can be found under the conf directory.
169 </li>
170 </ul>
171
172 The installation includes the following parts:
173
174 <ul>
175 <li>
176 Configuring the NSAPI redirector with a default /examples context and checking that you can serve servlets 
177 with Netscape.
178 </li>
179 <li>
180 Adding more contexts to the configuration.
181 </li>
182 </ul>
183
184 </p>
185 </section>
186
187 <section name="Configuring the NSAPI Redirector">
188 <p>
189 In this document we'll assume that nsapi_redirect.dll is placed in 
190 <b>c:\jk\lib\nsapi_redirect.dll</b>, the properties file is in<b>c:\jk\conf</b>
191 and you created a log directory <b>c:\jk\logs</b>
192 </p>
193
194 <ul>
195 <li>
196 If the built in servlet support is working disable it.
197 </li>
198 <li>
199 Add the redirector plugin into the Netscape server configuration. 
200 Edit your server <b>magnus.conf</b> and add the following lines:
201 </li>
202 </ul>
203
204 <source>
205   
206   Init fn="load-modules" funcs="jk_init,jk_service" shlib="c:/jk/lib/nsapi_redirect.dll" shlib_flags="(global|now)"
207   Init fn="jk_init" worker_file="c:/jk/conf/workers.properties" log_level="debug" log_file="c:/jk/logs/nsapi.log" shm_file="c:/jk/logs/jk_shm"
208 </source>
209 <ul>
210 <li>
211 Edit your server <b>obj.conf</b> and add the following lines:
212 </li>
213 </ul>
214 <source>
215
216   
217   In the default object NameTrans section
218   &lt;Object name="default"&gt;
219       
220   NameTrans fn="assign-name" from="/servlets-examples(|/*)" name="jknsapi" 
221   NameTrans fn="assign-name" from="/jsp-examples(|/*)" name="jknsapi"
222   ....
223   &lt;/Object&gt;
224   
225   Create a new configuration object by adding the following lines to the end of the obj.conf file
226   
227   &lt;Object name="jknsapi"&gt;
228   ObjectType fn=force-type type=text/plain
229   Service fn="jk_service" method="*" worker="worker1"
230   &lt;/Object&gt;
231 </source>
232
233 <ul>
234 <li>
235 Edit your worker definition file <b>workers.properties</b>. You should at least choose a connection pool size:
236 </li>
237 </ul>
238
239 <source>
240   #An entry that lists all the workers defined. For example:
241   worker.list=worker1
242   
243   # Entries that define the host and port associated with these workers.
244   worker.worker1.host=localhost
245   worker.worker1.port=8009
246   worker.worker1.type=ajp13
247   worker.worker1.connection_pool_size=50
248 </source>
249
250 <ul>
251 <li>
252 Restart Web Server (stop and start the server)
253 </li>
254 </ul>
255
256 <p>
257 That's all, now you should start tomcat and ask for http://server:port/servlets-examples/
258 </p>
259 <warn>
260 The file <b>obj.conf</b> seems to be sensitive to leading white space in lines, especially in
261 the <b>Object</b> element. Make sure you have no leading white space (no indentation)
262 on any line of this file.
263 </warn>
264
265 <subsection name="Adding additional Contexts">
266 <p>
267 The examples context is useful for verifying your installation, but you will also need to add your own contexts. 
268 Adding a new context requires two operations:
269 </p>
270 <ul>
271 <li>
272 Adding the context to Tomcat (I am not going to talk about this).
273 </li>
274 <li>
275 Assigning the NSAPI redirector to handle this context.
276 </li>
277 </ul>
278
279 <p>
280 Assigning the NSAPI redirector to handle this context is simple, 
281 all you need to do is to edit <b>obj.conf</b> and add a NameTrans line that looks like:
282 </p>
283
284 <source>
285   NameTrans fn="assign-name" from="/&lt;context name&gt;/*" name="jknsapi"
286 </source>
287
288 <p>
289 After saving <b>obj.conf</b> restart Netscape and it will serve the new context.
290 </p>
291 </subsection>
292
293 <subsection name="Advanced Context Configuration">
294 <p>
295 Sometimes it is better to have Netscape serve the static pages (html, gif, jpeg etc.) 
296 even if these files are part of a context served by Tomcat. For example, consider the html and gif files in the examples context, there is no need to serve them from the Tomcat process, Netscape will suffice.
297 </p>
298 <p>
299 Making Netscape serve static files that are part of the Tomcat contexts requires the following:
300 </p>
301 <ul>
302 <li>
303 Configuring Netscape to know about the Tomcat contexts
304 </li>
305 <li>
306 Make sure that the WEB-INF directory is protected from access.
307 </li>
308 <li>
309 Configuring Netscape to assign the NSAPI redirector only specific requests that requires JSP/Servlet handling.
310 </li>
311 </ul>
312
313 <p>
314 Adding a Tomcat context to Netscape requires the addition of a new Netscape virtual directory 
315 that covers the Tomcat context.
316 </p>
317
318 <p>
319 For example, adding a /example Netscape virtual directory that 
320 covers the <b>c:\tomcat\webapps\examples</b> directory. 
321 </p>
322
323 <p>
324 To add a new virtual directory add the following line to your <b>obj.conf</b>:
325 </p>
326
327 <source>
328   NameTrans fn=pfx2dir from=/examples dir="c:/tomcat/webapps/examples"
329 </source>
330
331 <p>
332 WEB-INF protection requires some explanation; Each servlet application (context) has a special directory named <b>WEB-INF</b>,
333 this directory contains sensitive configurations data and Java classes and must be kept hidden from web users. 
334 WEB-INF can be protected by adding the following line to the PathCheck section in the default configuration object:
335 </p>
336
337 <source>
338   PathCheck fn="deny-existence" path="*/WEB-INF/*"
339   
340   This line instructs the Netscape server to reject any request with a URL that contain the path /WEB-INF/.
341 </source>
342
343 <p>
344 Configuring Netscape to assign the NSAPI redirector only specific requests is somewhat harder, 
345 you will need to specify the exact URL-Path pattern(s) that you want Tomcat to handle 
346 (usually only JSP files and servlets). 
347 </p>
348
349 <p>
350 This requires a change to NameTrans portion of <b>obj.conf</b>. 
351 </p>
352
353 <source>
354   For the examples context it requires to replace the following line:
355   
356   NameTrans fn="assign-name" from="/examples/*" name="jknsapi"
357   
358   with the following two lines:
359   
360   NameTrans fn="assign-name" from="/examples/jsp/*.jsp" name="jknsapi"
361   NameTrans fn="assign-name" from="/examples/servlet/*" name="jknsapi"
362 </source>
363
364 <p>
365 As you can see the second configuration is more explicit, it actually instructs 
366 Netscape to assign the redirector with only requests to resources under 
367 <b>/examples/servlet/</b> and resources under <b>/examples/</b> whose name ends with <b>.jsp</b>.
368 </p>
369
370 <p>
371 You can be even more explicit and provide lines such as:
372 </p>
373
374 <source>
375   NameTrans fn="assign-name" from="/examples/servletname" name="jknsapi"
376   
377   Instructs Netscape to assign the redirector request whose URL-Path equals /example/servletname
378 </source>
379
380 </subsection>
381
382 <subsection name="Advanced Worker Configuration">
383 <p>
384 Sometimes you want to serve different contexts with different Tomcat processes 
385 (for example to spread the load among different machines). 
386 To achieve such goal you will need to define several workers and assign each context with its own worker.
387 </p>
388
389 <p>
390 Defining workers is done in <b>workers.properties</b>, this file includes two types of entries:
391 </p>
392
393 <source>
394   #An entry that lists all the workers defined. For example:
395   worker.list=worker1,worker2
396   
397   # Entries that define the host and port associated with these workers.
398   worker.worker1.host=localhost
399   worker.worker1.port=8009
400   worker.worker1.type=ajp13
401
402   worker.worker2.host=otherhost
403   worker.worker2.port=8009
404   worker.worker2.type=ajp13
405 </source>
406
407 <p>
408 The above examples defined two workers, now we can use these workers to serve two different 
409 contexts each with it's own worker. 
410 Submitting requests to different workers is accomplished by using multiple Service directives 
411 in the servlet configuration Object, each with a different path pattern parameter. 
412 </p>
413
414 <p>
415 For example, if we want to submit the <b>/examples</b> context to the worker named <b>worker1</b> and the 
416 <b>/webpages</b> context to the worker named <b>worker2</b> we should use the following configuration:
417 </p>
418
419 <source>
420   &lt;Object name="jknsapi"&gt;
421   ObjectType fn=force-type type=text/plain
422   Service fn="jk_service" worker="worker1" path="/examples/*"
423   Service fn="jk_service" worker="worker2" path="/webpages/*"
424   Service fn="jk_service" worker="worker1"
425   &lt;/Object&gt;
426 </source>
427
428 <p>
429 More informations on using and configuring workers in the <a href="../generic_howto/workers.html">Workers HowTo</a>
430 and in the <a href="../reference/workers.html">worker.properties configuration reference</a>.
431
432 </p>
433 </subsection>
434
435 </section>
436
437 <section name="Building NSAPI DLL redirector for Windows">
438 <p>
439 The redirector was developed using Visual C++ Ver.6.0, so having this environment is a prereq if you want 
440 to perform a custom build. You should also have NES developer SDK
441
442 The steps that you need to take are:
443 <ul>
444 <li>
445 Change directory to the nsapi plugins source directory.
446 </li>
447 <li>
448 Edit <b>nsapi.dsp</b> and update the include and library path to reflect your own Netscape server installation 
449 (search for a <b>/I compiler</b> option and <b>/libpath</b> linker option)
450 </li>
451 <li>
452 Make the source with MSDEV
453 </li>
454 </ul>
455 <screendos>
456 <notedos>Change directory to the nsapi plugins source directory</notedos>
457 <typedos>cd c:\home\apache\jk\nsapi</typedos>
458 <notedos>Build the sources using MSDEV</notedos>
459 <typedos>MSDEV nsapi.dsp /MAKE ALL</typedos>
460 </screendos>
461 </p>
462 <p>
463 If msdev is not in your path, enter the full path to msdev.exe. 
464 This will build both release and debug versions of the redirector plugin.
465 An alternative will be to open the nsapi workspace file (nsapi.dsw) in msdev and 
466 build it using the build menu.
467 </p>
468 </section>
469 <section name="Building NSAPI so plugin redirector for Unix">
470 <p>
471 The redirector requires either gcc (Linux) or gcc or the Sun cc compiler (Solaris).
472
473 The steps that you need to take are:
474 <ul>
475 <li>
476 Change directory to the nsapi plugins source directory (src/native).
477 </li>
478 <li>
479 configure for Netscape/iPlanet/SunONE webserver.
480 </li>
481 <li>
482 Change directory to the nsapi netscape directory (./netstape).
483 </li>
484 <li>
485 Set environment variables JAVA_HOME resp. SUITSPOT_HOME to the location of your Java installation
486 resp. Netscape server installation. Depending on the web server version, you must add the subdirectory
487 &quot;plugins&quot; to SUITSPOT_HOME.
488 The variable is correct, if the file $SUITSPOT_HOME/include/nsapi.h exists.
489 </li>
490 <li>
491 Edit <b>Makefile.solaris</b> resp. <b>Makefile.linux</b> and update the variables according to your needs.
492 In the Solaris Makefile, you need to switch the commented lines in order to use the Sun compiler cc
493 instead of GNU gcc.
494 </li>
495 <li>
496 Make the source with gmake.
497 </li>
498 </ul>
499 <screendos>
500 <notedos>Change directory to the nsapi plugins source directory</notedos>
501 <typedos>cd /usr/local/src/tomcat-connectors-xxx-src/native</typedos>
502 <notedos>configure for Netscape/iPlanet/SunONE webserver</notedos>
503 <typedos>./configure --enable-netscape</typedos>
504 <notedos>Change directory to the nsapi netscape directory</notedos>
505 <typedos>cd netscape</typedos>
506 <notedos>Set JAVA_HOME (ksh example)</notedos>
507 <typedos>export JAVA_HOME=/path/to/my/java</typedos>
508 <notedos>Set SUITSPOT_HOME (ksh example)</notedos>
509 <typedos>export SUITSPOT_HOME=/path/to/my/netscape/server</typedos>
510 <notedos>Edit the Makefile</notedos>
511 <typedos>vi Makefile.solaris</typedos>
512 <notedos>Make the source with gmake</notedos>
513 <typedos>gmake -f Makefile.solaris</typedos>
514 </screendos>
515 </p>
516 <p>
517 After the build, you will have the required nsapi_redirector.so plugin.
518 </p>
519 </section>
520 </body>
521 </document>