stevenyao

  C++博客 :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理 ::
  22 随笔 :: 1 文章 :: 67 评论 :: 0 Trackbacks
首先说为什么是Windows平台,因为linux/unix下已经有很多人写过了,windows下还很少有人写。
其实也没什么太大不同就是几个小细节,当作自己的备忘,给其他人一个参考而已

我的目的是建立一个基于http的 mercurial服务器,而且支持用户认证的访问,mercurial本来是自带一个轻量级的http服务的,但是出于安全
我用Nginx的反向代理功能提供Mercurial的对外访问。

1. 下载
http://mercurial.selenic.com/
http://nginx.org/en/download.html

2. 安装
Mercurial需要安装,Nginx不需要,随便找个目录解压缩就好了。

3. 建立Mercurial的代码仓库
随便建个目录,比如 c:\mercurial\repos
hg init

4. 配置mercurial 并启动 mercurial 的http服务
hg serve -d -a localhost -p 8000 --webdir-conf hgweb.config
-d 是指后台运行
-a 指定 localhost是为了限制mercurial只能从本机访问
--webdir-conf 指定 mercurial的 web配置文件为 hgweb.config

hgweb.config的内容很简单
[web]
push_ssl = false
allow_push = *
[paths]
/myhg = c:\mercurial\repos\

允许push的时候不需要 https ,允许所有人push,把mercurial的代码库映射到web上的 /myhg 目录

5. 修改nginx的配置
到nginx/conf 目录下打开 nginx.conf,修改成如下的样子。
        location / {
            root   html;
            index  index.html index.htm;
            auth_basic           "Restricted";
            auth_basic_user_file htpasswd;
            proxy_pass           http://localhost:8000;
        }
使用简单的密码校验,反向代理到 localhost:8000

6. 配置用户和密码
在 nginx的 conf下,建立一个叫  htpasswd 的文件,纯文本,每一行是一对 用户名密码,冒号分隔,比如:
tom:1234
mike:5678

7. 最后启动nginx
直接运行 nginx.exe就好了,用浏览器打开 你的主页看看吧
posted on 2010-07-22 10:25 姚冬 阅读(3351) 评论(4)  编辑 收藏 引用

评论

# re: Mercurial + Nginx + Windows 构建代码管理 2010-07-22 23:18 GunsNRose
非常感谢博主分享,之前一直在WINDOWS下试了 apache,还有lighttpd 来做hg的WEB功能,主要想使用https功能,但都未成功

看了以后发现关键是在只允许localhost访问,使用web.config,然后使用nginx 来做代理  回复  更多评论
  

# re: Mercurial + Nginx + Windows 构建代码管理 2010-10-12 15:40 楠楠
你好,感谢你的分享。可以留下email吗?本人是刚刚开始研究mercurial的小菜鸟,想找像你这样的达人求助!!  回复  更多评论
  

# re: Mercurial + Nginx + Windows 构建代码管理 2011-07-26 17:05 conanca
客户端直接push 这个地址http://localhost:8000
还是可以的。

所以起不到安全验证的作用  回复  更多评论
  

# re: Mercurial + Nginx + Windows 构建代码管理 2011-07-26 18:33 conanca
@conanca
哦,抱歉

我没注意这个 -a localhost   回复  更多评论
  


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理