配置HG服务器

Mercurial + Nginx + Windows 构建代码管理


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

1. 下载
http://tortoisehg.bitbucket.org/
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就好了,用浏览器打开 你的主页看看吧

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值