如何使用用户/密码通过 NGINX 通过 HTTP 服务 GIT? [英] How to serve GIT through HTTP via NGINX with user/password?

查看:20
本文介绍了如何使用用户/密码通过 NGINX 通过 HTTP 服务 GIT?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尽管我找到了有关如何配置 git/nginx 以获取我的存储库的所有链接,但我无法让它们工作.

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

我跟着这个教程,Git 仓库过使用 nginx 的 HTTP WebDAV,但用户/密码限制不起作用.任何人都可以克隆存储库.

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

我来自使用 SVN + Apache + DAV_SVN 的配置,有一个密码文件(用 htpasswd 创建)和一个用于 authz 的文件.我想做同样的事情,使用 git+nginx.这怎么可能?

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 ?

感谢您的帮助!

推荐答案

看下面的文章,http://www.toofishes.net/blog/git-smart-http-transport-nginx/

它提供了一个示例 nginx 配置:

It provides a sample nginx config:

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;
        }
    }
}

这样做是将位于 URL 中/git 之后的存储库传递到 /usr/lib/git-core/git-http-backend.例如,http://git.mydomain.com/git/someapp 将指向 someapp 存储库.此存储库将位于 /srv/git/someapp 中,如 GIT_PROJECT_ROOTfastcgi_param 中所定义,并且可以更改以适合您的服务器.

What this does is pass your repo which is located after /git in the url, to /usr/lib/git-core/git-http-backend. Example, http://git.mydomain.com/git/someapp would point to the someapp repository. This repo would be located in /srv/git/someapp as defined in the fastcgi_param of GIT_PROJECT_ROOT and can be changed to fit your server.

这非常有用,您可以将 HttpAuthBasicModule 应用到 nginx 以获取密码通过 HTTP 保护您的存储库访问.

This is very useful and you can apply HttpAuthBasicModule to nginx to password protect your repo's access via HTTP.

如果您缺少 git-http-backend,您可以在 Ubuntu/Debian 或基于 RPM 的平台查看 如何在 CENTOS 5.5 上安装 git?

If you are missing git-http-backend, you can install the git-core package on Ubuntu/Debian or on RPM based platforms look at How can git be installed on CENTOS 5.5?

这篇关于如何使用用户/密码通过 NGINX 通过 HTTP 服务 GIT?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆