【问题标题】:git-http-backend/nginx - error 22 on pushgit-http-backend/nginx - 推送时出现错误 22
【发布时间】:2017-10-16 14:09:49
【问题描述】:

我有一个在线服务器 (Ubuntu 17.04) 来托管我的裸存储库。我尝试在此服务器上设置 HTTPS,可以拉取但无法推送,失败并出现以下错误:

错误:无法访问 URL https://user:passwd@myserver.com/REPO/, 返回代码 22 致命:git-http-push 失败错误:未能推送一些 参考'https://user:passwd@myserver/REPO/'

nginx 配置相关部分如下所示:

# static repo files for cloning over https
location ~ ^.*\.git/objects/([0-9a-f]+/[0-9a-f]+|pack/pack-[0-9a-f]+.(pack|idx))$ {
    client_max_body_size 0;
    auth_basic  "Restricted Area";
    auth_basic_user_file /etc/apache2/.htpasswd;
    fastcgi_param REMOTE_USER $remote_user;
    root /home/git/;
}

# requests that need to go to git-http-backend
location ~ ^.*\.git/(HEAD|info/refs|objects/info/.*|git-(upload|receive)-pack)$ {
    client_max_body_size 0;
    auth_basic  "Restricted Area";
    auth_basic_user_file /etc/apache2/.htpasswd;
    root /home/git/;

    #fastcgi_pass unix:/var/run/fcgiwrap.socket;
    fastcgi_param SCRIPT_FILENAME   /usr/lib/git-core/git-http-backend;
    fastcgi_param PATH_INFO         $uri;
    fastcgi_param GIT_PROJECT_ROOT  /home/git/;
    fastcgi_param GIT_HTTP_EXPORT_ALL "";
    fastcgi_param REQUEST_METHOD $request_method;
    fastcgi_param REMOTE_USER $remote_user;
    include fastcgi_params;
}

在我阅读的所有线程中,问题来自远程 URL 中缺少用户/密码的 REMOTE_USER fastcgi 参数或本地 git 配置,但我设置了它,所以我一无所知。有没有人有想法或发现问题?

编辑:这是我的 .git/config:

[core]
    repositoryformatversion = 0
    filemode = false
    bare = false
    logallrefupdates = true
    symlinks = false
    ignorecase = true
[remote "origin"]
    url = https://user:passwd@myserver.com/REPO/
    fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
    remote = origin
    merge = refs/heads/master
[user]
    name = git

【问题讨论】:

    标签: git nginx git-http-backend


    【解决方案1】:

    根据documentation,在不复制您的设置的情况下,您确定receivepack 已正确启用吗?

    如果您尝试更新您的本地 .git/config 网址,如 this post 中的那样(查看评论)

    【讨论】:

    • 我已经更新了我的 .git/config(查看错误,用户名在 URL 中)默认情况下,receivepack 对经过身份验证的用户启用,对匿名用户禁用,这正是我想要的
    • 好的,nginx fastcgi_params 怎么样,它是否有可能覆盖之前定义的参数?我不确定git push -v 在使用 HTTP 而不是 SSH 时是否提供有用的信息,但可以尝试一下。我会试试看能否重现你的设置。
    • 为了以防万一,你能更新你的问题并添加你的回购.git/config吗?
    • 我编辑添加了我的 .git/config。另外 fastcgi_params 没有被覆盖,我复制的两个之后的唯一块是“location ~ \.php$”
    • 谢谢!我已经复制了您的设置,并且我不得不承认我有同样的问题,无论如何......当增加错误日志级别 nginx 时,我在 PROPFIND 方法上收到 405 错误,这意味着请求可能没有传给git-http-backend...还在调查中...
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-09-30
    • 1970-01-01
    • 2023-03-16
    • 2012-06-12
    • 1970-01-01
    • 1970-01-01
    • 2016-12-30
    相关资源
    最近更新 更多