2

I set up all the needed components for a Git server on Nginx using FastCGI and followed the combined suggestions of a few tutorials to end up with this configuration:

server {
  listen 80;
  listen [::]:80;

  server_name example.com www.example.com;

  return 301 https://example.com$request_uri;
}

server {
  listen 443 ssl;
  listen [::]:443 ssl;

  root /path/to/site;
  index index.html;

  server_name example.com www.example.com;

  # ... Some ssl stuff here ...

  location ~ /git(/.*) {
    auth_basic "Access denied";
    auth_basic_user_file /path/to/auth;

    client_max_body_size 0;

    fastcgi_param SCRIPT_FILENAME /usr/lib/git-core/git-http-backend;

    include fastcgi_params;

    fastcgi_param GIT_HTTP_EXPORT_ALL "";
    fastcgi_param GIT_PROJECT_ROOT /path/to/site/git;
    fastcgi_param PATH_INFO $1;
    fastcgi_param REMOTE_USER $remote_user;

    fastcgi_pass unix:/var/run/fcgiwrap.socket;
  }
}

Using the window git client however, attempting to do anything to the repository found at https://example.com/git/test.git results in the following error on the client:

fatal: repository 'https://example.com/git/test.git/' not found

And this error on the server:

2016/01/07 16:59:05 [error] 5155#0: *579 FastCGI sent in stderr: "Not a git repository: '/path/to/site/git/test.git'" while reading response header from upstream, client: xxx.xxx.xxx.xxx, server: example.com, request: "GET /git/test.git/info/refs?service=git-receive-pack HTTP/1.1", upstream: "fastcgi://unix:/var/run/fcgiwrap.socket:", host: "example.com"

Which is odd, because in the /git/test.git folder I had ran the git init --bare command previously so the repository is definitely there. I also tried chmod 0777 test.git -R in case it wasn't able to read the repository or something, but that had no effect.

I have tried many variants of the sameish configuration but I just do not understand what is going wrong here, so any help would be appreciated.

Lemon Drop
  • 131
  • 4

1 Answers1

0

Try running this in your git project folder (/path/to/site/git/test.git)

git --bare init
git update-server-info

This should prep the git directory and create the necessary files. You are just missing the second step, I think.

Alex T
  • 1