fcgiwrap+nginx configuration (was: Re: FastCGI integration for cgit?)

Peter Wu lekensteyn at gmail.com
Mon Apr 15 16:44:15 CEST 2013


On Monday 15 April 2013 16:32:42 Jason A. Donenfeld wrote:
> On Sat, Apr 13, 2013 at 10:51 AM, Peter Wu <lekensteyn at gmail.com> wrote:
> > So I was wondering if somebody has already considered integrating fastcgi
> > into cgit
> 
> This is planned for future versions once we take care of some memory
> management issues. For now, fcgiwrap is sufficient.

fcgiwrap works indeed, a different patch[1] got merged that allows multiple
commands to be specified. In order to enable smart HTTP for git and cgit, I use
the following command to start fcgiwrap:

    fcgiwrap -p /opt/cgit/cgit.cgi -p /usr/lib/git-core/git-http-backend

My nginx server configuration with caching enabled is below, hopefully it
will be of help to someone:

# based on http-backend.c from git v1.8.2.1, service_cmd
location ~ "^/[^/]+/(git-(receive|upload)-pack|HEAD|info/refs|objects/(info/(http-)?alternates|packs)|[0-9a-f]{2}/[0-9a-f]{38}|pack/pack-[0-9a-f]{40}\.(pack|idx))$" {
    fastcgi_param SCRIPT_FILENAME /usr/lib/git-core/git-http-backend;
    fastcgi_param GIT_PROJECT_ROOT /home/git/repositories;
    fastcgi_param PATH_INFO $fastcgi_script_name;
    include fastcgi_params;
    fastcgi_pass unix:/var/run/fcgi-cgit.sock;
}

fastcgi_cache cgit;
fastcgi_cache_key "$request_method$request_uri";

# requests which do not change very often
location ~ ^/[^/]+/(commit|patch|diff|snapshot|tag|stats|about) {
    fastcgi_cache_valid 1h;
    fastcgi_param SCRIPT_FILENAME /opt/cgit/cgit.cgi;
    fastcgi_param PATH_INFO $fastcgi_script_name;
    include fastcgi_params;
    fastcgi_pass unix:/var/run/fcgiwrap-cgit.sock;
}

try_files $uri @cgit;

location @cgit {
    fastcgi_cache_valid 5m;
    fastcgi_param SCRIPT_FILENAME /opt/cgit/cgit.cgi;
    fastcgi_param PATH_INFO $fastcgi_script_name;
    include fastcgi_params;
    fastcgi_pass unix:/var/run/fcgiwrap-cgit.sock;
}

 [1]: https://github.com/gnosek/fcgiwrap/commit/1b44aba5




More information about the CGit mailing list