Configuring Apache mod_proxy_balancer for Bitbucket Data Center

Still need help?

The Atlassian Community is here for you.

Ask the community

Platform Notice: Data Center - This article applies to Atlassian products on the Data Center platform.

Note that this knowledge base article was created for the Data Center version of the product. Data Center knowledge base articles for non-Data Center-specific features may also work for Server versions of the product, however they have not been tested. 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.

*Except Fisheye and Crucible

Disclaimer

As Bitbucket Data Center applications are using the load balancer both on the application (HTTPS) and transport (SSH) levels it is strongly recommended to use the load balancer software capable of performing a load balancing on both levels. Until usage of mod_proxy_balancer is not the requirement we recommend you to use the HAProxy as mentioned in the documentation.

mod_proxy_balancer examples

Bitbucket DC requires sticky HTTP sessions. Using a cookie strategy approach for this will give you more control over user IP changes that occur due to network or VPN configuration.

mod_proxy_balancer with specific cookie

This is the less intrusive approach where your load balancer creates a specific cookie to route all the requests from the same session to the same backend server.
In this example, we will instruct Apache to create a cookie called ROUTEID, and use it for stickysession.

Header add Set-Cookie "ROUTEID=.%{BALANCER_WORKER_ROUTE}e; path=/" env=BALANCER_ROUTE_CHANGED

<Proxy balancer://bitbucketcluster>

    BalancerMember http://backend1:7990 route=perftest1

    BalancerMember http://backend2:7990 route=perftest2

</Proxy>

ProxySet stickysession=ROUTEID
ProxyPass / balancer://bitbucketcluster/ lbmethod=byrequests stickysession=ROUTEID
ProxyPreserveHost On


In that case when the user is connected to Bitbucket DC the following cookies are getting set:

Cookie Name

Cookie Value

Domain

Path

Expires

Created by

BITBUCKETSESSIONID
DDFACF910F0F807930AE2A382956018Fbackend1/bitbucket/SessionBackend Tomcat
ROUTEID.perftest1backend1/SessionApache


Tomcat BITBUCKETSESSIONID cookie

Tomcat supports routing information in the BITBUCKETSESSIONID cookie when you start with -DjvmRoute=<nodeName> parameter. This information is also used by Apache.

<Proxy balancer://bitbucketcluster>
    BalancerMember http://backend1:7990 route=perftest1
    BalancerMember http://backend2:7990 route=perftest2
</Proxy>
ProxyPass / balancer://bitbucketcluster/ stickysession=BITBUCKETSESSIONID


In that case when the user is connected to Bitbucket DC the following cookies are getting set:

Cookie Name

Cookie Value

Domain

Path

Expires

Created by

BITBUCKETSESSIONID
9CA086750138E6FC6965D1A82E652E96.perftest1backend1/bitbucket/SessionBackend Tomcat

Note that the route information is added as a suffix on BITBUCKETSESSIONID value


Description
Product



Last modified on Nov 4, 2019

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.