Apache で mod_jk を使用する

  • The preferred configuration is Using Apache with mod_proxy. This works with any application server, and together with mod_proxy_html allows complex URL rewriting to deal with different application paths on the web server and the application server.
  • このページは Confluence 自体ではなく、Apache の設定について記述しています。アトラシアンはこの構成による Confluence をサポートしていますが、Apache によって問題をデバッグできると保証することはできません。この資料は情報提供のみを目的としているため、自己責任で使用されるようご注意ください。

 

はじめに

Apache web サーバーは、高負荷環境のパフォーマンスを改善するため、アプリケーション サーバーのフロントでよく使用されます。mod_jk を使用すると、AJP と呼ばれるプロトコルを介して、リクエストをアプリケーションに転送することができます。この設定は、Apache での mod_jk の有効化、アプリケーション サーバーでの AJP コネクタの設定、または Apache への mod_jk を介したアプリケーション サーバーへの特定のパスの転送の指示に関係します。

Mod_jk is sometimes preferred to mod_proxy because AJP is a binary protocol, and because some site administrators are more familiar with it than with mod_proxy..

このドキュメントのスコープは、Tomcat 5.x の AJP コネクタの設定に限定されています。他のアプリケーション サーバーも AJP コネクタをサポートしている場合があるため、設定する方法の手順に関するアプリケーション サーバーのドキュメントを参照してください。

以下の設定は、Confluence インスタンスが、アプリケーション サーバーと web サーバーで同じパスが適用されていることを前提としています。例:

外部からアクセス可能な(web サーバーの) URL

http://www.example.com/confluence/

アプリケーション サーバーの URL (HTTP)

http://app-server.internal.example.com:8090/confluence/

アプリケーション サーバーのAJP 接続は app-server.internal.example.com:8009 に設定されています。

Apache での mod_jk の設定

The standard distribution of Apache does not include mod_jk. You need to download it from the JK homepage and put the mod_jk.so file in your Apache modules directory.

次に、以下を httpd.conf に直接追加するか、他のファイルからインクルードします。

# Put this after the other LoadModule directives
LoadModule jk_module modules/mod_jk.so

# Put this in the main section of your configuration (or desired virtual host, if using Apache virtual hosts)
JkWorkersFile conf/workers.properties
JkLogFile logs/mod_jk.log
JkLogLevel info

JkMount /confluence worker1
JkMount /confluence/* worker1

workers.properties の設定

「workers.properties」というファイルを新しく作成し、Apache の conf ディレクトリに配置します(workers.properties は上記の設定ファイルの1つです)。

worker.list=worker1

worker.worker1.host=app-server.internal.example.com
worker.worker1.port=8009
worker.worker1.type=ajp13

Tomcat 5.x の設定

Tomcat 5 において、デフォルトではポート 8009 でAJP コネクタが有効になっています。比較のため、以下には Tomcat の server.xml を最小限表示しています。関連する行は、ポート 8009 の Connector の部分です。server.xml でこれがコメント化されていないことを確認します。

<Server port="8000" shutdown="SHUTDOWN">
  <Service name="Catalina">

    <!-- Define a HTTP/1.1 Connector on port 8090 -->
    <Connector port="8090" />

    <!-- Define an AJP 1.3 Connector on port 8009 -->
    <Connector port="8009" protocol="AJP/1.3" />

    <Engine name="Catalina" defaultHost="localhost">
      <Host name="localhost" appBase="webapps">
	<Context path="/confluence" docBase="/opt/webapps/confluence-2.2/confluence"/>
        <Logger className="org.apache.catalina.logger.FileLogger"/>
      </Host>
    </Engine>
  </Service>
</Server>

注意点:

  • ポート 8009 の Connector が「AJP/1.3」のプロトコルを持っていること。これが重要です。
  • Confluence アプリケーションの Context path が「/confluence」であること。これは web サーバーの Confluence にアクセスするのに使用されるパスと一致している必要があります。
  • Tomcat 5.x の server.xml の外側のアプリケーション Contexts はそのままにしておくことをお勧めします。上記の例では、例として示すためだけに表示しています。

mod_jk コネクタのパフォーマンスの改善

高負荷環境におけるもっとも重要な設定は、Tomcat AJP コネクタが使用するプロセッサ スレッド数です。デフォルトでは、これは200になっていますが、Apache の maxThreads (デフォルトでは256)と一致するように増やす必要があります。

<Connector port="8009" minSpareThreads="5" maxThreads="256" protocol="AJP/1.3" />

All the configuration parameters for the AJP connector are covered in the Tomcat documentation.

UTF-8 互換性の保証

ファイル名に非アスキー文字を含む添付ファイルをダウンロードする際に問題が発生した場合、以下を Apache の設定に追加します。

JkOptions +ForwardURICompatUnparsed

そして、AJP コネクタの設定の URIEncoding に UTF-8 を指定します。

<Connector port="8009" protocol="AJP/1.3" URIEncoding="UTF-8" />

These settings are discussed further on Configuring Tomcat's URI encoding.

詳細情報

The Tomcat JK website has complete documentation on workers.properties and Apache configuration. You can also find information there on how to use mod_jk with IIS.

注: IIS プロキシ サーバーのアップロード ファイルの最大サイズは、デフォルトで 30MB です。より大きいファイルをアップロードする必要がある場合は、サーバー管理者に連絡してください。

最終更新日: 2015 年 12 月 2 日

この内容はお役に立ちましたか?

はい
いいえ
この記事についてのフィードバックを送信する
Powered by Confluence and Scroll Viewport.