Configuring Hg as backend

Hi all,

I’m trying to set up Hg behind nginx (web view, clone, pull, push)
following the
official wiki: http://mercurial.selenic.com/wiki/HgServeNginx.
I have created an empty repository ($ hg init t1), set up the following
file (hgweb):
[web]
allow_push = *
push_ssl = false
baseurl = http://localhost/hg/

[paths]
/ = /tmp/hg/*

And the following nginx.conf:
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
access_log /var/log/nginx/access.log main;
error_log /var/log/nginx/error.log error;
sendfile on;
keepalive_timeout 65;
include /etc/nginx/conf.d/.conf;
server {
listen 80;
server_name localhost;
location ~ ^/hg/(.
)$ {
proxy_pass http://127.0.0.1:8000/$1;
}
}
I launch $ hg serve --web-conf hgweb.
The web view works well, but $ hg clone http://localhost/hg/t1 fails. It
prints
abort: ‘http://localhost/hg/t1/’ does not appear to be an hg repository:
—%<— (text/html; charset=UTF-8)
html output
—%<—
!
instead of $ hg clone http://localhost:8000/t1 works. Requests are
different:

  • With nginx:
    127.0.0.1 - - [27/Nov/2012 16:21:08] “GET /t1/ HTTP/1.0” 200 -
    127.0.0.1 - - [27/Nov/2012 16:21:08] “GET /t1/ HTTP/1.0” 200 -
    127.0.0.1 - - [27/Nov/2012 16:21:08] “GET /t1/ HTTP/1.0” 200 -
    127.0.0.1 - - [27/Nov/2012 16:21:08] “GET /t1/.hg/requires HTTP/1.0” 404

127.0.0.1 - - [27/Nov/2012 16:21:08] “GET /t1/.hg/00changelog.i
HTTP/1.0”
404 -

  • Without nginx:
    127.0.0.1 - - [27/Nov/2012 16:21:32] “GET /t1/?cmd=capabilities
    HTTP/1.1”
    200 -
    127.0.0.1 - - [27/Nov/2012 16:21:32] “GET /t1/?cmd=batch HTTP/1.1” 200 -
    x-hgarg-1:cmds=heads+%3Bknown+nodes%3D
    127.0.0.1 - - [27/Nov/2012 16:21:32] “GET /t1/?cmd=listkeys HTTP/1.1”
    200 -
    x-hgarg-1:namespace=phases
    127.0.0.1 - - [27/Nov/2012 16:21:32] “GET /t1/?cmd=listkeys HTTP/1.1”
    200 -
    x-hgarg-1:namespace=bookmarks

is there some of you who have had the same issue? How did you solve the
problem?
Have you got ideas on how to solve it?

For your help,
Thanks by advance.

Hello!

On Tue, Nov 27, 2012 at 05:10:02PM +0100, Gautier DI FOLCO wrote:

baseurl = http://localhost/hg/
worker_connections 1024;
listen 80;
server_name localhost;
location ~ ^/hg/(.*)$ {
proxy_pass http://127.0.0.1:8000/$1;
}

[…]

is there some of you who have had the same issue? How did you solve the
problem?
Have you got ideas on how to solve it?

You essentially asked nginx to drop request arguments here due to
proxy_pass with variables being handled specially by nginx. Use
this instead:

location /hg/ {
    proxy_pass http://127.0.0.1:8080/;
}

More details can be found here:

http://nginx.org/r/proxy_pass
http://nginx.org/r/location


Maxim D.
http://nginx.com/support.html

2012/11/27 Maxim D. re[email protected]

http://nginx.org/r/proxy_pass
http://nginx.org/r/location

It works! So fast, thank you very much.

2012/11/27 Volodymyr K. [email protected]

baseurl = http://hostname/hg/

[paths]
/ = /where/is/hg/*

Thanks for your answer.
I didn’t try this way because I didn’t know it.
Thank you for this hint.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs