【问题标题】:Check GitLab API access: FAILED. code: 302检查 GitLab API 访问:失败。代码:302
【发布时间】:2015-10-21 02:41:53
【问题描述】:

我在 Centos 6.5 上安装了 GitLab,但收到以下错误:

Running /home/git/gitlab-shell/bin/check
Check GitLab API access: FAILED. code: 302
gitlab-shell self-check failed
  Try fixing it:
  Make sure GitLab is running;
  Check the gitlab-shell configuration file:
  sudo -u git -H editor /home/git/gitlab-shell/config.yml
  Please fix the error above and rerun the checks.

Checking GitLab Shell ... Finished

我在下面包含了完整的检查输出以及我的/home/git/gitlab-shell/config.yml 文件。此外,GitLab 实际上正在运行:

[root@vps gitlab]# service gitlab status
unicorn (pid  30184) is running...
sidekiq (pid  30340) is running...
[root@vps gitlab]#

我已经测试连接到服务器,并且可以使用ssh -T git@example.com 进行验证。我不确定它是否相关,但我无法推送存储库,并收到以下错误。

[Michael@devserver example]$ ssh -T git@example.com
Address 123.456.789.01 maps to ve6.phpwebhosting.com, but this does not map back to the address - POSSIBLE BREAK-IN ATTEMPT!
Welcome to GitLab, Anonymous!
[Michael@devserver example]$ git remote -v
origin  git@example.com:root/example.git (fetch)
origin  git@example.com:root/example.git (push)
[Michael@devserver example]$ git push -u origin master
Address 123.456.789.01 maps to ve6.phpwebhosting.com, but this does not map back to the address - POSSIBLE BREAK-IN ATTEMPT!
Access denied.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
[Michael@devserver example]$

如何解决上述错误?是不是跟无法推送到仓库有关?

谢谢

[root@vps gitlab]# sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production
Checking Environment ...

Git configured for git user? ... yes

Checking Environment ... Finished

Checking GitLab Shell ...

GitLab Shell version >= 1.9.3 ? ... OK (1.9.3)
Repo base directory exists? ... yes
Repo base directory is a symlink? ... no
Repo base owned by git:git? ... yes
Repo base access is drwxrws---? ... yes
Satellites access is drwxr-x---? ... yes
update hook up-to-date? ... yes
update hooks in repos are links: ...
Michael Smith / example ... repository is empty
Running /home/git/gitlab-shell/bin/check
Check GitLab API access: FAILED. code: 302
gitlab-shell self-check failed
  Try fixing it:
  Make sure GitLab is running;
  Check the gitlab-shell configuration file:
  sudo -u git -H editor /home/git/gitlab-shell/config.yml
  Please fix the error above and rerun the checks.

Checking GitLab Shell ... Finished

Checking Sidekiq ...

Running? ... yes
Number of Sidekiq processes ... 1

Checking Sidekiq ... Finished

Checking LDAP ...

LDAP is disabled in config/gitlab.yml

Checking LDAP ... Finished

Checking GitLab ...

Database config exists? ... yes
Database is SQLite ... no
All migrations up? ... yes
Database contains orphaned UsersGroups? ... no
GitLab config exists? ... yes
GitLab config outdated? ... no
Log directory writable? ... yes
Tmp directory writable? ... yes
Init script exists? ... yes
Init script up-to-date? ... no
  Try fixing it:
  Redownload the init script
  For more information see:
  doc/install/installation.md in section "Install Init Script"
  Please fix the error above and rerun the checks.
projects have namespace: ...
Michael Smith / example ... yes
Projects have satellites? ...
Michael Smith / example ... can't create, repository is empty
Redis version >= 2.0.0? ... yes
Your git bin path is "/usr/bin/git"
Git version >= 1.7.10 ? ... yes (1.8.3)

Checking GitLab ... Finished

config.yml:

[root@vps gitlab]# cat /home/git/gitlab-shell/config.yml
# GitLab user. git by default
user: git

# Url to gitlab instance. Used for api calls. Should end with a slash.
gitlab_url: "http://example.com/"

http_settings:
#  user: someone
#  password: somepass
#  ca_file: /etc/ssl/cert.pem
#  ca_path: /etc/pki/tls/certs
  self_signed_cert: true

# Repositories path
# Give the canonicalized absolute pathname,
# REPOS_PATH MUST NOT CONTAIN ANY SYMLINK!!!
# Check twice that none of the components is a symlink, including "/home".
repos_path: "/home/git/repositories"

# File used as authorized_keys for gitlab user
auth_file: "/home/git/.ssh/authorized_keys"

# Redis settings used for pushing commit notices to gitlab
redis:
  bin: /usr/bin/redis-cli
  host: 127.0.0.1
  port: 6379
  # socket: /tmp/redis.socket # Only define this if you want to use sockets
  namespace: resque:gitlab

# Log file.
# Default is gitlab-shell.log in the root directory.
# log_file: "/home/git/gitlab-shell/gitlab-shell.log"

# Log level. INFO by default
log_level: INFO

# Audit usernames.
# Set to true to see real usernames in the logs instead of key ids, which is easier to follow, but
# incurs an extra API call on every gitlab-shell command.
audit_usernames: false
[root@vps gitlab]#

【问题讨论】:

    标签: ruby git centos rake gitlab


    【解决方案1】:

    如何解决上述错误?是不是跟不能推送有关 到存储库?

    /home/git/gitlab-shell/config.yml,更改

    gitlab_url: "http://mydomain.com/"
    

    gitlab_url: "https://mydomain.com"
    

    而且,是的,这与无法推送有关。

    据我所知,它现在完美无缺。

    【讨论】:

      【解决方案2】:

      我遇到了同样的错误,看了之后,我发现 gitlab-shell 正在通过 http 进行 API 调用。就我而言,我的 gitlab 主机无法解析自己的 dns 名称。

      所以我找到了两种方法来解决这个问题:

      • 将 gitlab-shell/config.yml 中的 gitlab_url 更改为 http://localhost:8080/
      • 或将 gitlab_url 添加到 /etc/hosts "127.0.0.1 {gitlab_url}"

      您可以立即检查它是否可以执行以下命令:

      ssh -T git@{your_gitlab_server}
      

      如果有效,您应该看到:

      “欢迎来到 GitLab,{gitlab_username}!”

      如果还是不行:

      “欢迎来到 GitLab,匿名者!”

      希望这会有所帮助!

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2019-06-13
        • 1970-01-01
        • 1970-01-01
        • 2014-11-19
        • 1970-01-01
        • 2020-08-04
        • 2018-11-27
        • 2019-11-06
        相关资源
        最近更新 更多