# Configuring Hg as backend

**URL:** <https://www.ruby-forum.com/t/configuring-hg-as-backend/224826>\
**Category:** NGINX\
**Created:** [November 27, 2012, 5:10pm UTC](https://www.ruby-forum.com/t/configuring-hg-as-backend/224826 "2012-11-27T17:10:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![aris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/258eb7/32.png) [@aris](https://www.ruby-forum.com/u/aris)\
**Post date:** [November 27, 2012, 5:10pm UTC](https://www.ruby-forum.com/t/configuring-hg-as-backend/224826/1 "2012-11-27T17:10:25Z")

</div>

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](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/](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](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](http://localhost/hg/t1) fails. It  
prints  
abort: ‘[http://localhost/hg/t1/](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](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.

---

<div class="post-metadata">

**Author:** ![Gautier\_DI\_FOLCO](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/e19adc/32.png) [@Gautier\_DI\_FOLCO](https://www.ruby-forum.com/u/Gautier_DI_FOLCO)\
**Post date:** [November 27, 2012, 5:24pm UTC](https://www.ruby-forum.com/t/configuring-hg-as-backend/224826/2 "2012-11-27T17:24:28Z")

</div>

Hello!

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

> baseurl = [http://localhost/hg/](http://localhost/hg/)  
> worker\_connections 1024;  
> listen 80;  
> server\_name localhost;  
> location ~ ^/hg/(.\*)$ {  
> proxy\_pass [http://127.0.0.1:8000/$1](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:

> **[Module ngx\_http\_proxy\_module](http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_pass)**
>
> The ngx\_http\_proxy\_module module allows passing requests to another server.

> **[Module ngx\_http\_core\_module](http://nginx.org/en/docs/http/ngx_http_core_module.html#location)**
>
> This directive appeared in version 1.11.8.

–  
Maxim D.

> **[F5 NGINX: Built for cloud-native apps. Ready for AI traffic.](https://www.f5.com/products/nginx)**
>
> Deliver modern applications with NGINX. Explore high-performance load balancing, API gateways, and web server solutions trusted by top global enterprises.

---

<div class="post-metadata">

**Author:** ![Gautier\_DI\_FOLCO](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/e19adc/32.png) [@Gautier\_DI\_FOLCO](https://www.ruby-forum.com/u/Gautier_DI_FOLCO)\
**Post date:** [November 27, 2012, 5:29pm UTC](https://www.ruby-forum.com/t/configuring-hg-as-backend/224826/3 "2012-11-27T17:29:08Z")

</div>

2012/11/27 Maxim D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

> [Module ngx\_http\_proxy\_module](http://nginx.org/r/proxy_pass)  
> [Module ngx\_http\_core\_module](http://nginx.org/r/location)

It works! So fast, thank you very much.

---

<div class="post-metadata">

**Author:** ![Gautier\_DI\_FOLCO](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/e19adc/32.png) [@Gautier\_DI\_FOLCO](https://www.ruby-forum.com/u/Gautier_DI_FOLCO)\
**Post date:** [November 28, 2012, 10:44am UTC](https://www.ruby-forum.com/t/configuring-hg-as-backend/224826/4 "2012-11-28T10:44:33Z")

</div>

2012/11/27 Volodymyr K. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

> baseurl = [http://hostname/hg/](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.
