How to set up NGINX Plus as the load balancer for a Bamboo Data Center cluster
Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.
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
Atlassian applications allow the use of load balancers and reverse-proxies with our products, however Atlassian Support does not provide assistance for configuring them. Consequently, Atlassian cannot guarantee providing any support for them.
If assistance with configuration is required, please raise a question on Atlassian Community.
This configuration only works with NGINX Plus, the paid version of NGINX. The free version of NGINX (NGINX Open Source) does not support Active Health Checks.
Purpose
Bamboo Data Center needs a load balancer to run in front of it to distribute incoming requests (both HTTP/s and TCP) to the stand-by node in case the active node stops working. The load balancer must support cookie-based session-affinity ("sticky sessions"). NGINX Plus can be set up to provide this for Bamboo Data Center. You still need to follow the full installation guide available at Installing Bamboo Data Center to set up a Data Center instance of Bamboo.
For more details on the load balancer configuration using NGINX Plus, please have a look at the High-Performance Load Balancing with NGINX Plus page on the NGINX website.
Solution
In this article we will provide an example of load balancer configuration using NGINX Plus typically found inside the /etc/nginx folder.
The load balancer configuration below was created using the following NGINX Plus documentation pages:
HTTP/s
TCP
This assumes:
- The NGINX Plus process is running under the
nginx
account in the operating system. - The NGINX Plus configuration is stored inside the
nginx.conf
file. The Bamboo cluster nodes are at addresses 192.168.0.1 and 192.168.0.2, listening on the default ports 8085 (HTTP) and 54663 (TCP).
- The server name is
bambooserver
. Users connect to NGINX Plus on port 80 from their web browser.
- You want to use sticky_route as the session persistence method.
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log notice;
pid /var/run/nginx.pid;
events {
worker_connections 4096;
}
http {
# Search the cookie named BAMBOOSESSIONID for data after the final '.' and store that in a variable named $route_cookie
map $cookie_bamboosessionid $route_cookie {
~.+\.(?P<route>\w+)$ $route;
}
# Search the URL for a trailing BAMBOOSESSIONID parameter and store the value after the final '.' in a variable named $route_uri
map $request_uri $route_uri {
~bamboosessionid=.+\.(?P<route>\w+)$ $route;
}
upstream bamboocluster {
zone bamboocluster 64k;
server 192.168.0.1:8085;
server 192.168.0.2:8085;
sticky route $route_cookie $route_uri;
}
server {
listen 80;
server_name bambooserver;
location / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://bamboocluster;
health_check uri=/rest/api/latest/status mandatory persistent;
}
}
}
stream {
upstream brokers {
zone brokers 64k;
server 192.168.0.1:54663;
server 192.168.0.2:54663;
}
server {
listen 54663;
proxy_pass brokers;
health_check;
}
}
Please review the contents of the nginx.cfg
file carefully and make any changes necessary to adapt it to your environment.
Once you have configured the nginx.cfg
file you can test your configuration using the following command before restarting NGINX Plus:
nginx -t
If the syntax is ok and the test successful you can restart NGINX Plus using:
nginx -s reload