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.
- To set up Smart Mirroring for Bitbucket Cloud, using a valid SSL certificate, see Set up Bitbucket Smart Mirroring.
- If you want to mirror a Bitbucket Server instance, see Smart Mirroring instead.
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
- Download the latest version of the Bitbucket installer from www.atlassian.com/software/bitbucket/download.
- Run the installer, making sure to select Install a new instance and then Install a mirror instance.
Stick to the default values for the rest of the installation process
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:
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:
./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:
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:
Add the following lines to the file and replace
xxxxxx.ngrok.io with your ngrok hostname (for example,
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:
Remember the funky ngrok address (it has the pattern
)? 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 team mates will see in Bitbucket Cloud later) and select Bitbucket Cloud as the primary server location:
Next, pick 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 repos included in those projects, you can head to any mirrored repo and start cloning form your own mirror! Just 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:
./ngrok -region eu 7990
To see all regions that ngrok supports check our their docs.