このページでは、mod_proxy を使用して Apache web サイトに Confluence を統合する方法を説明します。

 

設定を使用する場合がある状況がいくつかあります。

Note: This page documents a configuration of Apache, rather than of Confluence itself. Atlassian will support Confluence with this configuration, but we cannot guarantee to help you debug problems with Apache. Please be aware that this material is provided for your information only, and that you use it at your own risk.

基本設定

これらの例では、以下を使用します。

http://www.example.com/confluence - 希望の URL

http://example:8090 - 現在 Confluence がインストールされているホスト名とポート

/confluence - 希望のコンテキスト パス(ホスト名とポートの後の部分)

以下の例では、ご利用のサーバーの希望の URL に置き換えてください。以下の内容のコピー/貼り付けをすると、ご利用のサーバーで動作しません。

コンテキストパスを設定する

Set your Confluence application path (the part after hostname and port). To do this in Tomcat (bundled with Confluence), edit conf/server.xml, locate the "Context" definition:

<Context path="" docBase="../confluence" debug="0" reloadable="true">

次のように変更します。

<Context path="/confluence" docBase="../confluence" debug="0" reloadable="true">

Confluence を再起動し、http://example:8090/confluence でアクセスできることを確認します。

リダイレクション用 URL の設定

Set the URL for redirection. In the same conf/server.xml file, locate this code segment:

    <Connector port="8090" maxHttpHeaderSize="8192"
               maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
               enableLookups="false" redirectPort="8443" acceptCount="100"
               connectionTimeout="20000" disableUploadTimeout="true" />

最後の行を追加します。

    <Connector port="8090" maxHttpHeaderSize="8192"
               maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
               enableLookups="false" redirectPort="8443" acceptCount="100"
               connectionTimeout="20000" disableUploadTimeout="true"
               proxyName="www.example.com" proxyPort="80" />

これで動作しない場合、および SSL を使用している場合、Connector タグに、scheme 属性 scheme="https" を追加してみてください。

 

ここで2つの選択肢があります。

単純な設定

mod_proxy の設定

Now enable mod_proxy in Apache, and proxy requests to the application server by adding the example below to your Apache httpd.conf (note: the files may be different on your system; the JIRA docs describe the process for Ubuntu/Debian layout):

Apache 2.2
# Put this after the other LoadModule directives
LoadModule proxy_module /usr/lib/apache2/modules/mod_proxy.so
LoadModule proxy_http_module /usr/lib/apache2/modules/mod_proxy_http.so

# Put this in the main section of your configuration (or desired virtual host, if using Apache virtual hosts)
ProxyRequests Off
ProxyPreserveHost On

<Proxy *>
    Order deny,allow
    Allow from all
</Proxy>

ProxyPass /confluence http://app-server.internal.example.com:8090/confluence
ProxyPassReverse /confluence http://app-server.internal.example.com:8090/confluence
<Location /confluence>
    Order allow,deny
    Allow from all
</Location>
Apache 2.4
# Put this after the other LoadModule directives
LoadModule proxy_module /usr/lib/apache2/modules/mod_proxy.so
LoadModule proxy_http_module /usr/lib/apache2/modules/mod_proxy_http.so

# Put this in the main section of your configuration (or desired virtual host, if using Apache virtual hosts)
ProxyRequests Off
ProxyPreserveHost On

<Proxy *>
	# Auth changes in 2.4 - see http://httpd.apache.org/docs/2.4/upgrading.html#run-time
    Require all granted
</Proxy>

ProxyPass /confluence http://app-server.internal.example.com:8090/confluence
ProxyPassReverse /confluence http://app-server.internal.example.com:8090/confluence
<Location /confluence>
	# Auth changes in 2.4 - see http://httpd.apache.org/docs/2.4/upgrading.html#run-time
    Require all granted
</Location>

It is recommended that you specify the absolute path to the mod_proxy.so and mod_proxy_http.so files.

複雑な設定

複雑な設定は、mod_proxy_html フィルタを使用して、途中のプロキシされたコンテンツを変更することに関連します。Apache とアプリケーション サーバーの間で Confluence のパスが異なる場合にこれが必要になります。例:

外部からアクセス可能な(Apache) URL

http://confluence.example.com/

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

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

URL のアプリケーション パスがそれぞれ異なっていることに注意してください。Apache ではパスが / ですが、アプリケーション サーバーではパスが /confluence になっています。

この設定の場合、標準の Apache ディストリビューションに含まれない mod_proxy_html モジュールをインストールする必要があります。

別のソリューションを以下で説明します。

Apache 2.2
# Put this after the other LoadModule directives
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule proxy_html_module modules/mod_proxy_html.so

<VirtualHost *>
    ServerName confluence.example.com
    
    # Put this in the main section of your configuration (or desired virtual host, if using Apache virtual hosts)
    ProxyRequests Off
    ProxyPreserveHost On

    <Proxy *>
        Order deny,allow
        Allow from all
    </Proxy>
    
    ProxyPass / http://app-server.internal.example.com:8090/confluence
    ProxyPassReverse / http://app-server.internal.example.com:8090/confluence
    
    ProxyHTMLURLMap / /confluence/
    
    <Location />
        Order allow,deny
        Allow from all
    </Location>
</VirtualHost>
Apache 2.4
# Put this after the other LoadModule directives
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule proxy_html_module modules/mod_proxy_html.so

<VirtualHost *>
    ServerName confluence.example.com
    
    # Put this in the main section of your configuration (or desired virtual host, if using Apache virtual hosts)
    ProxyRequests Off
    ProxyPreserveHost On

    <Proxy *>
		# Auth changes in 2.4 - see http://httpd.apache.org/docs/2.4/upgrading.html#run-time
    	Require all granted
    </Proxy>
    
    ProxyPass / http://app-server.internal.example.com:8090/confluence
    ProxyPassReverse / http://app-server.internal.example.com:8090/confluence
    
    ProxyHTMLURLMap / /confluence/
    
    <Location />
		# Auth changes in 2.4 - see http://httpd.apache.org/docs/2.4/upgrading.html#run-time
    	Require all granted
    </Location>
</VirtualHost>

複数のアプリケーションがこの設定で実行している場合、ProxyHTMLURLMap 設定が、より複雑になる可能性があります。web サーバー URL がサブディレクトリであり、仮想ホスト上にない場合、マッピングを Location ブロックにも記載する必要があります。Apache Week チュートリアルには、このための情報がより多くあります。

最終設定手順

Apache サーバーの再起動

これは新しい設定を有効するのに必要です。コマンドライン/ターミナル/シェルで以下を実行することで完了できます。

sudo apachectl graceful

HTTP 圧縮を無効にする

プロキシと Tomcat の両方で圧縮を実行すると、JIRA などのアトラシアンの他のアプリケーションをと統合する際に問題が発生することがあります。「Confluence 内で HTTPレスポンスを圧縮する」を参照して、HTTP 圧縮を無効にしてください。

Confluence の Base URL の設定

最後の段階では、Base URL に、プロキシ内で使用するアドレスを設定します。この例では、http://www.example.com/confluence です。

SSL の追加

If you're running Apache in front of Tomcat, it's a good idea to terminate your SSL configuration at Apache, then forward the requests to Tomcat over HTTP. You can set up Apache to terminate the SSL connection and use the ProxyPass and ProxyPassReverse directives to pass the connection through to Tomcat (or the appropriate application server) which is running Confluence.

  1. Create a new SSL host by creating a virtual host on 443
  2. The standard http connection on apache could be used to redirect to https if you want or it could just be firewalled.
  3. Within the VirtualHost definition:
    1. define the SSL options (SSLEngin and SSLCertificateFile)
    2. define the ProxyPass and ProxyPassReverse directives to pass through to Tomcat.

Most of the relevant Apache Config:

Listen 443

NameVirtualHost *:443
<VirtualHost *:443>
    SSLEngine On
    SSLCertificateFile /etc/apache2/ssl/apache.pem
    ProxyPass / http://localhost:8090/
    ProxyPassReverse / http://localhost:8090/
</VirtualHost>

Apart from the Apache configuration there are a couple of things you will need to do before you get your server working:

  1. You will have to change your base URL to point to https addresses. See the documentation on configuring the server base URL.
  2. We need to set up the connector to use https. In your installation directory, edit the file server.xml and add this attributes to your connector:
proxyName="proxy.example.com" proxyPort="443" scheme="https" secure="true" 

詳細情報

代替手段

Tomcat がアプリケーション サーバーの場合、2つの選択肢があります。

  • mod_jk を使用してリクエストを Tomcat に送信します。
  • Tomcat の仮想ホストを使用し、Confluence アプリケーション ディレクトリをアプリケーション サーバーと web サーバーで同じにして、URL マップングの必要性を取り除きます。

アプリケーション サーバーが AJP コネクタを持っている場合

  • mod_jk を使用して、リクエストをアプリケーション サーバーに送信します。
  • ラベルなし