mercurial web server deployment on nginx
Maxim Khitrov
mkhitrov at gmail.com
Mon Aug 27 16:48:40 CDT 2007
On 8/27/07, Jack Chu <seiji22 at hotmail.com> wrote:
>
>
> Maxim Khitrov wrote:
> > 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;
> > }
>
> Thanks Maxim, this works pretty well. I've been trying to get mercurial to
> work with nginx for a few days and have had no luck until I ran into this
> thread. The only issue I have left is that the template/css files won't and
> the sort links in the mercurial index page don't load. Any suggestions?
> Thanks.
Hello,
I wrote those rules to try and generate a 404 response when a
repository isn't found. However, I quickly realized that this wouldn't
work, because you could have nested repositories. So actually I got
rid of that solution and am now using this simpler one:
location ^~ /hg/ {
if ($request_uri ~ /hg(/[^?]*)) {
set $path $1;
}
fastcgi_pass unix:/var/run/fastcgi/hg.sock;
fastcgi_param PATH_INFO $path;
include fastcgi_params;
}
Modify the location and uri checks as needed. CSS and sorting works fine for me.
Hope that helps.
- Max
P.S. Sorry for the second e-mail, forgot to cc mercurial at selenic.com before.
More information about the Mercurial
mailing list