Git, Debian, Apache and Smart HTTP

5.6k views Asked by At

I am trying to set up git on my Debian server. However, I'm going crazy about this Smart HTTP stuff, as I want to use the Egit plug-in for eclipse and it requires Smart HTTP. And for this reason I'm unable to push my local branch to the remote repository on my server. I have installed Apache and Git 1.7.2.3. I'm using Basic Authentication and have enabled mod_cgi, mod_env and mod_alias. My apache config file for the git stuff is located at /etc/apache2/sites-available/git and has about the following contents:

 <VirtualHost *:80>
         Servername git.mydomain.com
         DocumentRoot /var/git
         SetEnv GIT_PROJECT_ROOT /var/git/
         SetEnv GIT_HTTP_EXPORT_ALL
         ScriptAlias /git/ /usr/lib/git-core/git-http-backend/
         <Directory "/var/git">
            DAV On
            Options +Indexes +FollowSymLinks
            Deny from all
            AuthType Basic
            AuthName "git repository"
            AuthUserFile /var/git/.htpasswd
            AuthGroupFile /var/git/.htgroup
         </Directory>
         <Directory /var/git/allternative>
                 Allow from all
                 Order allow,deny
                 Require group allternative
         </Directory>
         <Directory "/usr/lib/git-core/git-receive-pack">
                 Allow from all
                 Order allow,deny
                 Require group allternative
         </Directory>
 </VirtualHost>

The diretories are the following:

  • /var/git: This is the directory where all my repositories will be
  • /var/git/allternative: This is the directory where the (bare) repository lies that I'm currently trying to set up

I did everything that I read on this article (and many others saying about the same): http://progit.org/2010/03/04/smart-http.html

I still get the error from Egit that remote Smart HTTP is not enabled. What am I missing?

Thanks in advance, Andreas

2

There are 2 answers

0
thobens On BEST ANSWER

Answering my own question: I replaced the ScriptAlias directive with this:

  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/$1"

And Also added the following directive:

SetEnv REMOTE_USER=$REDIRECT_REMOTE_USER

Then it worked. I found those two settings on http://www.espace.com.eg/blog/2010/11/10/migrating-from-subversion-to-git/ and I'm not exactly sure which one of the two solved the problem, but I assume it was the SetEnv REMOTE_USER=$REDIRECT_REMOTE_USER directive.

0
Alex Shwarc On

ServerAdmin     [email protected]
ServerName      git.server.ru
ServerAlias     git
UseCanonicalName Off

# path to repo
DocumentRoot    /srv/git
DavLockDB "/var/lock/davlock"

SetEnv GIT_PROJECT_ROOT /srv/git
SetEnv GIT_HTTP_EXPORT_ALL
#in Progit http://progit.org/2010/03/04/smart-http.html next line is omitted and
#we get an error. So next line is a mandatory requirement.
SetEnv REMOTE_USER=$REDIRECT_REMOTE_USER

#Don't uncomment line below. It's a second error.
#ScriptAlias / /usr/lib/git-core/git-http-backend/

#but this works

 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/$1"

 #making accessible scripts
  <Directory /usr/lib/git-core/>
      Options +ExecCGI
  Order Allow,Deny      
  Allow from all
  </Directory>

 #opening access to our git repos
 <Directory /srv/git>
Dav on
Order Allow,Deny        
Allow from all
Options +Indexes                       
</Directory>

#need only for auth.
<LocationMatch "^.*/git-receive-pack$">
    AuthType Basic
    AuthName "Git Access"
    AuthUserFile /srv/git/passwd.git
    Require valid-user
</LocationMatch>

LogLevel warn
ErrorLog /var/log/httpd/git-error.log        
CustomLog /var/log/httpd/git-access.log combined