Why is Bitbucket Server listening on random ports?
プラットフォームについて: Server および Data Center のみ。この記事は、Server および Data Center プラットフォームのアトラシアン製品にのみ適用されます。
サーバー*製品のサポートは 2024 年 2 月 15 日に終了しました。サーバー製品を利用している場合は、アトラシアンのサーバー製品のサポート終了のお知らせページにて移行オプションをご確認ください。
*Fisheye および Crucible は除く
プラットフォームについて: Server および Data Center のみ。この記事は、Server および Data Center プラットフォームのアトラシアン製品にのみ適用されます。
サーバー*製品のサポートは 2024 年 2 月 15 日に終了しました。サーバー製品を利用している場合は、アトラシアンのサーバー製品のサポート終了のお知らせページにて移行オプションをご確認ください。
*Fisheye および Crucible は除く
質問
You are noticing that Bitbucket is choosing two random ports to listen to on start-up, and are looking to gain information on what these ports are being used for, and if they can be configured to be set to a static value.
回答
By default Bitbucket Server and Bitbucket Data Center opens two random ports for the following Git operations:
- Git transcoding, which helps deal with non-UTF-8 data in Git repositories
- Git hook callbacks into Bitbucket Server/Bitbucket Data Center
For this reason, these ports cannot be disabled. However, you can change the behavior from just choosing a random port to instead having them listen on a consistent port of your choosing.
This can be done by adding the following configuration values into your $BITBUCKET_HOME/shared/bitbucket.properties file, and making sure to replace 0 with the ports of your choice:
hook.callback.socket.port=0
plugin.bitbucket-git.transcode.socket.port=0
(For Stash, the transcode property is plugin.stash-scm-git.transcode.socket.port=0. If this is configured, it will automatically be rewritten for Bitbucket Server upon upgrading to any 4.x version.)
If the configured value is negative or zero (the default), a random port is used. Otherwise, the specific port is used.
Once this configuration has been made, the ports for these two services should listen on the ports you specify the next time that Bitbucket is restarted.
The ports chosen should generally be 1024 or higher, since low range ports typically require root access and Bitbucket Server/Stash should not be run as root.