How to setup AWS ELB to proxy requests for Bitbucket Server

Still need help?

The Atlassian Community is here for you.

Ask the community

Purpose

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 nameUnique name for the load balancer
    Create LB InsideNote the VPC used here as we'll use it later

    Listener Configuration

    Load Balancer ProtocolLoad Balancer PortInstance ProtocolInstance Port
    HTTP80HTTP7990
    TCP22TCP7999
  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 ProtocolHTTP
    Ping Port7990
    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 Server 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.



Last modified on May 2, 2017

Was this helpful?

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