7
8

More than 5 years have passed since last update.

GitLab8.0以降でhttpでpushできない問題の解決策

Last updated at Posted at 2016-02-08

はじめに

CentOSにGitLab8.1をリバースプロキシを設定導入しました。このGitLabサーバにhttpを使ってpushしてみるとアクセスできないエラーが出るので解決策をメモります。

なぜエラーが出るか?

そもそもGitLab8.0以降からhttp・httpsからのpushの処理の方法が変わりました。具体的にはgitlab-git-http-serverにより処理するようになりました。
そのためpushするとき、http://gitlab.exampel.com/yorumiru/test.gitというようなURLを指定すると思うのですが、このURLへのアクセスをうまく処理できなくなっているみたいです。

対処方法

そこでhttp://gitlab.exampel.com/yorumiru/test.gitというようなアクセスがあったら、gitlab-git-http-serverは8181ポートがデフォルトなのでそこに飛ばしてあげればいいので次のようにnginxの設定ファイルに追加します。タイムアウトとかは適当に...

gitlab.conf
server {
    ###省略###

    location ~ [-\/\w\.]+\.git\/ {

      proxy_read_timeout    300;
      proxy_connect_timeout 300;
      proxy_redirect        off;
      proxy_buffering       off;

      proxy_set_header    Host                $http_host;
      proxy_set_header    X-Real-IP           $remote_addr;
      proxy_set_header    X-Forwarded-For     $proxy_add_x_forwarded_for;
      proxy_set_header    X-Forwarded-Proto   $scheme;

      proxy_pass http://localhost:8181;
    }

}

以下のようにGitLabの設定ファイルを編集して、gitlab-ctl reconfigureで適用して完了です。

gitlab.rb
##########################
# GitLab git http server #
##########################

gitlab_git_http_server['enable'] = true
gitlab_git_http_server['ha'] = false
gitlab_git_http_server['repo_root'] = "/var/opt/gitlab/git-data/repositories"
gitlab_git_http_server['listen_addr'] = "127.0.0.1:8181"

最後に

以下のIssueを参考にしました。
Cannot clone projects via HTTP
unix socketを使った方法もあるので参考に。

追記

GitLabのバージョンを8.1から8.2にアップデートした段階でgitlab-git-http-serverがgitlab-workhorseに変わったようです。
GitLab8.2.2で今回と同じエラーが出ました。そこで、本投稿の設定を行ったところ問題なくpushできました。gitlab-workhorseについてもう少し調べなくては...。
まだまだ未熟者です。ご指摘感謝します。

7
8
2

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
7
8