mercurial web server deployment on nginx
Maxim Khitrov
mkhitrov at gmail.com
Mon Aug 20 12:32:41 CDT 2007
On 8/20/07, Manlio Perillo <manlio_perillo at libero.it> wrote:
> Maxim Khitrov ha scritto:
> >I
> > don't know why that happens. Second is that if you try to access a
> > non-existent repository you will see python's traceback if using
> > gitweb template. In the regular CGI script you could comment out
> > cgitb.enable() and that would hide the traceback. With FastCGI the
> > only option seems to be to download the latest gitweb template from
> > tip and replace the installed one.
> >
>
> Ok, thanks.
>
>
> Manlio Perillo
Actually, just found a much better solution. Wrote some simple set of
rules to have nginx check for valid mercurial repositories. In my
configuration I wanted http://<domain>/hg/ to be the list of all
repositories available, so here's what I did:
location ^~ /hg/ {
if ($request_uri ~ /hg(/.*)$) {
set $path $1;
}
if ($path ~ ^/(?:static/.*)?$) {
break;
}
if ($path ~ ^/([^/]+)) {
set $hg /srv/hg/$1/.hg;
}
if (!-d $hg) {
return 404;
}
fastcgi_pass unix:/var/run/fastcgi/hg.sock;
fastcgi_param PATH_INFO $path;
include fastcgi_params;
}
So the $path variable is just the url minus /hg/ prefix, it is passed
as PATH_INFO to the FastCGI server. After that, if url is / or
/static/.* then end processing. Otherwise, take the repository name
and make sure that /srv/hg/<repository>/.hg is a valid directory. You
would obviosly change the /srv/hg/ prefix. If .hg does not exist at
that path, the server responds with a 404 error that you can present
however you want. Hope that helps.
- Max
More information about the Mercurial
mailing list