title: git-http-backend
body: <p>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. </p>
  
  <p>The config</p>
  
  <pre><code>&lt;VirtualHost *:80&gt;
  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/
  
  &lt;Directory "/usr/lib/git-core*"&gt;
     Options ExecCGI Indexes
     Order allow,deny
     Allow from all
  &lt;/Directory&gt;
  
  &lt;LocationMatch "^/git/repos/git-receive-pack$"&gt;
    AuthType Digest
    AuthName "Git Repositories"
    AuthUserFile /srv/git/.git-auth-file
    AuthGroupFile /srv/git/.git-group-file
    Require valid-user
  &lt;/LocationMatch&gt;
  &lt;/VirtualHost&gt;
  </code></pre>
  
  <p>This allows everybody to read the repos but only valid users to write. The thing that bugs me is that the url is <a href="http://git.server.com/git/repos">http://git.server.com/git/repos</a>. I would like to get rid of the <strong>git</strong> in the URL like <a href="http://git.server.com/repos">http://git.server.com/repos</a>. When I change the config to </p>
  
  <pre><code>&lt;VirtualHost *:80&gt;
  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/
  
  &lt;Directory "/usr/lib/git-core*"&gt;
     Options ExecCGI Indexes
     Order allow,deny
     Allow from all
  &lt;/Directory&gt;
  
  &lt;LocationMatch "^/repos/git-receive-pack$"&gt;
    AuthType Digest
    AuthName "Git Repositories"
    AuthUserFile /srv/git/.git-auth-file
    AuthGroupFile /srv/git/.git-group-file
    Require valid-user
  &lt;/LocationMatch&gt;
  &lt;/VirtualHost&gt;
  </code></pre>
  
  <p>The authentication fails. I can still read the repos but <strong>git push</strong> fails. I couldn't figure out why this happens. </p>
  
  <pre><code>* About to connect() to git.server.com port 80 (#0)
  *   Trying MYIP... * Connected to git.server.com (MYIP) port 80 (#0)
  &gt; 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
  
  &lt; HTTP/1.1 200 OK
  &lt; Date: Sun, 28 Aug 2011 18:17:27 GMT
  &lt; 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
  &lt; Expires: Fri, 01 Jan 1980 00:00:00 GMT
  &lt; Pragma: no-cache
  &lt; Cache-Control: no-cache, max-age=0, must-revalidate
  &lt; Transfer-Encoding: chunked
  &lt; Content-Type: application/x-git-receive-pack-advertisement
  &lt; 
  * 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)
  &gt; 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
  </code></pre>
  
  <p>Can someone help me understand why the latter fails? I assume it must be that the ScriptAlias kicks in during the authentication.</p>
  
  <p><strong>EDIT 1</strong>
  The logging of apache didn't give me much information. Just that the authentication fail for some reason. </p>
  
  <p>The access_log says:</p>
  
  <pre><code>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 - 
  </code></pre>
  
  <p>and the error_log says:</p>
  
  <pre><code>[Mon Aug 29 19:03:18 2011] [error] [client MYIP] Request not supported:   '/srv/git/error/HTTP_UNAUTHORIZED.html.var'
  </code></pre>