I am trying to serve git repositories using Nginx. I have the following configuration for Nginx server:
worker_processes auto;
error_log /var/log/nginx/error.log notice;
pid /var/run/nginx.pid;
events {
}
http {
include /etc/nginx/mime.types;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
server {
listen80;
root /home/path/to/repositories;
location ~ \.git {
auth_basic "Restricted";
auth_basic_user_file /etc/nginx/.gitpasswd;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME /usr/lib/git-core/git-http-backend;
fastcgi_param GIT_PROJECT_ROOT /home/path/to/repositories;
fastcgi_param GIT_HTTP_EXPORT_ALL "";
fastcgi_param PATH_INFO $uri;
fastcgi_param REMOTE_USER $remote_user;
client_max_body_size 0;
fastcgi_pass unix:/var/run/fcgiwrap.socket;
}
}
}
But when i try to clone it in a folder with the following command:
git clone http://user:password@my-local-ip/repo-name.git folder-name
I get the following result:
Cloning into 'folder-name'...
fatal: repository 'http://my-local-ip/repo-name.git/' not found
But the repository is there! I can serve it through "dumb http" with:
location /repositories {
root /home/path/to;
}
've checked the error.log of nginx and when I try to clone with "smart HTTP" I get:
2022/12/05 17:09:22 [error] 79488#79488: *43 FastCGI sent in stderr: "Not a git repository: '/home/path/to/repositories/repo-name.git'" while reading response header from upstream, client: 192.168.1.13, server: , request: "GET /repo-name.git/info/refs?service=git-upload-pack HTTP/1.1", upstream: "fastcgi://unix:/var/run/fcgiwrap.socket:", host: "192.168.1.13"