Tell me more ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I've tried this in many different ways. Here is probably the best configuration I've managed to come up with.

nginx:

server {
    server_name   git.x-yuri.pp.ua;
    access_log   /var/log/nginx/git.x-yuri.pp.ua-access.log;
    error_log   /var/log/nginx/git.x-yuri.pp.ua.com-error.log;

    include common;

    location / {
        fastcgi_pass   unix:/var/run/fcgiwrap.socket;

        # fastcgi_param   DOCUMENT_ROOT   /home/yuri/git;
        # fastcgi_param   SCRIPT_NAME   /1.pl;
        fastcgi_param   DOCUMENT_ROOT   /usr/lib/git-core;
        fastcgi_param   SCRIPT_NAME   /git-http-backend;
        include fastcgi_params;
        fastcgi_param   DOCUMENT_ROOT   /home/yuri/git;

        fastcgi_param   GIT_HTTP_EXPORT_ALL   "";
        fastcgi_param   GIT_PROJECT_ROOT   /home/yuri/git;
        fastcgi_param   PATH_INFO   $request_uri;
    }
}

I've written a little script to intercept data between fcgiwrap and git-http-backend. Here it is:

#!/usr/bin/perl
use Data::Dumper;
my $output = `/usr/lib/git-core/git-http-backend`;
open my $fh, '>', '/home/yuri/git/1/1.txt';
print $fh $output;
print $fh Dumper {map {$_ => $ENV{$_}} 'QUERY_STRING', 'REQUEST_METHOD', 'CONTENT_TYPE', 'CONTENT_LENGTH', 'SCRIPT_NAME', 'REQUEST_URI', 'DOCUMENT_URI', 'DOCUMENT_ROOT', 'SERVER_PROTOCOL', 'GATEWAY_INTERFACE', 'SERVER_SOFTWARE', 'REMOTE_ADDR', 'REMOTE_PORT', 'SERVER_ADDR', 'SERVER_PORT', 'SERVER_NAME', 'REDIRECT_STATUS'};
print $output;

And here is the output I get:

$ git clone http://git.domain.com/1.git
Cloning into '1'...
fatal: http://git.domain.com/1.git/info/refs?service=git-upload-pack not found: did you run git update-server-info on the server?

Apparently, I did run git update-server-info. Because for example I can clone this repository without git-http-backend:

server {
    server_name   git.domain.com;
    root   /home/yuri/git;
}

And here is the data I get in 1.txt:

Status: 404 Not Found^M
Expires: Fri, 01 Jan 1980 00:00:00 GMT^M
Pragma: no-cache^M
Cache-Control: no-cache, max-age=0, must-revalidate^M
^M
$VAR1 = {
          'SERVER_NAME' => 'git.domain.com',
          'SCRIPT_NAME' => '/1.git/info/refs',
          'CONTENT_LENGTH' => '',
          'REQUEST_METHOD' => 'GET',
          'SERVER_SOFTWARE' => 'nginx/0.7.67',
          'REMOTE_PORT' => '53908',
          'QUERY_STRING' => 'service=git-upload-pack',
          'SERVER_PORT' => '80',
          'REDIRECT_STATUS' => '200',
          'REMOTE_ADDR' => 'x.x.x.x',
          'CONTENT_TYPE' => '',
          'SERVER_PROTOCOL' => 'HTTP/1.1',
          'DOCUMENT_URI' => '/1.git/info/refs',
          'REQUEST_URI' => '/1.git/info/refs?service=git-upload-pack',
          'GATEWAY_INTERFACE' => 'CGI/1.1',
          'SERVER_ADDR' => 'x.x.x.x',
          'DOCUMENT_ROOT' => '/home/yuri/git'
        };

I'm running Debian squeeze, fcgiwrap-1.0, git-1.7.2.5, nginx-0.7.67.

UPD I would be grateful if someone could at least provide me with the output of my script under apache?


On a side note, this version of fcgiwrap ignores SCRIPT_FILENAME. DOCUMENT_ROOT and SCRIPT_NAME are concatenated and split back again into the script name and PATH_INFO. But the first fastcgi_param DOCUMENT_ROOT must point to the right location, otherwise fcgiwrap wouldn't find the script to be launched for some reason. That is, this doesn't work:

        fastcgi_param   DOCUMENT_ROOT   $document_root;   # /usr/local/nginx/html
        fastcgi_param   DOCUMENT_ROOT   /home/yuri/git;

But this works:

        fastcgi_param   DOCUMENT_ROOT   /home/yuri/git;
        fastcgi_param   DOCUMENT_ROOT   $document_root;   # /usr/local/nginx/html

That is the reason behind slightly obscure nginx configuration:

        fastcgi_param   DOCUMENT_ROOT   /usr/lib/git-core;
        ...
        include fastcgi_params;
        fastcgi_param   DOCUMENT_ROOT   /home/yuri/git;

But there are some setups when it works...

share|improve this question

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.