我正在使用Apache和git-http-backend.exe在WS 2008机器上设置一个Git服务器(1.7.2.3)。我一直在跟踪一个很好的这里。我有GUI工作,我可以恼人地克隆,如果我把下面的内容放在回购的配置中,我可能会恼怒地推动:
[http]
receivepack = true
我在httpd.conf文件中添加了以下内容:
SetEnv GIT_PROJECT_ROOT C:/GIT/Repositories
SetEnv GIT_HTTP_EXPORT_ALL
ScriptAliasMatch \
"(?x)^/(.*/(HEAD | \
info/refs | \
objects/(info/[^/]+ | \
[0-9a-f]{2}/[0-9a-f]{38} | \
pack/pack-[0-9a-f]{40}\.(pack|idx)) | \
git-(upload|receive)-pack))$" \
"C:/Program Files (x86)/git/libexec/git-core/git-http-backend.exe/$1"
<Directory />
Allow from all
</Directory>
<LocationMatch "^/git/.*/git-receive-pack$">
AuthType Basic
AuthName "Git Access"
AuthUserFile C:/GIT/ApacheConfig/users
AuthGroupFile C:/GIT/ApacheConfig/groups
Require group repogeneral
</LocationMatch>
当我添加"LocationMatch“时,我仍然可以恼人地克隆,或者通过在URL中指定名称,git克隆http://jon@myserver.com。
它将提示输入密码和克隆。
但是,当我试图向后推回购时,我得到了以下信息:
错误:无法访问URL http://jon@myserver.com/newtestrepo.git/,返回代码22致命:git-http-推失败
我一直在看http-backend.exe手册页的例子,但不能让他们工作。
下面是我的组文件(这只是测试示例,所以不需要在prod中使用):
admin: jon steve admin
webview: jon steve web
repogeneral: jon steve
testrepo: jon admin
testrepo2: jon steve web
以下是用户文件:
jon:$apr1$kEKVExYx$guIF9oYV8buGhFLZr16XN0
steve:$apr1$jvgjF9nv$PvWsHH.cSOBN5ymk6NT1B0
admin:$apr1$vzXgDskN$oszCei3tkHNUgtLj2HkHF/
web:$apr1$wS0do7hb$VA9tsc9c9LwY5PcjfhdwK0
我知道用户名jon的工作方式就好像我把目录要求放在gui部分一样,我可以用用户名jon登录,没有问题(与locationmatch相同的用户和组文件)。
我不知道我在这一点上遗漏了什么配置(假设这是一个配置问题)。
任何关于克服这最后一道障碍的建议都是很棒的。
编辑
我一直在玩更多的游戏,下面是我得到的信息:
如果我克隆一个回购:
git clone http://jon@myserver.com/remotetest.git
我可以将存储库取出,但当我尝试用以下方法进行回推时:
git推送原主
我被问到我的密码,我输入它,然后它再次请求它,然后我得到以下错误:
C:\temp\remotetest\remotetest>git推送源主密码:密码:错误:无法访问URL http://jon@myserver.com/remotetest.git/,返回代码22致命:git-http-推失败
在我的Apache access.log中,我得到了以下内容:
192.168.1.2 - - [29/Sep/2010:21:58:19 +0100] "GET /remotetest.git/info/refs?service=git-upload-pack HTTP/1.1" 200 38
192.168.1.2 - - [29/Sep/2010:21:58:51 +0100] "GET /remotetest.git/info/refs?service=git-receive-pack HTTP/1.1" 403 -
192.168.1.2 - - [29/Sep/2010:21:58:51 +0100] "GET /remotetest.git/info/refs HTTP/1.1" 200 -
192.168.1.2 - - [29/Sep/2010:21:58:51 +0100] "GET /remotetest.git/HEAD HTTP/1.1" 200 23
有趣的是,当我用URL中的用户名进行克隆时,不管我输入了什么密码,它还是会工作的。我想这是因为我应该能匿名的。不知道为什么它要求密码在这一点上。
我还在日志错误中看到了这一点:
[Wed Sep 29 22:33:00 2010] [error] [client 192.168.1.2] client denied by server configuration: C:/Program Files (x86)/Git/libexec/git-core/git-http-backend.exe
[Wed Sep 29 22:33:00 2010] [error] [client 192.168.1.2] client denied by server configuration: C:/Program Files (x86)/Git/libexec/git-core/git-http-backend.exe
编辑2
我尝试通过以下操作重新创建密码文件:
htpasswd -c -m C:/git/apacheconfig/users jon
但这没什么用。
编辑3
PHP在httpd.conf中使用相同的用户文件用于基本的auth:
<Directory "C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs">
AuthName "GitUsers"
AuthType Basic
AuthUserFile C:/GIT/ApacheConfig/users
AuthGroupFile C:/GIT/ApacheConfig/groups
require group webview
</Directory>
编辑4
好的,我可以愉快地克隆和推动恼人的模式,但是认证失败了。
C:\temp\test2\temp\test>git push origin master
Password:
Password:
error: Cannot access URL http://jon@192.168.10.97:8000/repositories/test.git/, return code 22
fatal: git-http-push failed
我将httpd.conf更改为使用以下内容:
<VirtualHost *:80>
SetEnv GIT_PROJECT_ROOT "C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs/repositories"
SetEnv GIT_HTTP_EXPORT_ALL
<Directory "C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs/repositories">
Options Indexes FollowSymLinks MultiViews Includes ExecCGI
AllowOverride None
Order allow,deny
Allow from all
</Directory>
<LocationMatch "^/repositories/.*/git-receive-pack$">
AuthType Basic
AuthName "Git Access"
AuthUserFile "C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs/repositories/.htpasswd"
Require valid-user
</LocationMatch>
ScriptAliasMatch \
"(?x)^/repositories/(.*/(HEAD | \
info/refs | \
objects/(info/[^/]+ | \
[0-9a-f]{2}/[0-9a-f]{38} | \
pack/pack-[0-9a-f]{40}\.(pack|idx)) | \
git-(upload|receive)-pack))$" \
"C:/Program Files (x86)/Git/libexec/git-core/git-http-backend/$1"
ErrorLog C:/GIT/error_log
CustomLog C:/GIT/access_log combined
</VirtualHost>
有趣的是,当我创建一个新的回购(git裸newrepo.git)时,它没有创建一个信息/参考文件。我必须执行"git update-server-info“命令来创建该命令。
Apache访问日志有一些有趣的线索:
192.168.10.97 - - [05/Oct/2010:22:48:26 +0100] "GET /repositories/test.git/info/refs?service=git-receive-pack HTTP/1.1" 200 -
192.168.10.97 - - [05/Oct/2010:22:48:26 +0100] "GET /repositories/test.git/HEAD HTTP/1.1" 200 23
192.168.10.97 - - [05/Oct/2010:22:48:28 +0100] "PROPFIND /repositories/test.git/ HTTP/1.1" 405 248
那是当我试图“推”回回购,但他们是得到的命令,而不是发布。不知道PROPFIND是什么,还没有找到更多的信息。我想,(四处阅读),可能会有某种重写,这是改变的帖子,并杀死它,或其他什么。不过,在这一点上,我已经力不从心了。
谢谢
发布于 2010-10-20 21:33:13
好吧,地狱已经冻结了,我终于开始工作了!
我相信我的设置有两件事是根本错误的。
1)用户没有通过身份验证,我发现这有助于:
SetEnv REMOTE_USER=$REDIRECT_REMOTE_USER
第二,我无法让物理的“目录”工作。
<Directory "C:/GIT/Apache/repositories">
Options +ExecCGI
AuthType Basic
AuthName intranet
AuthUserFile "C:/GIT/Apache/config/users"
Require valid-user
</Directory>
为了解决这个问题,我使用locationMatch进行拉和推。这意味着你必须认证来拉和推。如果你想惹恼拉,你可以删除“git-上传-包”部分。
希望这能帮到别人。
下面是我的最后一个httpd.conf文件:
DocumentRoot "C:/GIT/Apache/www"
<Directory />
Options +ExecCGI
Allow from all
</Directory>
<Directory "C:/GIT/Apache/www">
Allow from all
</Directory>
<Directory "C:/GIT/Apache/www/secure">
AuthType Basic
AuthName intranet
AuthUserFile "C:/GIT/Apache/config/users"
require valid-user
</Directory>
SetEnv GIT_PROJECT_ROOT C:/GIT/Apache/repositories
SetEnv GIT_HTTP_EXPORT_ALL
SetEnv REMOTE_USER=$REDIRECT_REMOTE_USER
ScriptAliasMatch \
"(?x)^/(.*/(HEAD | \
info/refs | \
objects/(info/[^/]+ | \
[0-9a-f]{2}/[0-9a-f]{38} | \
pack/pack-[0-9a-f]{40}\.(pack|idx)) | \
git-(upload|receive)-pack))$" \
"C:/Program Files/git/libexec/git-core/git-http-backend.exe/$1"
<LocationMatch "^/.*/git-receive-pack$">
Options +ExecCGI
AuthType Basic
AuthName intranet
AuthUserFile "C:/GIT/Apache/config/users"
Require valid-user
</LocationMatch>
<LocationMatch "^/.*/git-upload-pack$">
Options +ExecCGI
AuthType Basic
AuthName intranet
AuthUserFile "C:/GIT/Apache/config/users"
Require valid-user
</LocationMatch>
https://stackoverflow.com/questions/3817478
复制相似问题