Pages

Sunday, January 30, 2011

Setting up mercurial init.d web serving

cd /usr/lib/cgi-bin
cp /usr/share/doc/mercurial-common/examples/hgweb.cgi .
chown www-data:www-data hgweb.cgi
chmod u+x hgweb.cgi

comment the last two lines of hgweb.cgi and add the following:
#application = hgweb("/data/hg/test", "repository name")
#wsgicgi.launch(application)
from mercurial.hgweb.hgweb_mod import hgweb
from mercurial.hgweb.hgwebdir_mod import hgwebdir
from mercurial.hgweb.request import wsgiapplication

def make_web_app():
    return hgwebdir("/usr/lib/cgi-bin/hgweb.config")

application = wsgiapplication(make_web_app)
wsgicgi.launch(application)

create: hgweb.config
[collections]
/data/hg = /data/hg

Add the following to: /etc/apache2/sites-enabled/000-default
ScriptAlias /hg "/usr/lib/cgi-bin/hgweb.cgi"

http://www.aventinesolutions.nl/mediawiki/index.php/Quick_Tip:_Getting_Started_with_Mercurial

http://mercurial.selenic.com/wiki/PublishingRepositories#single


http://mercurial.selenic.com/wiki/PublishingRepositories
(Also includes resources for digest as well as allowing no pass on clone/pull, but restricting push.

7.4.1. Restrict to known users

This configuration restricts access to a known set of users as defined in the /home/user/hg/hgusers password file:



AuthType Basic
AuthName "Mercurial repositories"
AuthUserFile /home/user/hg/hgusers
Require valid-user


Since the AuthType directive is set to Basic, passwords are communicated as plain text, and it is therefore recommended that this only be used with a server configured for HTTPS. See the Apache SSL documentation for more information

http://mercurial.selenic.com/wiki/FAQ

4.22. How can I store my HTTP login once and for all ?

You can specify the usename and password in the URL like:

http://user:password@mydomain.org
Then add a new entry in the paths section of your hgrc file. With Mercurial 1.3 you can also add an auth section to your hgrc file:


[auth]
example.prefix = https://hg.example.net/
example.username = foo
example.password = bar


Prevent the certificate error
http://kiln.stackexchange.com/questions/2816/mercurial-certificate-warning-certificate-not-verified-web-cacerts

SSL Configuration

http://www.tc.umn.edu/~brams006/selfsign.html

http://www.tc.umn.edu/~brams006/selfsign_ubuntu.html


cd /opt/openssl
openssl genrsa -des3 -out server.key 4096
openssl req -new -key server.key -out server.csr
openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
# Make a copy of the server key that does not require the password
openssl rsa -in server.key -out server.key.insecure
mv server.key server.key.secure
mv server.key.insecure server.key

# server.crt: The self-signed server certificate.
# server.csr: Server certificate signing request.
# server.key: The private server key, does not require a password when starting Apache.
# server.key.secure: The private server key, it does require a password when starting Apache.

cp server.key /etc/apache2/ssl
cp server.crt /etc/apache2/ssl
a2enmod ssl
a2ensite default-ssl


Then edit the default-ssl.conf to change the web root-- for instance /var/www-ssl. Also modify the keys to use your custom server.key and server.crt

No comments:

Post a Comment