How to use Apache as a Load Balancer for Confluence Data Center

お困りですか?

アトラシアン コミュニティをご利用ください。

コミュニティに質問

プラットフォームについて: Server および Data Center のみ。この記事は、Server および Data Center プラットフォームのアトラシアン製品にのみ適用されます。

Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Fisheye および Crucible は除く

Atlassian applications can be accessed through Load Balancer, however, Atlassian Support does not provide assistance for configuring it. Consequently, Atlassian cannot guarantee providing any support for it.

目的

This how-to guide aims to provide all the details you need to set up Apache as a Load Balancer for your Confluence Data Center instance. In this example, we will consider a two node Cluster with Synchrony in self-managed mode, although it should work fine for Synchrony standalone mode as well.

Tests for the steps below were performed with Confluence version 6.12.

ソリューション

In this section, we will cover how to configure your Apache server to act as a Load Balancer for your nodes.

Prerequisites

  1. Apache version 2.4+ with support for support WebSockets
  2. The following modules must be enabled in your main httpd.conf file:
    1. proxy_module

    2. proxy_http_module

    3. proxy_wstunnel_module
    4. proxy_balancer_module
    5. lbmethod_byrequests_module
    6. headers_module
    7. rewrite_module

Virtual host settings

The configuration below enables support for WebSockets and forward requests directly to Synchrony, which should result in the lowest latency possible while interacting with the editor:

Apache Virtual Host
<VirtualHost *:80>

    # Specify your server name, should match the external domain of the instance
    ServerName <COMPANY-DOMAIN>

    <Location /balancer-manager>
        SetHandler balancer-manager
        Require all granted
    </Location>

    # Main Synchrony proxy rule
    ProxyPass /synchrony  balancer://synchrony-http/synchrony

    # Synchrony HTTP balancer declaration
    <Proxy balancer://synchrony-http>
        BalancerMember http://<Server1-IP>:<Synchrony-PORT> route=synnode1
        BalancerMember http://<Server2-IP>:<Synchrony-PORT> route=synnode2

        Require all granted
    </Proxy>

    # Synchrony WebSocket balancer declaration
    <Proxy balancer://synchrony-ws>
        BalancerMember ws://<Server1-IP>:<Synchrony-PORT> route=synnode1
        BalancerMember ws://<Server2-IP>:<Synchrony-PORT> route=synnode2

        Require all granted
    </Proxy>

    # WebSocket rewrite condition and rules
    RewriteEngine     On
    RewriteCond       %{REQUEST_URI}       ^/synchrony/(.*)/bayeux-sync1   [NC]
    RewriteRule       /(.*)                balancer://synchrony-ws/$1      [P,L]

    # Main Confluence balancer
    Header add Set-Cookie "ROUTEID=.%{BALANCER_WORKER_ROUTE}e; path=/" env=BALANCER_ROUTE_CHANGED
    <Proxy "balancer://confluence-cluster">
        BalancerMember "http://<Server1-IP>:<Confluence-PORT>" route=1
        BalancerMember "http://<Server2-IP>:<Confluence-PORT>" route=2
        ProxySet stickysession=ROUTEID
    </Proxy>

    # Main Confluence proxy rules
    ProxyPass        "/" "balancer://confluence-cluster/"
    ProxyPassReverse "/" "balancer://confluence-cluster/"

</VirtualHost>

You will notice that we have three balancers declared, they are:

  1. <Proxy balancer://synchrony-http>: Main Synchrony HTTP balancer, it will forward all non-WebSocket connections to the Synchrony nodes
  2. <Proxy balancer://synchrony-ws>: Second Synchrony balancer, this one is dedicated to forwarding the WebSocket connection that is established between the browser and Synchrony when we open the editor
  3. <Proxy "balancer://confluence-cluster">: This is the Confluence HTTP balancer, it will forward the requests that do not target Synchrony to the respective servers and endpoint

After creating the virtual host above, make sure to restart Apache so it can pick up the new settings.

注意

If you are terminating SSL at Apache, which is recommended, you will just need to add the certificate related information to the configuration above and change the port of the Virtual Host to 443. Also, please make sure to swap the placeholders with the actual IPs and Ports used by Confluence and Synchrony.

Tomcat settings

In this section, we will cover the changes needed in <Confluence-Install>/conf/server.xml to add the Load Balancer settings. This is a connector example with the Proxy/LB settings in place:

<Connector port="<PORT>" connectionTimeout="20000" redirectPort="8443"
maxThreads="48" minSpareThreads="10"
enableLookups="false" acceptCount="10" debug="0" URIEncoding="UTF-8"
protocol="org.apache.coyote.http11.Http11NioProtocol"
scheme="<HTTP/HTTPS>" proxyName="<DOMAIN>" proxyPort="<ProxyPort>"/>

The place holders here are:

  1. port="<PORT>": this should be set to the port that the balancer is targeting for the Confluence requests, by default it is 8090
  2. scheme="<HTTP/HTTPS>": this should match the protocol that you are using to access the application
  3. proxyName="<DOMAIN>": should be set to the company domain, same as the proxy ServerName parameter and the server base URL set in the UI
  4. proxyPort="<ProxyPort>": set this to the port that Apache is listening to, usually 80 for HTTP and 443 for HTTPS

Make sure to apply those changes in all of your Confluence nodes and restart them to apply.

トラブルシューティング

If you face issues while creating/editing pages (specifically, 404 HTTP responses), check: CONFSERVER-55946 - Getting issue details... STATUS

Additionally, confirm that you don't have this property set on your Apache configs: ProxyErrorOverride on.

If you do, remove it.


説明 Configure Apache as Load Balancer for Confluence Data Center
製品Confluence

最終更新日: 2021 年 1 月 6 日

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

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