Configuration of nginx for git-http-backend on debian(-based systems)

I'm having trouble to get git-http-backend working using an nginx server on my Ubuntu 13.04 machine. Tried it with Debian 7 before but with similar results. Basically I followed http://weininger.net/configuration-of-nginx-for-gitweb-and-git-http-backend/ but ignored anything concerning gitweb.

I did the following:

Installed nginx, git, git-core and fcgiwrap using:

apt-get install git git-core nginx fcgiwrap

Created a bare repo at /var/git/test.git and chowned it to www-data:

mkdir -p /var/git/test.git
cd /var/git/test.git
git init --bare
git update-server-info
chown -R www-data:www-data /var/git

Replaced /etc/nginx/sites-enabled/default with

server {
        listen 80;

        server_name localhost;

        location / {
                root /var/git;

                fastcgi_pass unix:/var/run/fcgiwrap.socket;
                fastcgi_param SCRIPT_FILENAME   /usr/lib/git-core/git-http-backend;
                fastcgi_param PATH_INFO         $uri;
                fastcgi_param GIT_PROJECT_ROOT  /var/git;
                fastcgi_param GIT_HTTP_EXPORT_ALL "";
                include /etc/nginx/fastcgi_params;
        }
}

When doing

GIT_CURL_VERBOSE=1 git clone http://localhost/test.git

it prints:

Klone nach 'test'...
* Couldn't find host localhost in the .netrc file; using defaults
* About to connect() to localhost port 80 (#0)
*   Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 80 (#0)
> GET /test.git/info/refs?service=git-upload-pack HTTP/1.1
User-Agent: git/1.8.1.2
Host: localhost
Accept: */*
Accept-Encoding: gzip
Pragma: no-cache

* The requested URL returned error: 500 Internal Server Error
* Closing connection 0
error: The requested URL returned error: 500 Internal Server Error while accessing http://localhost/test.git/info/refs?service=git-upload-pack
fatal: HTTP request failed

The /var/log/nginx/error.log does not contain any entries for this request. I am not sure if git-http-backend writes a logfile but could not find one.

Do you have any idea what is wrong with this setup? Do you know a way to get more information / logging concerning the 500 error?


Solution 1:

Since you're receiving a 500 error:

500 Internal Server Error while accessing http://localhost/test.git/info/refs?service=git-upload-pack

Try visiting that address in your web browser while watching the nginx error logs. You can view the error log "interactively" by:

tail -f /var/log/nginx/error.log