gpt4 book ai didi

git - 如何使用用户/密码通过 NGINX 通过 HTTP 服务 GIT?

转载 作者:IT王子 更新时间:2023-10-29 01:21:19 26 4
gpt4 key购买 nike

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

我遵循了本教程,Git repository over HTTP WebDAV with nginx ,但用户/密码限制不起作用。任何人都可以克隆存储库。

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

感谢您的帮助!

最佳答案

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

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

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 存储库。此 repo 将位于 /srv/git/someapp 中,如 GIT_PROJECT_ROOTfastcgi_param 中所定义,并且可以更改以适合您的服务器。

这个很有用,可以申请HttpAuthBasicModule到 nginx 到密码保护你的 repo 通过 HTTP 访问。

编辑: 如果您缺少 git-http-backend,您可以在 Ubuntu/Debian 或基于 RPM 的平台查看 How can git be installed on CENTOS 5.5?

关于git - 如何使用用户/密码通过 NGINX 通过 HTTP 服务 GIT?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6414227/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com