If you want to quickly evaluate Smart Mirroring in Bitbucket Cloud and don’t want to go through the hassle of getting a valid domain, SSL certificate etc., follow these simple steps below to set up a mirror with SocketXP. Get up and running in less than 15 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 SocketXP to forward HTTPS requests to your local mirror (mirrors only work with HTTPS for security reasons).
- Git clone from your local mirror instead of Bitbucket Cloud.
Note: A locally set up mirror on your own server will be faster than cloning from a Bitbucket cloud. The main purpose of this guide is to show how quickly you can spin up your own Bitbucket Cloud Smart Mirror and evaluate it using SocketXP. 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 tothe following:
BITBUCKET_HOME = /Users/gvelrajan/Atlassian/ApplicationData/Bitbucket DEST_DIRECTORY = /Users/gvelrajan/Atlassian/Bitbucket
Install and start SocketXP
Download and install SocketXP, which is a super easy tool to expose our localhost to the Internet and Bitbucket Cloud. We’ll use SocketXP to forward all HTTPS requests to our locally installed mirror instance. SocketXP is available for free for all major operating systems.
Once you’ve installed SocketXP on your local machine simply run the following command in your terminal:
socketxp -connect http://localhost:7990
This command will start SocketXP client process 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:
Service URL -> https://25a3d66c-47ab-41e1-aa56-a2942e33b94e.socketxp.com
We’ll soon use the funky
https://xxxxx.socketxp.com URL to set up our Bitbucket Smart Mirror, so make sure you copy that URL and keep SocketXP running during your entire evaluation.
Temporary SocketXP https URL
Whenever you stop and re-start SocketXP 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 SocketXP while you’re evaluating mirroring.
Set up and start your Smart Mirror
Now that you’ve successfully installed your mirror locally and started running SocketXP on your local machine, 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.socketxp.com with your SocketXP public URL (for example, https://25a3d66c-47ab-41e1-aa56-a2942e33b94e.socketxp.com):
server.port=7990 server.proxy-name=xxxxxx.socketxp.com 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 SocketXP address (it has the pattern
https://xxxxxx.socketxp.com)? This is the public URL to access your newly installed Bitbucket mirror instance. Now that your mirror has been started you need to visit that URL 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:
It is a good practice to replicate your Bitbucket git in different geographical locations as a risk mitigation strategy.
If you wish to keep your git mirrors private and local to your satellite office location, you could do so. Interconnect your Bitbucket cloud and your local mirror securely using SocketXP.
SocketXP is a light-weight VPN alternative that securely interconnects your application servers that don’t have public IP addresses and are located in different geographical locations.