Differences between revisions 3 and 4
Revision 3 as of 2009-08-12 20:07:46
Size: 1717
Editor: JasonWalsh
Comment: Added section for configuring mercurial
Revision 4 as of 2009-08-12 20:09:50
Size: 1713
Editor: JasonWalsh
Comment:
Deletions are marked like this. Additions are marked like this.
Line 3: Line 3:
==== Configuring Nginx ==== ==== Configure Nginx ====
Line 27: Line 27:
==== Configuring hg ==== ==== Configure hg ====

This is a solution I found for hosting personal projects. I was already using Nginx, didn't want to mess with (Fast)CGI, but still wanted some basic authentication for pushing. This method allows repositories to be served using hg serve, and then be cloned and accessed via the web interface anonymously, but HTTP authentication is required for pushing.

Configure Nginx

The first step is to configure Nginx.

server {
    listen      80;
    server_name <your-server-name>;    # standard stuff
    access_log  /path/to/access/log;
    error_log   /path/to/error/log;

    location / {
        limit_except GET { # do this for all requests but GETS
            auth_basic           "Restricted";
            auth_basic_user_file /path/to/htpasswd/file;
            proxy_pass http://localhost:8000;
        }

    proxy_pass http://localhost:8000; # or wherever hg serve is running
}

Configure htpasswd

cd into the root directory of your repos (i.e. /var/hg/repos), and run htpasswd -c htpasswd <user-name> and supply a password. If you want to give a new user commit rights, simply cd back to that directory and run htpasswd <user-name>.

Configure hg

The final step is to configure your repository's hgrc file, located at <repo-name>/.hg/hgrc. The import things in hgrc are to make sure that, in the [web] section, push_ssl is set to false and allow_push is set to *.

Serve

Now run hg serve as normal, and you should be able to access the web interface and clone the repository with no authentication, but to push to the central repository you need to have a user name and password from the htpasswd file.

PublishRepositoriesOnNginx (last edited 2018-06-09 07:35:07 by AntonShestakov)