How to Redirect Bitbucket Server Traffic to Port 80 on Linux
目的
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.
ソリューション
If you've got Bitbucket Server running on port 7990 successfully, you can add a rule to your Iptables so requests to
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
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.