How to Turn Your Bitbucket Instance into a Web Hosting Machine

Mohammed Davoodi
Mohami Blog
Published in
7 min readMay 20, 2020

One cool side-effect of using Bitbucket in the cloud is its web hosting capability. It’s convenient not only because of the easy setup but because of the built-in source control on hand to help manage changes to HTML pages.

It can make a lot of sense to let Bitbucket cloud host simple web pages — whether it’s just to improve information access directly for the team, or to use as a platform for completely separate projects. So much so that users of the server version might be tempted to migrate to the cloud, just to add that capability.

But do server users really need to jump to the cloud to leverage the web hosting functionality in Bitbucket? Is the tradeoff giving up that peace of mind and security of keeping your source code out of the cloud?

Well, yes.

And no.

Before you jump into the cloud, you should know that there’s another alternative that lets you retain the tight control you get with your on-premises version, while getting all the web hosting functionality of cloud version — and then some.

Plugins to the Rescue

No matter what, if you’re hosting public web pages, then sure, they’re in ‘the cloud’.

But the good news is you don’t need to use the cloud version of Bitbucket to do it. As usual, it’s plugins to the rescue.

The Pages for Bitbucket Server plugin (PBS) is a powerful add-on that allows you to host those pages on your Bitbucket Server instance. It’s a simple, turnkey solution that lets you publish web pages in multiple repositories. It offers all the web hosting functionality that’s available from the cloud version, while adding additional functionality and flexibility that isn’t.

End-users who just want to maintain and host pages in Bitbucket Server, just for sharing mission-critical data in-house, don’t have to risk exposing sensitive data to the cloud just for that privilege.

The PBS plugin is a win-win solution hiding in plain sight on the Atlassian Marketplace.

Features and Functionality

The Pages for Bitbucket Server plugin brings additional functionality you can’t get in the Bitbucket cloud version. Host a site on a repository level, on an account level, and even better, you can use a custom domain.

The plugin allows repository administrators to enable serving of static web pages for any existing branch or tag. Once enabled, users will be able to view HTML files of this branch or tag, directly in Bitbucket. You can also link to other HTML files or resources like CSS, JavaScript or images by using relative links.

Feature Highlights

  • HTML hosting: Host simple websites as static HTML directly in Bitbucket Server.
  • Supports embedded images, Javascript, and CSS: Static doesn’t mean it has to be plain. Full support for these technologies with a security option to disable Javascript
  • Version control is built right in: Automatic version control by Git — Edit, push, and your changes are live.
  • Flexible hosting partitions: Enable serving web pages per branch or tag.
  • Uses existing Bitbucket permissions: Access control based on repository permissions.
  • Use relative links: Supports relative links and files stored in Git LFS.

Comparison — PBS vs. Bitbucket Cloud

Since users of Bitbucket Cloud get web hosting capability more or less out of the box, you’d be right to wonder if there’s an apples-to-apples comparison between that and PBS. And to be clear, even with that native functionality in the cloud, there are some noteworthy differences.

Perhaps the most striking difference between cloud and what the Pages for Bitbucket Server plugin can do is a subtle point of flexibility — Bitbucket Cloud supports websites on the account level, but the PBS plugin lets you host unique sites on a repository level, and on multiple branches, with full control over user access on each.

Pages for Bitbucket Server brings other advantages too. Here’s a like for like comparison:

Websites on Bitbucket Cloud…

  • One Repository per User: On Bitbucket Cloud you can only publish one repository per user.
  • Publishing limited to one branch: On Bitbucket Cloud you can only publish a single branch of the repository.
  • Anyone has access: On Bitbucket Cloud the website is public on the internet. Anyone with the URL can access it.
  • Limited to Bitbucket domain: Bitbucket Cloud can only serve a website when the site’s URL is <username>.bitbucket.org.

…vs Pages for Bitbucket Server plugin…

  • Unlimited Repositories: With the Pages add-on you can publish as many repositories as you want.
  • Unlimited branches: With the Pages add-on you can serve static web pages from any branch or tag you like.
  • Access control: The Pages add-on uses the permissions of the underlying repository, which allows you to control specifically who can access the pages and who cannot.
  • Use your own branded domain: The Pages add-on allows you to use your own custom domain.

What About Security?

Access to web pages is simply based on existing repository permissions. Users need at least READ access to the repository to view web pages in Bitbucket. For security reasons, pages are not available for branches or tags in personal repositories by default. But in the plugin settings, you can configure which groups are allowed to enable pages in personal repositories.

Note: Only enable pages in repositories and branches or tags where you trust the users who can commit code!

Preventing XSS Attacks

Pages for Bitbucket supports client-side scripting. But for users who are worried about cross-site scripting attacks, Mohami added an option to disable JavaScript on rendered pages — either globally or uniquely for selected repositories.

Working with the Plugin

It may be useful to connect some of those feature-level descriptions with the detailed mechanics of configuration.

Repository administrators can enable serving of static web pages for any existing branch or tag in the repository settings screen. Once enabled, the base URL for pages in this branch or tag is being displayed next to the branch or tag name.

Enable pages for branches or tags

URLs and Links

Web pages are available under a URL in this format: /pages/<PROJECT>/<REPOSITORY>/<BRANCH-OR-TAG>

If there is no index.html file available in the root level of a branch or tag, that’s okay, you can link to the page directly by appending the file path to the URL.

For Example: /pages/<PROJECT>/<REPOSITORY>/<BRANCH-OR-TAG>/browse/<PATH>/<TO>/<FILE>.html

Example of webpage in Pages for Bitbucket

Once pages have been enabled for a branch or a tag, users are able to view HTML files of this branch or tag directly in Bitbucket.

After clicking open in the file browser of a particular branch or tag, the page will be rendered full screen, without the Bitbucket layout.

It’s also possible to link to other HTML files or resources like CSS, JavaScript or images by using relative links. You can even link to files stored in Git LFS.

Link files stored in LFS

That root folder for a given site supports familiar subfolders with optional images, javascript, and CSS.

Enable pages for branches or tags

So, what’s the right option?

So, is it time to migrate to the cloud version? Maybe. But it may also be time to jump the other way. Knowing the details of our options will at least ensure a decision based on a comprehensive understanding of the trade-offs.

Either way, access to information is the foundation of any successful team, and just knowing you can enlist Bitbucket in that cause is the first step to making the right decision for your team.

Try it now for free with simple installation

As with almost any feature on your feature wish-list, the best place to find it is in the Atlassian Marketplace.

Pages for Bitbucket Server supports Server and Data Center deployments.

Hosting options

Want to try it for free? Your Confluence administrator can install the Pages plugin with a single mouse click and you can experience the benefits of active messaging yourself, and take your team to the next level of focus and cohesion.

  1. Login to your Confluence instance as an admin and choose Add-ons, or go to the Atlassian Marketplace.
  2. Locate Pages for Bitbucket Server and click Try it free.
Try it free button

3. You’re all set! Click Close in the Installed and ready to go dialog.

You’ll reap the benefits right away, and your entire team can experience the benefits for themselves.

Mohami extends the Atlassian ecosphere with a suite of sensible, productivity-boosting macros that plug key gaps in functionality, unlock integration between platforms, and streamline development. Find more Mohami products at the Atlassian Marketplace here.

--

--

Mohammed Davoodi
Mohami Blog

CEO @Soteriaio, Formerly Founder & CEO @Mohamicorp (Acquired by Appfire), Flight Software Engineer @SpaceX, Software Developer @Amazon, @virginia_tech Alumni