Apache Software Foundation | Jakarta Project | Apache Tomcat
Introduction


はじめに

This document explains how to set up Netscape web servers to cooperate with Tomcat.


この文書は、Tomcatと連携させるためにNetscape Webサーバーをセットアップする方法を説明します。

Normally the Netscape web servers come with their own Servlet engine, but you can also configure them to send servlet and JSP requests to Tomcat using the Tomcat redirector plugin.


Netscape Webサーバーは、通常独自のServletエンジンとともに提供されます。 しかし、Tomcatリダイレクタプラグインを使用すれば、JSPとServletの要求をTomcatに転送するように設定することができます。

It is recommanded that you also read the Workers HowTo document to learn how to setup the working entities between your WebServer and Tomcat Engines.


Web サーバと Tomcat エンジンとの間で動作するコネクタを設定する方法を知るために、 ワーカの手引き の文書を読んでおくことをお奨めします。

Document Conventions and Assumptions


文書規約と仮定

${tomcat_home} is the root directory of tomcat. Your Tomcat installation should have the following subdirectories:

  • ${tomcat_home}\conf - Where you can place various configuration files
  • ${tomcat_home}\webapps - Containing example applications
  • ${tomcat_home}\bin - Where you place web server plugins


${tomcat_home} は、tomcatのルートディレクトリです。 Tomcatをインストールするためには、以下のサブディレクトリが必要です。

  • ${tomcat_home}\conf - さまざまな設定ファイルを置きます
  • ${tomcat_home}\webapps - サンプルアプリケーションを含みます
  • ${tomcat_home}\bin - Webサーバープラグインを置きます

In all the examples in this document ${tomcat_home} will be c:\jakarta-tomcat . A worker is defined to be a tomcat process that accepts work from the Netscape/iPlanet server.


本文書中の全ての例では、${tomcat_home} を c:\jakarta-tomcat と記述します。 Netscape/iPlanetサーバーからの依頼をtomcatプロセスが受け付けるために定義するのがワーカ(worker)です。


Supported Configuration


サポートする構成

The Netscape-Tomcat redirector was developed and tested on:

  • WinNT4.0-i386 SP4/SP5/SP6a (should be able to work with other service packs) and some Unixes
  • Netscape Enterprise 3.0 and 3.61
  • Tomcat 3.2.x, 3.3.x, Tomcat 4.0.x, Tomcat 4.1.x and Tomcat 5


Netscape-Tomcat リダイレクタは、次の環境で開発とテストをおこないました。

  • WinNT4.0-i386 SP4/SP5/SP6a (他のサービスパックでの動作も含む)と、いくつかのUNIX
  • Netscape Enterprise 3.0 と 3.61
  • Tomcat 3.2.x、3.3.x、Tomcat 4.0.x、Tomcat 4.1.xおよびTomcat 5

The redirector uses ajp12 and ajp13 to send requests to the Tomcat containers. There is also an option to use Tomcat in process, more about the in-process mode can be found in the in process howto.


リダイレクタは、Tomcatコンテナに要求を送るために、 ajp12 ajp13 を使用します。 Tomcatを内部プロセスで使用することもできます。 内部プロセスモードについての詳細は「内部プロセスの手引き」を見てください。


Who support ajp protocols ?


ajpプロトコルをサポートするソフトウェアは?

The ajp12 protocol is only available in Tomcat 3.2.x and 3.3.x.


ajp12 プロトコルは、Tomcat 3.2.x と 3.3.x. でのみサポートされています。

The ajp12 has been deprecated with Tomcat 3.3.x and you should use instead ajp13 which is the only ajp protocol known by Tomcat 4.0.x, 4.1.x and 5.


ajp12 は、Tomcat 3.3.x では 推奨されません 。代わりに ajp13 を使うべきです。 Tomcat 4.0.x、4.1.x、5 では、 ajp13 だけがサポートされる ajp プロトコルです。

Of course Tomcat 3.2.x and 3.3.x also support ajp13 protocol.


もちろん、Tomcat 3.2.x や 3.3.x でも ajp13 プロトコルをサポートしています。

Others servlet engines such as jetty have support for ajp13 protocol


jetty のような Tomcat 以外の Servlet エンジンでも ajp13 プロトコルをサポートしています。


How does it work ?


どのように動作しますか?

  1. The Netscape-Tomcat redirector is an Netscape service step plugin, Netscape load the redirector plugin and calls its service handler function for request that are assigned to the "servlet" configuration object.
  2. For each in-coming request Netscape will execute the set of NameTrans directives that we added to obj.conf, the assign-name function will check if it's from parameter matches the request URL.
  3. If a match is found, assign-name will assign the servlet object name to the request. This will cause Netscape to send the request to the servlet configuration object.
  4. Netscape will execute our jk_service extension. The extension collects the request parameters and forwards them to the appropriate worker using the ajp13 protocol (the worker="defworker" parameter in jk_service inform it that the worker for this request is named defworker ). the workers properties files, workers.properties , will indicate that defworker use ajp13 protocol.
  5. The extension collects the response from the worker and returns it to the browser.


  1. Netscape-Tomcat リダイレクタは、Netscapeのサービスステッププラグインです。 Netscape は、リダイレクタプラグインを読み込み、"servlet" 設定オブジェクトに割り当てられた要求のために、そのサービスハンドラ機能を呼び出します。
  2. 入ってくる要求ごとに、obj.confに追記した一連のNameTrans指示をNetscapeが実行し、 要求されたURLとパラメータが一致するかをassign-name機能がチェックします。
  3. 一致した場合assign-name機能は、要求に対してServletオブジェクト名を割り当てます。 これによってNetscapeは、Servlet設定オブジェクトに対して要求を送るようになります。
  4. Netscapeは、jk_serviceエクステンションを実行します。 エクステンションは要求パラメータを集め、ajp13プロトコルを使用してそれらを適切なワーカに送ります。 (jk_serviceでのworker="defworker" パラメータは、 defworker という名前のワーカがこの要求を処理することを知らせます) ワーカのプロパティファイルである、 workers.properties は、defworker が ajp13 プロトコルを使用することを示しています。
  5. エクステンションは、ワーカからのレスポンスを集めて、それをブラウザに返します。



Installation


インストール

A pre-built version of the Netscape redirector, nsapi_redirect.dll, may be available under the win32/i386 directory of jakarta-tomcat-connectors distribution. For those using Netscape as your browser, try downloading a zip version of the file, if available. There can be problems using Netscape to download DLL files. You can also build a copy locally from the source present in jakarta-tomcat-connectors distribution. The Tomcat redirector requires two entities:

  • nsapi_redirect.dll - The Netscape server plugin, either obtain a pre-built DLL or build it yourself (see the build section).
  • workers.properties - A file that describes the host(s) and port(s) used by the workers (Tomcat processes). A sample workers.properties can be found under the conf directory.
The installation includes the following parts:
  • Configuring the NSAPI redirector with a default /examples context and checking that you can serve servlets with Netscape.
  • Adding more contexts to the configuration.


Netscape リダイレクタ nsapi_redirect.dll のビルド済みのバージョンが、 jakarta-tomcat-connectors 配布の win32/i386 ディレクトリに用意されています。 ブラウザとしてNetscapeを使用する場合には、可能であれば、 ファイルのzpiバージョンのダウンロードを試してください。Netscapeを使用して DLLをダウンロードすると問題が発生することがあります。 また、jakarta-tomcat-connectors 配布のソースをローカルにコピーしてビルドすることもできます。 Tomcat リダイレクタには、以下の2つが必要です。

  • nsapi_redirect.dll - Netscape サーバープラグイン。すでにビルドされているDLLを入手するか、 あなた自身でビルドしてください (ビルドセクションを参照)。
  • workers.properties - ワーカ(Tomcatプロセス)のために使用されるホスト名とポート番号を記述するファイル。 サンプルの workers.properties は conf ディレクトリにあります。
インストールでは、以下のことをおこないます。
  • NSAPIリダイレクタをデフォルトの/exsamples コンテキストで設定して、 NetscapeでServletが実行できることを確認します。
  • さらに他のコンテキストを設定に追加します。


Configuring the NSAPI Redirector


NSAPI リダイレクタの設定

In this document we'll assume that nsapi_redirect.dll is placed in c:\jk\lib\nsapi_redirect.dll , the properties file is in c:\jk\conf and you created a log directory c:\jk\logs


この文書では、nsapi_redirect.dll は、 c:\jk\lib\nsapi_redirect.dll にあり、 プロパティファイルは c:\jk\conf にあり、 ログディレクトリを c:\jk\logs に作成したものと仮定します。

  • If the Netscape built in servlet support is working disable it.
  • Add the redirector plugin into the Netscape server configuration. Edit your server obj.conf and add the following lines:

  • Netscapeが、Servletをサポートするようにビルドされていれば、それを無効にします。
  • リダイレクタプラグインをNetscapeサーバーの設定に追加します。 サーバーの obj.conf を編集して、以下の行を追加します。

In the Init section:
Init fn="load-modules" funcs="jk_init,jk_service" shlib="c:/jk/lib/nsapi_redirect.dll"
Init fn="jk_init" worker_file="c:/jk/conf/workers.properties" log_level="debug" log_file="c:/jk/logs/nsapi.log"
In the default object NameTrans section
NameTrans fn="assign-name" from="/servlet/*" name="servlet"
NameTrans fn="assign-name" from="/examples/*" name="servlet"
Create a new configuration object by adding the following lines to the end of the obj.conf file
<Object name=servlet>
ObjectType fn=force-type type=text/plain
Service fn="jk_service" worker="worker1"
</Object>


Init セクション:
Init fn="load-modules" funcs="jk_init,jk_service" shlib="c:/jk/lib/nsapi_redirect.dll"
Init fn="jk_init" worker_file="c:/jk/conf/workers.properties" log_level="debug" log_file="c:/jk/logs/nsapi.log"
デフォルトobject NameTrans セクション
NameTrans fn="assign-name" from="/servlet/*" name="servlet"
NameTrans fn="assign-name" from="/examples/*" name="servlet"
obj.confファイルの末尾に以下の行を加え、新しい設定オブジェクトを作成します。
<Object name=servlet>
ObjectType fn=force-type type=text/plain
Service fn="jk_service" worker="worker1"
</Object>

  • Restart Netscape (stop and start the server)

  • Netscape を再起動(サーバーの停止と開始)します。

That's all, now you should start tomcat and ask Netscape for http://server:port/examples/


これで終りです。 Tomcatを起動して、Netscapeに http://server:port/examples/ を問い合わせることができます。

Adding additional Contexts


さらにコンテキストを追加する

The examples context is useful for verifying your installation, but you will also need to add your own contexts. Adding a new context requires two operations:


サンプルコンテキストは、インストールを検証するのに役立ちます。 しかし、さらに独自のコンテキストを追加する必要があります。 新しいコンテキストを追加するためには、2つの作業が必要です。

  • Adding the context to Tomcat (I am not going to talk about this).
  • Assigning the NSAPI redirector to handle this context.

  • コンテキストをTomcatに追加します(この文書では説明しません)。
  • NSAPIリダイレクタに、このコンテキストを処理するように割り当てます。

Assigning the NSAPI redirector to handle this context is simple, all you need to do is to edit obj.conf and add a NameTrans line that looks like:


NSAPIリダイレクタに、このコンテキストを取り扱うように割り当てることは簡単で、 obj.conf を編集して、以下のようなNameTrans行を追加するだけです。

NameTrans fn="assign-name" from="/<context name>/*" name="servlet"


NameTrans fn="assign-name" from="/<context name>/*" name="servlet"

After saving obj.conf restart Netscape and it will serve the new context.


obj.conf を保存してからNetscapeをリスタートすれば、あたらしいコンテキストを取扱います。


Advanced Context Configuration


より高度なコンテキストの設定

Sometimes it is better to have Netscape serve the static pages (html, gif, jpeg etc.) 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.


Tomcatが配信するコンテキストの一部のファイルであっても、 Netscapeが静的ページ(html, gif, jpeg,など)を配信する方がよいことがあります。 たとえば、examplesコンテキストの中のHTMLファイルとGIFファイルについて考えると、 わざわざTomcatプロセスからそれを配信しなくても、Netscapeがおこなえば充分です。

Making Netscape serve static files that are part of the Tomcat contexts requires the following:


NetscapeにTomcatコンテキストの一部を静的ファイルとして送信させるには、以下のことが必要になります。

  • Configuring Netscape to know about the Tomcat contexts
  • Make sure that the WEB-INF directory is protected from access.
  • Configuring Netscape to assign the NSAPI redirector only specific requests that requires JSP/Servlet handling.

  • Netscapeに対して、Tomcatコンテキストの設定をおこないます。
  • WEB-INFディレクトリが、アクセスされないように保護されていることを確認します。
  • NSAPIリダイレクタにJSP/Servletの取扱いを必要とする特定の要求だけを割り当てるようにNetscapeを設定します。

Adding a Tomcat context to Netscape requires the addition of a new Netscape virtual directory that covers the Tomcat context.


TomcatコンテキストをNetscapeに追加するためには、Tomcatコンテキストを含む新しいNetscape仮想ディレトクリを追加する必要があります。

For example, adding a /example Netscape virtual directory that covers the c:\jakarta-tomcat\webapps\examples directory.


たとえば、 c:\jakarta-tomcat\webapps\examples ディレクトリを含む/example Netscape 仮想ディレクトリを追加します。

To add a new virtual directory add the following line to your obj.conf :


新たに仮想ディレクトリを追加するためには、 obj.conf に以下の行を追加してください。

NameTrans fn=pfx2dir from=/examples dir="c:/jakarta-tomcat/webapps/examples"


NameTrans fn=pfx2dir from=/examples dir="c:/jakarta-tomcat/webapps/examples"

WEB-INF protection requires some explanation; Each servlet application (context) has a special directory named WEB-INF , this directory contains sensitive configurations data and Java classes and must be kept hidden from web users. WEB-INF can be protected by adding the following line to the PathCheck section in the default configuration object:


WEB-INFの保護については、説明が必要です。 それぞれのServletアプリケーション(コンテキスト)には、 WEB-INF という名前の特別なディレクトリがあります。 このディレクトリには、注意が必要な設定データとJavaクラスが含まれているので、Webユーザからは隠しておかなければなりません。 WEB-INFは、デフォルト設定オブジェクト内のPathCheckセクションに次の行を追加することによって保護されます。

PathCheck fn="deny-existence" path="*/WEB-INF/*"
This line instructs the Netscape server to reject any request with a URL that contain the path /WEB-INF/.


PathCheck fn="deny-existence" path="*/WEB-INF/*"
この行は、/WEB-INF/ パスが含まれるURLを持つすべての要求を拒否するようにNetscapeに指示します。

Configuring Netscape to assign the NSAPI redirector only specific requests is somewhat harder, you will need to specify the exact URL-Path pattern(s) that you want Tomcat to handle (usually only JSP files and servlets).


NSAPIリダイレクタに特定の要求だけを割り当てるようにNetscapeを設定することは、 Tomcatに処理して欲しいURLパスのパターン(通常JSPファイルとServletだけ)を明示的に指定する必要があるので、少し難しくなります。

This requires a change to NemaTrans portion of obj.conf .


これは、 obj.conf のNameTransの部分を変更する必要があります。

For the examples context it requires to replace the following line:
NameTrans fn="assign-name" from="/examples/*" name="servlet"
with the following two lines:
NameTrans fn="assign-name" from="/examples/jsp/*.jsp" name="servlet"
NameTrans fn="assign-name" from="/examples/servlet/*" name="servlet"


たとえば、examplesコンテキストでは、以下の行を書き換える必要があります。
NameTrans fn="assign-name" from="/examples/*" name="servlet"
with the following two lines:
NameTrans fn="assign-name" from="/examples/jsp/*.jsp" name="servlet"
NameTrans fn="assign-name" from="/examples/servlet/*" name="servlet"

As you can see the second configuration is more explicit, it actually instructs Netscape to assign the redirector with only requests to resources under /examples/servlet/ and resources under /examples/ whose name ends with .jsp .


見てわかるように、二番目の設定がより明示的であり、 /examples/servlet/ の下のリソースと、 /examples/ の下にある名前の末尾が .jsp のリソースに対してのみリダイレクタを割り当てています。

You can be even more explicit and provide lines such as:


さらに明示的にするためには、次のように行を指定してください。

NameTrans fn="assign-name" from="/examples/servletname" name="servlet"
Instructs Netscape to assign the redirector request whose URL-Path equals /example/servletname


NameTrans fn="assign-name" from="/examples/servletname" name="servlet"
これは、Netscapeに対して、 要求されたURLパスが /example/servletname に等しい場合に、リクエストをリダイレクタに割り当てるように指示します。


Advanced Worker Configuration


高度なワーカ設定

Sometimes you want to serve different contexts with different Tomcat processes (for example to spread the load among different machines). To achieve such goal you will need to define several workers and assign each context with its own worker.


異なるTomcatプロセスに対して、異なるコンテキストを提供させたい(たとえば、異なるマシンで負荷分散をさせる)場合があります。 そのような目的を達成するためには、複数のワーカを定義して、それぞれのワーカにコンテキストを割り当てる必要があります。

Defining workers is done in workers.properties , this file includes two types of entries:


ワーカの定義は、 workers.properties で行います。 このファイルには、以下の2つのエントリが含まれています。

An entry that lists all the workers defined. For example:
worker.list=worker1, worker2
Entries that define the host and port associated with these workers.
worker.worker1.host=localhost
worker.worker1.port=8009
worker.worker1.type=ajp13
worker.worker2.host=otherhost
worker.worker2.port=8009
worker.worker2.type=ajp13


定義するすべてのワーカのリストのエントリ。例:
worker.list=worker1, worker2
これらのワーカに関連するホストとポートの定義エントリ。例:
worker.worker1.host=localhost
worker.worker1.port=8009
worker.worker1.type=ajp13
worker.worker2.host=otherhost
worker.worker2.port=8009
worker.worker2.type=ajp13

The above examples defined two workers, now we can use these workers to serve two different contexts each with it's own worker. Submitting requests to different workers is accomplished by using multiple Service directives in the servlet configuration Object, each with a different path pattern parameter.


上記の例では、2つのワーカが定義されており、2つの異なるコンテキストに対して、それぞれ独自のワーカを使うことができます。 異なるワーカに対して要求を発行するためには、Servlet設定のObject中で、 異なるパスのパターンのパラメタを持つService指示子を複数使用すれば可能です。

For example, if we want to submit the /examples context to the worker named worker1 and the /webpages context to the worker named worker2 we should use the following configuration:


たとえば、 /examples コンテキストには worker1 という名前のワーカを使用して、 /webpages コンテキストには worker2 という名前のワーカを使用したい場合には、以下のような設定をしなければなりません。

<Object name=servlet>
ObjectType fn=force-type type=text/plain
Service fn="jk_service" worker="worker1" path="/examples/*"
Service fn="jk_service" worker="worker2" path="/webpages/*"
Service fn="jk_service" worker="worker1"
</Object>


<Object name=servlet>
ObjectType fn=force-type type=text/plain
Service fn="jk_service" worker="worker1" path="/examples/*"
Service fn="jk_service" worker="worker2" path="/webpages/*"
Service fn="jk_service" worker="worker1"
</Object>

More informations on using and configuring workers in the Workers HowTO


ワーカの使用や設定に関するより詳細な情報は ワーカの手引き にあります。



Building NSAPI redirector


NSAPI リダイレクタのビルド

The redirector was developed using Visual C++ Ver.6.0, so having this environment is a prereq if you want to perform a custom build. You should also have NES developer SDK The steps that you need to take are:

  • Change directory to the nsapi plugins source directory.
  • Edit nsapi.dsp and update the include and library path to reflect your own Netscape server installation (search for a /I compiler option and /libpath linker option)
  • Make the source with MSDEV

Change directory to the nsapi plugins source directory
c:\> cd c:\home\apache\jk\nsapi
Build the sources using MSDEV
c:\> MSDEV nsapi.dsp /MAKE ALL


リダイレクタはVisual C++ Ver.6.0を使って開発されたので、カスタムビルドしたい場合には、あらかじめこの環境を用意しておく必要があります。 また、NES 開発 SDK も必要です。 必要な手順は以下のとおりです。

  • nsapiプラグインソースディレクトリに移動します。
  • nsapi.dsp を編集して、includeとライブラリパスが、インストールしたNetscapeサーバーを参照するように更新します。 (コンパイラオプションの /I とリンカオプションの /libpath を見つけてください)
  • MSDEV でソースを Make(コンパイル)します。

nsapiプラグインソースディレクトリに移動
c:\> cd c:\home\apache\jk\nsapi
MSDEV を使ってソースをビルド
c:\> MSDEV nsapi.dsp /MAKE ALL

If msdev is not in your path, enter the full path to msdev.exe. This will build both release and debug versions of the redirector plugin. An alternative will be to open the nsapi workspace file (nsapi.dsw) in msdev and build it using the build menu.


もし、msdevがパスに無い場合には、msdev.exeへのフルパスを入力します。 これは、リダイレクタプラグインのリリース版とデバッグ版の両方をビルドします。 他に、msdevで nsapiワークスペースファイル(nsapi.dsw)を開いて、ビルドメニューを使用してビルドできます。


[訳注: これは鰈崎 義之が翻訳しました。日本語訳に対するコメントがあれば、こちらに送って下さい。(熊坂氏翻訳のtomcat-netscape-howto.htmlをベースに一部追加・修正)]