我試着用git-http-backend設置一個git服務器,並且所有的工作都非常符合我的要求,但是有一點小東西。git-http-backend
的配置
<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>
這讓所有人閱讀回購,但只有合法的用戶來寫。錯誤的是,該網址是http://git.server.com/git/repos。我想擺脫像http://git.server.com/repos這樣的URL中的git。當我更改配置爲
<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>
身份驗證失敗。我仍然可以閱讀回購協議,但git push失敗。我無法弄清楚爲什麼會發生這種情況。
* 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
有人能幫我理解後者爲什麼會失敗嗎?我認爲它必須是ScriptAlias在身份驗證過程中啓用的。
編輯1 Apache的日誌記錄沒有給我很多信息。只是由於某種原因認證失敗。
的訪問日誌說:
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 -
和error_log中說:
[Mon Aug 29 19:03:18 2011] [error] [client MYIP] Request not supported: '/srv/git/error/HTTP_UNAUTHORIZED.html.var'
檢查您的錯誤日誌。 – manojlds
你得到一個404 ...我認爲我的帖子可能會幫助..我猜測它是你的位置匹配是有點錯誤..認爲你可能需要類似/repos/.*/git-upload-pack$ – Jon
注意:在'SetEnv'語句中不允許有'='! – ShiDoiSi