How to serve GIT through HTTP via NGINX with user/password?

Viewed 42270

Despite all the links I've found on how to configure git/nginx to get my repos, I can't make them work.

I followed this tutorial, Git repository over HTTP WebDAV with nginx, but the user/password restriction doesnt' work. Anyone can clone the repository.

I'm from a configuration using SVN + Apache + DAV_SVN, with a file for password (created with htpasswd), and a file for the authz. I'd like to do the same, using git+nginx. How's that possible ?

Thanks for your help!

3 Answers

Adding more details, we need 3 components: nginx, git-http-backend and fcgiwrap.

  • git-http-backend is a standalone excutable binary can be built from https://github.com/git/git . It's the official solution for handling git http/https access, I don't know if it is the best one that exists.
  • Nginx do not have a built-in general FastCGI server(or I failed to find how to use nginx's fastcgi_bind correctly). So another fastcgi server should be used, like fcgiwarp( a good manual https://www.nginx.com/resources/wiki/start/topics/examples/fcgiwrap/ )
  • Use fastcgi_pass unix:/tmp/cgi.sock; in nginx config (reference to other answers)

fastcgi is not a must, and git-http-backend is not write only for fastcgi, and fastcgi is not simplest nor performance one. for examples, I wrote a servlet to interact between nginx and git-http-backend, using nginx's proxy_pass, it also works!

Related