Nginx – Chrooted nginx, fastcgi, and cgit

cgichrootgitnginx

I'm running a Debian server with nginx chrooted in /var/chroot/nginx. It works wonderfully, but I'd like to be able to run cgit and host my gitolite repositories.

When it was out of the chroot it would give me the same error as it is giving me now, which is this:

2012/12/08 14:25:19 [error] 9179#0: *3 FastCGI sent in stderr: "Cannot get script name, is DOCUMENT_ROOT and SCRIPT_NAME set and is the script executable?" while reading response header from upstream

I'm fairly sure that this is a problem with fastcgi… here are the relevant lines in my nginx.conf:

server {
    listen 80;
    server_name git.url.tld;
    access_log /var/log/nginx/cgit.access.log;
    error_log /var/log/nginx/cgit.error.log;
    root /var/www/htdocs/cgit;

        location ~* ^.+\.(css|png|ico)$ {
            root /var/www/htdocs/cgit;
            expires 30d;
        }

        location / {
    root /var/www/htdocs/cgit;
            fastcgi_param   SCRIPT_NAME     cgit.cgi;
    fastcgi_param   DOCUMENT_ROOT   /var/www/htdocs/cgit;
            fastcgi_param   PATH_INFO       $uri;
            fastcgi_param   QUERY_STRING    $args;
            fastcgi_pass    unix:/tmp/cgi.sock;
        }  
    }

Any clues? Fastcgi, fcgi-wrap, etc. are all outside of the chroot, because having cgit, fastcgi, and gitolite in the chroot seemed a bit excessive. fastcgi has a socket open at /var/chroot/nginx/tmp/cgi.sock.

Thanks for your help!!

Best Answer

This is probably a bug with the version of fcgiwrap found on debian squeeze (1.0-1+squeeze1). See http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=698071

Upgrading to fcgiwrap 1.0.3-3 solved the issue for me.