【发布时间】:2014-08-01 23:02:27
【问题描述】:
我正在尝试在安装了 git 的 CentOS 6 机器上通过我的 Apache 2.2 建立一个 git 存储库。我尝试了许多不同的方向,但我不知所措。我目前的情况包括可以正常clone,但完全无法推送。
似乎我无法让身份验证位正常工作,因为我可以在将http.receivepack 设置为true 时正常执行推送。
我已经安装了AuthzUnixGroup 和mod_authz_external。
我去了/var/www/git并创建了一个名为my-repo.git的repo,并在其中做了一个git init --bare。
然后我在/etc/httpd/conf.d/ 中设置我的git.conf 文件如下:
<VirtualHost "*:80">
SetEnv GIT_HTTP_EXPORT_ALL
SetEnv GIT_PROJECT_ROOT /var/www/git
SetEnv REMOTE_USER=$REDIRECT_REMOTE_USER
ScriptAlias /git /usr/libexec/git-core/git-http-backend
AddExternalAuth pwauth /usr/local/libexec/pwauth
SetExternalAuthMethod pwauth pipe
<Directory "/usr/libexec/git-core/">
AllowOverride None
Options +ExecCGI -Includes
Order allow,deny
Allow from all
</Directory>
<Location "/git">
AuthzUnixGroup on
AuthType Basic
AuthName "Git repository"
AuthBasicProvider external
AuthExternal pwauth
Require group git
</Location>
</VirtualHost>
将我的网络浏览器指向mysite/git 很好地向我显示了 HTTP 基本登录对话框,它运行良好。我已将自己添加到组 git,并在我的 shell 返回上执行 groups:
naseri sudo git
符合预期。
当我执行git clone http://mysite/git/my-repo.git 时,我从/var/logs/httpd/access_log 下的httpd 的access_log 文件中得到以下信息:
2.177.130.21 - - [11/Jun/2014:18:51:07 +0000] "GET /git/my-repo.git/info/refs?service=git-upload-pack HTTP/1.1" 401 480 "-" "git/1.8.5.2 (Apple Git-48)"
2.177.130.21 - - [11/Jun/2014:18:51:08 +0000] "GET /git/my-repo.git/info/refs?service=git-upload-pack HTTP/1.1" 401 480 "-" "git/1.8.5.2 (Apple Git-48)"
2.177.130.21 - naseri [11/Jun/2014:18:51:08 +0000] "GET /git/my-repo.git/info/refs?service=git-upload-pack HTTP/1.1" 200 256 "-" "git/1.8.5.2 (Apple Git-48)"
2.177.130.21 - naseri [11/Jun/2014:18:51:09 +0000] "POST /git/my-repo.git/git-upload-pack HTTP/1.1" 200 368 "-" "git/1.8.5.2 (Apple Git-48)"
在客户端,cloneing 工作正常。我改变了一些东西,然后尝试通过git pushing 内容在提交后推送。
这是我在服务器端日志中得到的:
2.177.130.21 - - [11/Jun/2014:18:53:26 +0000] "GET /git/my-repo.git/info/refs?service=git-receive-pack HTTP/1.1" 401 480 "-" "git/1.8.5.2 (Apple Git-48)"
2.177.130.21 - naseri [11/Jun/2014:18:53:27 +0000] "GET /git/my-repo.git/info/refs?service=git-receive-pack HTTP/1.1" 401 480 "-" "git/1.8.5.2 (Apple Git-48)"
2.177.130.21 - naseri [11/Jun/2014:18:53:30 +0000] "GET /git/my-repo.git/info/refs?service=git-receive-pack HTTP/1.1" 403 - "-" "git/1.8.5.2 (Apple Git-48)"
我可以看到我的“需要身份验证”响应正在由 Apache 在响应的第一行 (401) 发回,但客户端向我显示:
fatal: unable to access 'http://mysite/git/my-repo.git/': The requested URL returned error: 403
我对这个问题一无所知,因为将我的浏览器指向相同的 URL 会正确地启动身份验证,并且它甚至可以正常工作。
【问题讨论】: