4
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

GitLabで複数ポートからのアクセスをListenする

Last updated at Posted at 2021-03-17

はじめに

GitLabで、独自URL設定は/etc/gitlab/gilab.rbexternal_urlで行えます。
また、通常のhttpのListenポートは80ですが、変更したい場合は以下のように記載することで可能です。

gitlab.rb
external_url 'http://gitlab.example.com:8080'

それでは、もし現在のポートに加えて別のポートからもListenできるようにしたい場合はどうしたら良いでしょう?
今回はその設定を試してみたいと思います。

設定

GitLab をパッケージインストールした場合、web は nginx で動きます。
ただ、インストール先は一般的な/etc/nginxではなく、/var/opt/gitlab/nginx/conf/gitlab-http.confになります。

修正
$ vim /var/opt/gitlab/nginx/conf/gitlab-http.conf

もし、現在がデフォルトの80ポートでアクセス可能な状態でしたら、その下などに8080ポートを追加してください。

gitlab-httpd.conf
server {
  listen 80;
  listen 8080; ← 追加

設定したら nginx の再起動を行います。
とは言っても、通常の systemctl での再起動ではなく gitlab-ctl で行います。

restart
$ sudo gitlab-ctl restart nginx
ok: run: nginx: (pid 22060) 1s

以上で完了です。
これで80ポートに加えて8080ポートでもアクセスできるようになります。

注意

GitLabの設定関連は gitlab.rb で管理します。
設定した値を反映するには gitlab-ctl reconfigure で再構築が必要ですが、これをしてしまうとポートの設定が戻ってしまうので注意が必要です。
その場合は再構築後に改めて今回の対応を行う必要があります。

おわりに

わざわざ複数ポートでアクセスできるようにする機会はほぼないと思います。
ただ、こういったことを試すのは、そのシステムが「どうやって動いているか?」という仕組みを知るのにとても良いなと思います。

4
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?