Assuming you can’t configure your apache server to use hg fast cgi script, or you don’t have apache, here is another solution :
using hg –serve with nginx as proxy for authentication
this small how to is based on ubuntu but should work on many distro with few modifications.
This how to also assumes that you know hg basics and hav mercurial isntalled. the best beginner how to I know for mercurial (hg) is hgInit.
Get and configure NginX
First, we need to install the nginx server :
sudo apt-get install nginx
Now, here is the basic config needed for nginx to put in a new file in /etc/nginx/sites-available/ :
server {
listen 80; # may be different if a web server is already running on the box
server_name hg.domain.com; # standard stuff
access_log /path/to/log/access.log;
error_log /path/to/log/error.log;
location / {
# limit_except GET { # if we want to do this for all requests but GETS (public clone, private push)
auth_basic "Restricted";
auth_basic_user_file /path/to/htpasswd;
proxy_pass http://localhost:10000; # or what ever port your hg serve is running.
}
}
Configure authentication
to create a htpasswd file just run :
htpasswd -c# -c create or overwrite
and supply a password. If you want to give a new user commit rights, simply run :
htpasswd
Configure hg
Then you need to set a config file for hg serve which lists the repositories. you can place this file where you want (just keep seurity basics in mind) and put inside a section path containing your repos like this (ie: /path/to/hgweb.conf):
[paths] repo_one = /path/to/repo_one repo_two = /path/to/repo_two
You may also want t allow push tp your repositrories, so edit all /
and add the following lines :
[web] push_ssl = false allow_push = *
Run for fun
Now, your ready to run :
hg serve --webdir-conf=/path/to/hgweb.conf --port 10000 sudo /etc/init.d/nginx restart # note you may need to remove the default example site if you already have a web server running on port 80
You’re done, easy as a pie
Pingback: Tweets that mention Mercurial hg push over http with authentication and multi repository -- Topsy.com