如何通过使用用户/密码的NGINX通过HTTP服务GIT? [英] How to serve GIT through HTTP via NGINX with user/password?
问题描述
我从使用SVN + Apache + DAV_SVN的配置中获取密码文件(使用htpasswd创建)以及用于AuthZ的。我想用git + nginx来做同样的事情。如何可能?
感谢您的帮助! 看看下面的文章, http://www.toofishes。 net / blog / git-smart-http-transport-nginx /
它提供了一个nginx配置示例:
http {
...
服务器{
listen 80;
server_name git.mydomain.com;
位置〜/git(/.*){
#fcgiwrap设置为侦听此主机:端口
fastcgi_pass localhost:9001;
包含fastcgi_params;
fastcgi_param SCRIPT_FILENAME / usr / lib / git-core / git-http-backend;
#导出GIT_PROJECT_ROOT下的所有存储库
fastcgi_param GIT_HTTP_EXPORT_ALL;
fastcgi_param GIT_PROJECT_ROOT / srv / git;
fastcgi_param PATH_INFO $ 1;
}
}
}
repo,它位于/ git后面的 / usr / lib / git-core / git-http-backend
中。例如, http://git.mydomain.com/git/someapp
会指向 someapp
存储库。该回购将位于 / srv / git / someapp
中,如 fastcgi_param
中定义的 GIT_PROJECT_ROOT
,可以更改为适合您的服务器。
这非常有用,您可以应用 HttpAuthBasicModule
给nginx以密码保护您的repo通过HTTP访问。
编辑:如果缺少 git-http-backend
,则可以安装 git-core
在Ubuntu / Debian或基于RPM的平台上的软件包看如何在CENTOS 5.5上安装git?
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!
Take a look at the following article, http://www.toofishes.net/blog/git-smart-http-transport-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;
}
}
}
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.
This is very useful and you can apply HttpAuthBasicModule
to nginx to password protect your repo's access via HTTP.
Edit: 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屋!