Gitlab CI 令牌 - 403 与 apache

Gitlab CI token - 403 with apache

我在我的服务器上 运行 gitlab。我正在使用 apache2(使用 https)为网站提供服务。

最近我开始使用 gitlab CI,但是 运行 遇到了一个我自己无法解决的问题:我总是收到 403 错误:

remote: Access denied
fatal: unable to access 'https://gitlab-ci-token:xxxxxxxxxxxxxxxxxxxx@git.mydomain.com/group/project.git/': The requested URL returned error: 403

SSH 和 HTTP(S) 都启用了克隆并且 ci 与 public 项目一起工作得很好,检查所有 gitlab 日志显示运行者未通过身份验证因此触发 403。

我最好的猜测是 apache 配置没有将 ci-token 传递给 gitlab,但我不知道如何检查它,我也不认为这是真正的原因。

我的虚拟主机:

<VirtualHost *:80>
  ServerName git.mydomain.com
  ServerSignature Off

  RewriteEngine on
  RewriteCond %{HTTPS} !=on
  RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [NE,R,L]
</VirtualHost>

<VirtualHost *:443>
  SSLEngine on

  SSLProtocol all -SSLv2
  SSLHonorCipherOrder on
  SSLCipherSuite     "ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AESGCM:RSA+AES:RSA+3DES:!aNULL:!MD5:!DSS"
  Header add Strict-Transport-Security: "max-age=15768000;includeSubdomains"
  SSLCompression Off
  SSLCertificateFile /etc/letsencrypt/live/git.mydomain.com/fullchain.pem
  SSLCertificateKeyFile /etc/letsencrypt/live/git.mydomain.com/privkey.pem
  SSLCACertificateFile /etc/letsencrypt/live/git.mydomain.com/chain.pem

  ServerName git.mydomain.com
  ServerSignature Off

  ProxyPreserveHost On

  AllowEncodedSlashes NoDecode

  <Location />
    Require all granted
    ProxyPassReverse http://127.0.0.1:8181
    ProxyPassReverse http://git.mydomain.com/
  </Location>
  RewriteEngine on

  RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f [OR]
  RewriteCond %{REQUEST_URI} ^/uploads/.*
  RewriteRule .* http://127.0.0.1:8181%{REQUEST_URI} [P,QSA,NE]

  RequestHeader set X_FORWARDED_PROTO 'https'
  RequestHeader set X-Forwarded-Ssl on

  DocumentRoot /opt/gitlab/embedded/service/gitlab-rails/public

  ErrorDocument 404 /404.html
  ErrorDocument 422 /422.html
  ErrorDocument 500 /500.html
  ErrorDocument 502 /502.html
  ErrorDocument 503 /503.html

  LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b" common_forwarded
  ErrorLog /var/log/apache2/gitlab_error.log
  CustomLog /var/log/apache2/gitlab_forwarded.log common_forwarded
  CustomLog /var/log/apache2/gitlab_access.log combined env=!dontlog
  CustomLog /var/log/apache2/gitlab.log combined

</VirtualHost>

/etc/gitlab/gitlab.rb

的相关部分
external_url 'https://git.mydomain.com'

nginx['enable'] = false
web_server['external_users'] = ['www-data']
gitlab_workhorse['listen_network'] = "tcp"
gitlab_workhorse['listen_addr'] = "127.0.0.1:8181"

gitlab_rails['gitlab_email_reply_to'] = 'webmaster@mydomain.com'

Runner 配置:

[[runners]]
  name = "Runner Name"
  url = "https://git.mydomain.com/ci"
  token = "Some generated token"
  executor = "shell"
  [runners.cache]

/etc/default/gitlab:

gitlab_workhorse_options="-listenUmask 0 -listenNetwork tcp -listenAddr 127.0.0.1:8181 -authBackend http://127.0.0.1:8080"

.gitlab-ci.yml:

stages:
  - compile

compilei7:
    stage: compile
    script:
        - /./home/public/folder/someScript.sh -f `$PWD`
    tags:
    - neededtag

所有帮助都得到了帮助ci,我运行在这里靠墙。 谢谢。

自从我发布此问题以来发布的更新之一似乎已为我解决了这个问题,因为它现在可以使用完全相同的服务器和配置。

当 GitLab Runner 尝试从 Git 存储库克隆项目时会发生这种情况。

为了解决该问题,请将您自己添加为项目成员:

  1. 转到您在 Git实验室中的项目。
  2. 从左侧边栏的菜单中,select 设置/成员 条目。
  3. Select 要邀请的成员 输入字段中,输入您的姓名(或推送其代码的成员的姓名)。
  4. 选择一个角色权限, select Developer.
  5. 单击添加到项目按钮。