Configuring Apache mod_proxy_balancer for Bitbucket Data Center
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 |
---|---|---|---|---|---|
| DDFACF910F0F807930AE2A382956018F | backend1 | /bitbucket/ | Session | Backend Tomcat |
ROUTEID | .perftest1 | backend1 | / | Session | Apache |
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 |
---|---|---|---|---|---|
| 9CA086750138E6FC6965D1A82E652E96.perftest1 | backend1 | /bitbucket/ | Session | Backend Tomcat |
Note that the route information is added as a suffix on BITBUCKETSESSIONID value