Evaluate Smart Mirrors with ngrok

If you want to quickly evaluate Smart Mirroring in Bitbucket Cloud and don't want to go through the hassle of getting a valid SSL certificate follow these simple steps below to set up a mirror with ngrok. Get up and running in less than 10 minutes.

What you'll do:

  • Install a Smart Mirror on your local machine.

  • Use ngrok to forward HTTPS requests to your local mirror (mirrors only work with HTTPS for security reasons).

  • Clone from your local mirror instead of Bitbucket Cloud. 

Use ngrok for evaluation purposes only

  • We recommend using ngrok for evaluation purposes only.

  • ngrok will only work with HTTPS and not SSH.

  • A locally set up mirror on your own server will be faster than using ngrok even when specifying a region. The main purpose of this guide is to show how quickly you can spin up your own mirror and evaluate it using ngrok. This guide should help you to decide whether a mirror is the right investment to accelerate your global team.

Install Bitbucket Server on your local machine

  1. Download the latest version of the Bitbucket installer from www.atlassian.com/software/bitbucket/download.

  2. Run the installer, making sure to select Install a new instance and then Install a mirror instance.

  3. Stick to the default values for the rest of the installation process

  4. Remember your Bitbucket Home directory (where all your mirror specific data is stored) and Destination Directory.

Let's assume we've set our Bitbucket Home directory and Destination Directory to the following:

1 2 BITBUCKET_HOME = /Users/sszasztoth/Atlassian/ApplicationData/Bitbucket DEST_DIRECTORY = /Users/sszasztoth/Atlassian/Bitbucket

Install and start ngrok

Download and install ngrok, which is a super handy tool to expose our localhost to the Internet and Bitbucket Cloud. We'll use ngrok to forward all HTTPS requests to our locally installed mirror instance. ngrok is available for free for all major operating systems.

Once you've installed ngrok on your local machine simply run the following command in your terminal:

1 ./ngrok http 7990

This command will start ngrok and tunnel HTTPS requests on port 7990 (which is the standard port used by Smart Mirrors) to our localhost. You should see a line similar to this:

1 Forwarding https://d269543a.ngrok.io -> localhost:7990

We'll soon use the funky https://xxxxxx.ngrok.io URL to set up our Bitbucket Smart Mirror, so make sure you copy that URL and keep ngrok running during your entire evaluation.

Temporary ngrok https URL

Whenever you stop and re-start ngrok it will generate a new random HTTPS URL. During the mirroring setup process you'll have to provide a static Mirror Base URL, so make sure you don't stop ngrok while you're evaluating mirroring.

Set up and start your Smart Mirror

Now that you've successfully installed your mirror locally and started running ngrok you're ready to set up your mirror.

First, you have to open your bitbucket.properties file which is located in your $BITBUCKET_HOME directory under /shared/. In our case, it's here:

1 /Users/sszasztoth/Atlassian/ApplicationData/Bitbucket/shared/bitbucket.properties

Add the following lines to the file and replace xxxxxx.ngrok.io with your ngrok hostname (for example, d269543a.ngrok.io):

1 2 3 4 5 server.port=7990 server.proxy-name=xxxxxx.ngrok.io server.secure=true server.scheme=https server.proxy-port=443

Next, start your Mirror by running start-bitbucket.sh from your DEST_DIRECTORY, in our case:

1 /Users/sszasztoth/Atlassian/Bitbucket/bin/start-bitbucket.sh

Remember the funky ngrok address (it has the pattern https://xxxxxx.ngrok.io)? Now that your mirror has been started you need to visit that in your browser to start the set up process. 

You should now be able to see that your mirror is starting up. As soon as the mirror is ready you can choose a name for your mirror (this is the name that you and your teammates will see in Bitbucket Cloud later) and select Bitbucket Cloud as the primary server location.

Next, select the account you want to connect your mirror to and mirror from and grant access.

Finally, just select the individual projects you'd like to mirror, or mirror all the projects in your account.

Use your mirror to clone, fetch and pull

As soon as the mirror is done syncing all your projects and the repositories included in those projects, you can head to any mirrored repository and start cloning from your own mirror! Click Clone in the sidebar and select the mirror from the clone dialog.

Alternatively, you can get the clone URL from the top of the repo overview page. To learn how to use a mirror in your day-to-day work, see Work with Bitbucket Smart Mirroring.

Start ngrok with a different region to evaluate speed improvements

The cool thing about ngrok is that you can tell it to use a specific region that is closer to you to evaluate how much faster a "local" mirror will be. If you are, for example, located in Germany you can use ngrok's European region by starting ngrok with the following command:

1 ./ngrok -region eu 7990

To see all regions that ngrok supports check our their docs.

Last modified on Dec 3, 2020
Cached at 3:47 PM on Apr 14, 2021 |

Additional Help

Ask the Community