I've a CentOS 5 server at domain.fr. I am trying to set a subdomain so that I can use it with git : git.domain.fr

My repositories are in /home/git (example /home/git/repos.git)

I've installed git-http-backend and Nginx. I've set a repository like this:

cd /home/git/repos.git && git --bare init

I've set my git.conf (included in nginx.conf) as below.

However, on my client shell, I get the fatal error "repository not found": git clone http://git.domain.fr/repos.git

Does anyone know what I should do? It seems so simple, I'm getting frustrated because I'm sure it's nothing.

server {

    listen          80;
    server_name     git.domain.fr;
    root            /home/git;

    location ~ /(/.*) {

        include /etc/nginx/fastcgi_params;
        fastcgi_param   SCRIPT_FILENAME /usr/bin/git-http-backend;
        fastcgi_param   GIT_HTTP_EXPORT_ALL     true;
        fastcgi_param   GIT_PROJECT_ROOT        /home/git;
        fastcgi_param   PATH_INFO               $1;
        fastcgi_pass unix:/var/run/fcgiwrap.socket;

1 Answer 1


I found this snippet in a SO Q&A titled: How to serve GIT through HTTP via NGINX with user/password?.

http {
    server {
        listen       80;
        server_name  git.mydomain.com;

        location ~ /git(/.*) {
            # fcgiwrap is set up to listen on this host:port
            fastcgi_pass  localhost:9001;
            include       fastcgi_params;
            fastcgi_param SCRIPT_FILENAME     /usr/lib/git-core/git-http-backend;
            # export all repositories under GIT_PROJECT_ROOT
            fastcgi_param GIT_HTTP_EXPORT_ALL "";
            fastcgi_param GIT_PROJECT_ROOT    /srv/git;
            fastcgi_param PATH_INFO           $1;

I would make sure that your setup mirrors this one as much as possible. Also since I believe Apache is accessing your /home/git directory you need to take care that this user is able to do so. Additionally if you're using SELinux you need to make sure that the process (httpd) has appropriate contexts added to /home so that it's able to access this directory too.

Consult your /var/log/httpd/error_log log file for more details on where Apache is getting tripped up.

  • Hi ! I already checked this, but it won't work on my config. I can not figure out why, It changes nothing. Where can I find helpful logs ? What methodology/steps should I follow to debug this ? Thanks !
    – Charaf
    Commented Feb 21, 2014 at 23:18
  • @Charaf - as I stated before, the log file I'd like to see first is this one: /var/log/httpd/error_log.
    – slm
    Commented Feb 21, 2014 at 23:24
  • Almost there ! I removed the regex and replaced the fastcgi_pass url according to this post : superuser.com/questions/719949/centos-5-nginx-git-http-backend/… I do not have errors in the error_log anymore, but is still get a HTTP 502 when I git clone. iMac-de-Charaf:tmp charaf$ git clone git.domain.fr/repos.git Cloning into 'repos'... fatal: unable to access 'git.domain.fr/repos.git': The requested URL returned error: 502
    – Charaf
    Commented Feb 22, 2014 at 20:24
  • The post is continued here : superuser.com/questions/719949/centos-5-nginx-git-http-backend
    – Charaf
    Commented Feb 23, 2014 at 12:12
  • @Charaf - you should've just kept the post here. Cross posting is discouraged and typically leads to Q's getting closed.
    – slm
    Commented Feb 23, 2014 at 13:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .