2.3. mod_jk をロードするように Apache HTTP Server を設定する
mod_jk.conf ファイルで設定設定を指定することにより、mod_jk をロードするように Apache HTTP Server を設定できます。
次のオプションの設定手順を実行することもできます。
-
JkMountディレクティブの他に、JkMountFileディレクティブを使用してマウントポイントの設定ファイルを指定できます。設定ファイルには、Tomcat 転送の複数の URL マッピングが含まれます。 - ロードバランサーとして機能している Apache HTTP Server を設定して、要求を処理する各ワーカーノードの詳細をログに記録できます。これは、ロードバランサーのトラブルシューティングが必要な場合に役立ちます。
手順
-
JBCS_HOME/httpd/conf.dディレクトリーに移動します。 mod_jk.confという名前の新しいファイルを作成し、次の設定の詳細を入力します。# Load mod_jk module # Specify the filename of the mod_jk lib LoadModule jk_module modules/mod_jk.so # Where to find workers.properties JkWorkersFile conf.d/workers.properties # Where to put jk logs JkLogFile logs/mod_jk.log # Set the jk log level [debug/error/info] JkLogLevel info # Select the log format JkLogStampFormat "[%a %b %d %H:%M:%S %Y]" # JkOptions indicates to send SSL KEY SIZE JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories # JkRequestLogFormat JkRequestLogFormat "%w %V %T" # Mount your applications JkMount /application/* loadbalancer # Add shared memory. # This directive is present with 1.2.10 and # later versions of mod_jk, and is needed for # for load balancing to work properly JkShmFile logs/jk.shm # Add jkstatus for managing runtime data <Location /jkstatus/> JkMount status Require ip 127.0.0.1 </Location>重要LoadModuleディレクティブが、インストールしたmod_jkネイティブバイナリーを参照していることを確認します。注記JkMountディレクティブは、Apache HTTP Server がmod_jkモジュールに転送できる URL を指定します。JkMountディレクティブの設定に基づいて、mod_jkは受信した URL を正しいサーブレットコンテナーに転送します。Apache HTTP Server が静的コンテンツ (または PHP コンテンツ) を直接提供し、Java アプリケーションにのみロードバランサーを使用できるようにするには、前述の設定例では、Apache HTTP Server が URL
/application/*のリクエストのみをmod_jkロードバランサーに送信するよう指定します。または、
JkMountディレクティブで/*を指定して、すべての URL をmod_jkに転送するように Apache HTTP Server を設定することもできます。オプション:
JkMountFileディレクティブを使用してマウントポイントの設定ファイルを指定するには、次の手順を実行します。-
JBCS_HOME/httpd/conf.d/ディレクトリーに移動します。 -
uriworkermap.propertiesという名前のファイルを作成します。 転送する URL とワーカー名を指定します。
以下に例を示します。
# Simple worker configuration file # Mount the Servlet context to the ajp13 worker /application=loadbalancer /application/*=loadbalancer注記必要な構文は次の形式です:
/URL = WORKER_NAME上記の例では、
/applicationのリクエストを JBoss Web Server Tomcat バックエンドに転送するようにmod_jkを設定しています。JBCS_HOME/httpd/conf.d/mod_jk.confファイルで、次のディレクティブを入力します。# Use external file for mount points. # It will be checked for updates each 60 seconds. # The format of the file is: /url=worker # /examples/*=loadbalancer JkMountFile conf.d/uriworkermap.properties
-
オプション: Apache HTTP Server のログを有効にするには、次のいずれかの手順を実行します。
-
mod_jk.conf設定に関する前の手順で示したように、JkRequestLogFormatディレクティブに%wを含めます。 -
%{JK_WORKER_NAME}nを Apache HTTP ServerLogFormat(s) に含めて、使用するmod_jkワーカーの名前をログに記録します。
-