簡體   English   中英

針對Apache的gitolite存儲庫的GitSmartHTTP不允許我推送

[英]GitSmartHTTP for gitolite repositories over Apache does not allow me to push

我正在設置一個git-http-backend CGI腳本來處理我的git.domain子域。 服務器位於AWS雲上的ELB(彈性負載平衡器)后面。 我的服務器配置如下(我的git托管由gitolite處理):

<VirtualHost *:80>
    ServerName git.domain
    ServerAdmin hjpotter92+git@domain

    #SuexecUserGroup git git                                                                                                                                                                    
    DocumentRoot /opt/gitolite/repositories/

    PerlLoadModule Apache::Authn::Redmine

    SetEnv GIT_PROJECT_ROOT /opt/gitolite/repositories/
    SetEnv REMOTE_USER=$REDIRECT_REMOTE_USER # Have also tried removing this variable
    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))$" \
        /opt/gitolite/git-core/git-http-backend/$1

    <Directory "/opt/gitolite/git-core">
        AllowOverride None
        Options +ExecCGI -Includes
        Require all granted
    </Directory>
    <Location />
        # enabled in desparation...
        # saw it somewhere in bugzilla powered mailing list
        DAV On

        Order allow,deny
        Require all granted

        AuthType Basic
        AuthName "Git Repositories"
        AuthUserFile /dev/null
        Require valid-user

        PerlAccessHandler Apache::Authn::Redmine::access_handler
        PerlAuthenHandler Apache::Authn::Redmine::authen_handler

        RedmineDSN "DBI:mysql:database=redmine;host=endpoint.rds.amazonaws.com"
        RedmineDbUser "user"
        RedmineDbPass "your"
        RedmineGitSmartHttp yes
    </Location>

    LogLevel info
    CustomLog /var/log/apache2/gitolite.access.log combined
    ErrorLog  /var/log/apache2/gitolite.error.log
</VirtualHost>

我的apache服務器由www-data:www-data user / group運行,gitolite是用git:git用戶/組設置的。 為了允許apache讀/寫存儲庫,我做了:

# usermod -a -G git www-data
// and as a desparate measure, in frustration, the following:
# usermod -a -G www-data git

PerlAccessHandler和用戶身份驗證工作正常,因為我能夠使用redmine設置中的有效憑據克隆我的存儲庫。

但是,當我試圖推; 我在服務器日志中獲得以下內容:

10.0.225.176 [11/Feb/2017:07:46:26 +0530] "GET /xxx.git/info/refs?service=git-upload-pack HTTP/1.1" 401 726 "-" "git/2.11.0"
10.0.225.176 [11/Feb/2017:07:46:27 +0530] "GET /xxx.git/info/refs?service=git-upload-pack HTTP/1.1" 401 725 "-" "git/2.11.0"
10.0.225.176 [11/Feb/2017:07:46:27 +0530] "GET /xxx.git/info/refs?service=git-upload-pack HTTP/1.1" 200 848 "-" "git/2.11.0"
10.0.225.176 [11/Feb/2017:07:46:27 +0530] "POST /xxx.git/git-upload-pack HTTP/1.1" 200 130408 "-" "git/2.11.0"

在客戶端(在我的負載均衡器中設置的任何連接超時之后出現以下內容,30秒到10分鍾):

Counting objects: 2, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 930 bytes | 0 bytes/s, done.
Total 2 (delta 1), reused 0 (delta 0)
error: RPC failed; HTTP 504 curl 22 The requested URL returned error: 504 GATEWAY_TIMEOUT
fatal: The remote end hung up unexpectedly
fatal: The remote end hung up unexpectedly

通常情況下,我也會對長度為0的git-upload-pack進行POST (對於具有相同提交的相同存儲庫的相同命令)

10.0.225.222 [11/Feb/2017:07:50:55 +0530] "POST /pandorica.git/git-receive-pack HTTP/1.1" 200 0 "-" "git/2.11.0"
10.0.225.222 [11/Feb/2017:07:53:21 +0530] "POST /pandorica.git/git-receive-pack HTTP/1.1" 200 0 "-" "git/2.11.0"

並在我的服務器錯誤日志中收到以下內容:

[core:error] [pid 1683] (70007)The timeout specified has expired: [client 10.0.225.176:2534] AH00574: ap_content_length_filter: apr_bucket_read() failed
[cgid:error] [pid 1683] (70007)The timeout specified has expired: [client 10.0.225.176:2534] AH02550: Failed to flush CGI output to client

我甚至為git用戶玩過setuid和setuid,希望它可以幫助我推送到存儲庫; 但無濟於事!

chmod u+s /opt/gitolite/repositories
chmod g+s /opt/gitolite/repositories
// and the same commands for `*.git` inside `repositories`

來自/opt/gitolite/repositories/xyz.git/內的git配置:

http.postbuffer=200M
core.repositoryformatversion=0
core.filemode=true
core.bare=true
redminegitolite.projectid=xxx
http.receivepack=true
http.uploadpack=true

作為參考,我已經完成了以下各項:

  1. GIT-HTTP的后端
  2. Apache和git-http-backend
  3. 如何在http上設置git?
  4. 使用apache 2.4設置git-http-backend
  5. 在Windows上使用git-http-backend.exe設置Git服務器

如何設置Apache VHost以便它開始接受git push

花了我一會兒。 在我的情況下,它是權限。 我將docker引擎進程配置為以非root身份運行容器。 --userns重新映射

我有

#/etc/subuid 
docker-user:100000:65536

#/etc/subgid 
docker-runner:100000:65536

#/etc/passwd
docker-user:x:90:90::/home/docker-user:/sbin/nologin
dockremap:x:220:220::/home/dockremap:/bin/false
docker-root:x:100000:2::/home/docker-root:/sbin/nologin
docker-daemon:x:100001:2::/home/docker-daemon:/sbin/nologin 

只需使用此命令:

setfacl -RL -m g:100000:rwx -m g:100002:rwx /var/git 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM