~ubuntu-branches/ubuntu/oneiric/libapache-mod-jk/oneiric

« back to all changes in this revision

Viewing changes to xdocs/howto/nes.xml

  • Committer: Bazaar Package Importer
  • Author(s): Steve Kowalik
  • Date: 2006-08-05 16:30:53 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20060805163053-myf66gm6j1a21ps6
Tags: 1:1.2.18-1ubuntu1
Merge from Debian unstable.

Show diffs side-by-side

added added

removed removed

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