How to Redirect Bitbucket Server Traffic to Port 80 on Linux

Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.

Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

Summary

As described on the document below:

You can bind Bitbucket Server to a port over 1024 and then configure iptables to redirect traffic from port 80 to the higher port as an alternative to changing the port where Bitbucket Server listens to.

Solution

  • If you've got Bitbucket Server running on port 7990 successfully, you can add a rule to your Iptables so requests to

    1 iptables -t nat -A PREROUTING -i <your network interface> -p tcp --dport 80 -j REDIRECT --to-port 7990
  • If you are running Bitbucket Server on your own workstation, and connecting to Bitbucket as http://localhost:7990, you might need to add another rule to your Iptables as PREROUTING is not used by the loopback interface, it is done by the OUTPUT rule

    1 iptables -t nat -A OUTPUT -i <your network interface> -p tcp -o lo --dport 80 -j REDIRECT --to-port 7990

Please refer to the iptables man page for more details on how to use it.

Notice that there might be network impacts while handling the iptables. This is only a guideline on how you can approach this. Before changing your iptables, make sure you're comfortable with changing these rules. Use this guide at your own risk.

Updated on April 16, 2025

Still need help?

The Atlassian Community is here for you.