GIT-HTTP后端 [英] git-http-backend

查看:338
本文介绍了GIT-HTTP后端的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图建立用git-HTTP后端Git服务器和一切工作pretty就像我想,但有一个小东西。

在配置

 <虚拟主机*:80>
服务器名git.server.com
SETENV GIT_PROJECT_ROOT / SRV /混帐
SETENV GIT_HTTP_EXPORT_ALL
SETENV REMOTE_USER = $ REDIRECT_REMOTE_USER
ScriptAlias​​指令/ git的/ usr / lib目录/ git的核心/ GIT-HTTP后端/<目录/ usr / lib目录/ git的核心*>
   选项​​ExecCGI指数
   为了允许,拒绝
   所有允许
< /目录>< LocationMatch^ /的git /回购/混帐接收包$>
  摘要进行AuthType
  AuthName指令的Git库
  的AuthUserFile /srv/git/.git-auth-file
  目录AuthGroupFile /srv/git/.git-group-file
  需要有效的用户
< / LocationMatch>
< /虚拟主机>

这让所有人阅读回购,但只有有效的用户来写。的事情,我的错误是,网址是 http://git.server.com/git/repos 。我想摆脱在URL中的混帐 http://git.server.com/repos 。当我更改配置为

 <虚拟主机*:80>
服务器名git.server.com
SETENV GIT_PROJECT_ROOT / SRV /混帐
SETENV GIT_HTTP_EXPORT_ALL
SETENV REMOTE_USER = $ REDIRECT_REMOTE_USER
ScriptAlias​​指令/的/ usr / lib中/ git的核心/ GIT-HTTP后端/<目录/ usr / lib目录/ git的核心*>
   选项​​ExecCGI指数
   为了允许,拒绝
   所有允许
< /目录>< LocationMatch^ /回购/混帐接收包$>
  摘要进行AuthType
  AuthName指令的Git库
  的AuthUserFile /srv/git/.git-auth-file
  目录AuthGroupFile /srv/git/.git-group-file
  需要有效的用户
< / LocationMatch>
< /虚拟主机>

验证失败。我仍然可以读取回购,但混帐推失败。我想不出为什么会这样。

  *关于为()连接到git.server.com端口80(#0)
*尝试MYIP ... *连接到git.server.com(MYIP)端口80(#0)
> GET / iocaste /信息/裁判?服务=混帐接收包HTTP / 1.1
用户代理:混帐/ 1.7.6
主持人:git.server.com
接受:* / *
编译:无缓存< HTTP / 1.1 200 OK
<日期:孙老师,2011年8月28日18点17分27秒GMT
<服务器:Apache / 2.2.19(Unix的)了mod_ssl / 2.2.19的OpenSSL / 1.0.0d DAV / 2 PHP / 5.3.8用了Suhosin-补丁SVN / 1.6.17
<到期日:周五,1980 00:00:00 GMT 01一月
<编译:无缓存
<缓存控制:无缓存,最大年龄= 0,必重新验证
<传输编码:分块
<内容类型:应用程序/ x-混帐接收包,广告
<
*连接#0主办git.server.com保持不变
计数对象:4,完成。
最多可使用4个线程三角洲COM pression。
玉米pressing对象:100%(2/2),完成。
写对象:100%(3/3),257字节,完成。
共3(增量0),再用0(0增量)
*关于为()连接到git.server.com端口80(#0)
*尝试MYIP ... *连接
*连接到git.server.com(MYIP)端口80(#0)
> POST / iocaste /混帐接收包HTTP / 1.1
用户代理:混帐/ 1.7.6
主持人:git.server.com
接受编码:紧缩,Gzip已
内容类型:应用程序/ x-混帐接收包请求
接受:应用程序/ x-混帐接收包,结果
内容长度:393*请求的URL返回错误:404
*关闭连接#0
错误:RPC失败;结果= 22,HTTP code = 404
致命:远程端挂机意外
致命:远程端挂机意外

有人可以帮助我理解为什么后者失败?我认为它必须是在的ScriptAlias​​验证期间踢

修改1
阿帕奇的记录并没有给我太多的信息。只是,身份验证失败的某些原因。

的访问日志说:

  MYIP  -   -  [29月/ 8月/ 2011:19:03:18 +0200]GET /回购/信息/服务裁判=混帐接收包HTTP / 1.1 200 153
MYIP - - [29月/ 8月/ 2011:19:03:18 +0200]POST /回购/混帐接收包HTTP / 1.1404 -

和error_log里说:

  [周一8月29日19时03分18秒2011] [错误]不支持[客户MYIP]请求:/srv/git/error/HTTP_UNAUTHORIZED.html.var


解决方案

尝试更改

 的ScriptAlias​​ / / usr / lib目录/ git的核心/ GIT-HTTP后端/

到一个更加智能的比赛,只有引导git的请求的git-HTTP后端:

  ScriptAlias​​Match \\
    (?X)。^ /(* /(HEAD | \\
                    信息/裁判| \\
                    对象/(信息/ [^ /] + | \\
                             [0-9A-F] {2} / [0-9A-F] {38} | \\
                             包/封装[0-9A-F] {40} \\。(包| IDX))| \\
                             git-(上传|接收)-pack))$\\
     / usr / lib目录/ git的核心/ GIT-HTTP后端/

I tried to set up a git server with git-http-backend and everything works pretty much as I want but there is one little thing.

The config

<VirtualHost *:80>
ServerName git.server.com
SetEnv GIT_PROJECT_ROOT /srv/git
SetEnv GIT_HTTP_EXPORT_ALL
SetEnv REMOTE_USER=$REDIRECT_REMOTE_USER
ScriptAlias /git /usr/lib/git-core/git-http-backend/

<Directory "/usr/lib/git-core*">
   Options ExecCGI Indexes
   Order allow,deny
   Allow from all
</Directory>

<LocationMatch "^/git/repos/git-receive-pack$">
  AuthType Digest
  AuthName "Git Repositories"
  AuthUserFile /srv/git/.git-auth-file
  AuthGroupFile /srv/git/.git-group-file
  Require valid-user
</LocationMatch>
</VirtualHost>

This allows everybody to read the repos but only valid users to write. The thing that bugs me is that the url is http://git.server.com/git/repos. I would like to get rid of the git in the URL like http://git.server.com/repos. When I change the config to

<VirtualHost *:80>
ServerName git.server.com
SetEnv GIT_PROJECT_ROOT /srv/git
SetEnv GIT_HTTP_EXPORT_ALL
SetEnv REMOTE_USER=$REDIRECT_REMOTE_USER
ScriptAlias / /usr/lib/git-core/git-http-backend/

<Directory "/usr/lib/git-core*">
   Options ExecCGI Indexes
   Order allow,deny
   Allow from all
</Directory>

<LocationMatch "^/repos/git-receive-pack$">
  AuthType Digest
  AuthName "Git Repositories"
  AuthUserFile /srv/git/.git-auth-file
  AuthGroupFile /srv/git/.git-group-file
  Require valid-user
</LocationMatch>
</VirtualHost>

The authentication fails. I can still read the repos but git push fails. I couldn't figure out why this happens.

* About to connect() to git.server.com port 80 (#0)
*   Trying MYIP... * Connected to git.server.com (MYIP) port 80 (#0)
> GET /iocaste/info/refs?service=git-receive-pack HTTP/1.1
User-Agent: git/1.7.6
Host: git.server.com
Accept: */*
Pragma: no-cache

< HTTP/1.1 200 OK
< Date: Sun, 28 Aug 2011 18:17:27 GMT
< Server: Apache/2.2.19 (Unix) mod_ssl/2.2.19 OpenSSL/1.0.0d DAV/2 PHP/5.3.8 with Suhosin-Patch SVN/1.6.17
< Expires: Fri, 01 Jan 1980 00:00:00 GMT
< Pragma: no-cache
< Cache-Control: no-cache, max-age=0, must-revalidate
< Transfer-Encoding: chunked
< Content-Type: application/x-git-receive-pack-advertisement
< 
* Connection #0 to host git.server.com left intact
Counting objects: 4, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 257 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
* About to connect() to git.server.com port 80 (#0)
*   Trying MYIP... * connected
* Connected to git.server.com (MYIP) port 80 (#0)
> POST /iocaste/git-receive-pack HTTP/1.1
User-Agent: git/1.7.6
Host: git.server.com
Accept-Encoding: deflate, gzip
Content-Type: application/x-git-receive-pack-request
Accept: application/x-git-receive-pack-result
Content-Length: 393

* The requested URL returned error: 404
* Closing connection #0
error: RPC failed; result=22, HTTP code = 404
fatal: The remote end hung up unexpectedly
fatal: The remote end hung up unexpectedly

Can someone help me understand why the latter fails? I assume it must be that the ScriptAlias kicks in during the authentication.

EDIT 1 The logging of apache didn't give me much information. Just that the authentication fail for some reason.

The access_log says:

MYIP - - [29/Aug/2011:19:03:18 +0200] "GET /repos/info/refs?service=git-receive-pack HTTP/1.1" 200 153
MYIP - - [29/Aug/2011:19:03:18 +0200] "POST /repos/git-receive-pack HTTP/1.1" 404 - 

and the error_log says:

[Mon Aug 29 19:03:18 2011] [error] [client MYIP] Request not supported:   '/srv/git/error/HTTP_UNAUTHORIZED.html.var'

解决方案

Try changing

ScriptAlias / /usr/lib/git-core/git-http-backend/

to a more intelligent match that only directs git requests to git-http-backend:

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))$" \
     /usr/lib/git-core/git-http-backend/

这篇关于GIT-HTTP后端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆