带有 nginx 代理的 Gitlab 8 无法下载 zip,以访客身份克隆 public 存储库,也无法在 CI 中构建

Gitlab 8 with nginx proxy can't download a zip, clone a public repo as guest, can't build in CI either

我认为所有 3 个问题都与同一个问题有关,所以我将把它们全部放在这里。

Gitlab 本身正在运行,我什至设法将它从 8.2.2 更新到 8.2.3。 我可以创建项目,推送我的代码,拉取它,当我有合适的 ssh 密钥时重新克隆它,等等。

但是:

  1. 我无法将代码下载为 zip 文件,而是 JSON:

{"RepoPath":"/var/opt/gitlab/git-data/repositories/me/myrepo.git", "ArchivePrefix": "...

  1. 人们无法克隆我的 public 存储库(空存储库错误)。

  2. CI 无法构建我的测试:

warning: You have cloned an empty repository. Checking out 12345 as develop... fatal: reference is not a tree : 123456789mycommithash987654321

ERROR: Build failed with: exit status 1

注意:我翻译了法语错误信息。

我想问题出在我的 Nginx 配置上,但是有太多的文档我不确定哪个是好的:主力的那些,我必须更改的那些 gitlab.rb的gitlab_git_http_server等

我的配置如下:

我的 gitlab 使用 SLL 托管在一个子域上,所以我添加了一个 Nginx 代理

/etc/gitlab/gitlab.rb:

external_url 'https://gitlab.mydomain.com'
nginx['listen_addresses'] = ['127.0.0.1', "[::1]"]
nginx['listen_port'] = 8080 
nginx['listen_https'] = false 

/etc/nginx/site_enabled/gitlab:

server {
  listen *:80 default_server;
  listen [::]:80 ipv6only=on default_server;
  server_name gitlab.mydomain.com;
  return 301 https://$server_name$request_uri;

  access_log  /var/log/nginx/gitlab_access.log;
  error_log   /var/log/nginx/gitlab_error.log;
}

server{
  # listen 443 ssl;
  listen 0.0.0.0:443 ssl default_server;
  listen [::]:443 ipv6only=on ssl default_server; 
  server_name gitlab.mydomain.com;
  server_tokens off;

  location /{
    proxy_pass http://localhost:8080;
    proxy_redirect 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;
  }

  location ~ ^/(assets)/ {
    root /opt/gitlab/embedded/service/gitlab-rails/public;
    gzip_static on; # to serve pre-gzipped version
    expires max;
    add_header Cache-Control public;
  }

  client_max_body_size 250m;

  # ...
  # A lot a of SSL stuff (HSTS, OCSP, dhparam, etc)
  # ...

  access_log  /var/log/nginx/gitlab_access.log;
  error_log   /var/log/nginx/gitlab_error.log;
  
  error_page 502 /502.html;

更新:

刚刚将 Gilab 升级到 8.3.0。

Git现在502了。

正在申请:https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/update/8.2-to-8.3.md.

我们拭目以待。

更新 2:

毕竟没有完成指令,停止一切并重新启动一切两次(Gitlab 和 Nginx)终于成功了。

CI/Zip/PublicCloning 仍然存在同样的问题。

更新 3:

刚更新到8.2.3 apt-get update apt-get install gitlab-ce

502.

重启nginx gitlab-ctl 重启

gitlab-rake gitlab:app:check

Checking GitLab ...

Git configured with autocrlf=input? ... yes
Database config exists? ... yes
Database is SQLite ... no
All migrations up? ... yes
Database contains orphaned GroupMembers? ... no
GitLab config exists? ... yes
GitLab config outdated? ... no
Log directory writable? ... yes
Tmp directory writable? ... yes
Uploads directory setup correctly? ... yes
Init script exists? ... skipped (omnibus-gitlab has no init script)
Init script up-to-date? ... skipped (omnibus-gitlab has no init script)
projects have namespace: ... 

Redis version >= 2.8.0? ... yes
Ruby version >= 2.1.0 ? ... yes (2.1.7)
Your git bin path is "/opt/gitlab/embedded/bin/git"
Git version >= 1.7.10 ? ... yes (2.6.1)
Active users: 2

Checking GitLab ... Finished

如果有人可以引导我找到正确的文档或进行更改,那就太棒了。

看看https://gist.github.com/sameersbn/becd1c976c3dc4866ef8好像有个选项'gzip'可以关掉

gzip                    off;

第 53 行。

看起来 ZIP-Files 的下载现在由 gitlab-workhorse 处理。

为此,nginx-configfile 中有一些额外的内容。您可能想看看 https://gitlab.com/gitlab-org/gitlab-ce/blob/master/lib/support/nginx/gitlab 那里有一个部分

upstream gitlab-workhorse {
  server unix:/home/git/gitlab/tmp/sockets/gitlab-workhorse.socket fail_timeout=0;
}

还有一个

proxy_pass http://gitlab-workhorse;

配置结束。

我目前正在研究同一个问题,并会在解决后报告。

更新文档缺少一项:它在 nginx 配置中将 gitlab-git-http-server 重命名为 gitlab-workhorse,但部分缺少 /etc/default/gitlab。也将所有出现的 gitlab-git-http-server 替换为 gitlab-workhorse,尤其是 gitlab_workhorse_options.

中的套接字

类似

sed -i -e 's/gitlab-git-http-server/gitlab-workhorse/g' /etc/default/gitlab

开头但不是全部:

我错误地让Gitlab的nginx监听了8080端口。当已经是Gitlab的Unicorn使用的端口时。

将其更改为 8081 使 CI 响应更好。仍然必须解决 git 用户权限(或者更好,使用 docker)但这不是这里重要的直接问题...

更新:完整的解决方案 - ACL

安装过程中创建的 git 和 gitlab-runner 用户似乎拥有足够的权限。

首先:为每个人创造一个真正的家:/home/gitlab-runner,/home/git 使用适当的 ssh authorized_keys 和 rbenv + ruby 安装。

Then: vim /etc/passwd 并更改新家的主目录,在那里他们拥有全部权限。 现在我的构建是绿色的!