How to setup AWS ELB to proxy requests for Bitbucket Server
Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.
Note that this KB was created for the Data Center version of the product. Data Center KBs 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
Summary
This guide will help to setup and configure an Elastic Load Balancer in AWS to proxy requests to Bitbucket Server.
Solution
AWS Configuration
1. Create an EC2 instance and install Bitbucket Server as directed in our Getting started guide
2. Under the EC2 page in AWS, navigate to Load Balancing >> Load Balancers
and create a new load balancer with the following basic configuration
Load Balancer name | Unique name for the load balancer |
Create LB Inside | Note the VPC used here as we'll use it later |
Listener Configuration
Load Balancer Protocol | Load Balancer Port | Instance Protocol | Instance Port |
---|---|---|---|
HTTP | 80 | HTTP | 7990 |
TCP | 22 | TCP | 7999 |
3. Create a new Security Group that allows inbound traffic on ports 22 and 80 from the appropriate sources
4. Use the following configuration for the Health Check
Ping Protocol | HTTP |
Ping Port | 7990 |
Ping Path | /status |
5. Select the appropriate EC2 instances to associate with this ELB instance
6. Save the ELB
7. Navigate to your EC2 instances and modify the Security Group to allow inbound connections on port 7990 and 7999 with the ELB VPC as the source (configured in the initial setup of the ELB)
Bitbucket Server Configuration
Set the Base URL
Under Administration >> Server Settings
set the Base URL to the ELB address, i.e. http://bitbucket-elb.us-west-2.elb.amazonaws.com
Also, set the SSH base URL, i.e. ssh://bitbucket-elb.us-west-2.elb.amazonaws.com
Configure the Tomcat Connector
Bitbucket 5.0+
Update the BITBUCKET_HOME/shared/bitbucket.properties
and modify the connector for port 7990 so that it has the proxy configuration - proxy-name
, proxy-port
:
server.proxy-port=80
server.proxy-name=bitbucket-elb.us-west-2.elb.amazonaws.com
After this, restart Bitbucket Server.
Bitbucket Server 4.14 and below
Update the BITBUCKET_HOME/shared/server.xml
and modify the connector for port 7990 so that it has the proxy configuration - scheme
, proxyName
, proxyPort
:
<Connector port="7990"
protocol="HTTP/1.1"
connectionTimeout="20000"
useBodyEncodingForURI="true"
redirectPort="8443"
compression="on"
compressableMimeType="text/html,text/xml,text/plain,text/css,application/json,application/javascript,application/x-javascript"
scheme="http"
proxyName="bitbucket-elb.us-west-2.elb.amazonaws.com"
proxyPort="80" />
After this, restart Bitbucket Server.
For more details on configuring the proxy see Proxy and secure Bitbucket.
Troubleshooting
Windows
Verify that ports 7990 and 7999 are open in the Windows Firewall.
Was this helpful?