Git repository with HTTPS write access

(this is to document a setup which was not used in the end, and was replaced with gitolite)

1. Rent a VPS. For example, at TOCICI a minimal VPS costs as little as $33 per year. The following tutorial is tested with Ubuntu 11.04 on such a minimal VPS.

2. Install and configure Lighttpd

aptitude install git-core lighttpd

cat >/etc/lighttpd/conf-available/50-gitrepo.conf <<EOT
server.modules += ( "mod_cgi", "mod_setenv", "mod_rewrite" )
$HTTP["scheme"] == "https" {
  accesslog.filename = "/var/log/lighttpd/access-ssl.log"  
  server.document-root  = "/srv/www/git01.mydomain.net_ssl/"
  alias.url  += ( "/git" => "/usr/lib/git-core/git-http-backend")
  # prevent a request to "/git" from causing a 500 error (no PATH_INFO)
  url.rewrite-once         = ( "^/git$" => "/git/" )
  $HTTP["url"] =~ "^/git" {
        cgi.assign = ( "" => "" )
        setenv.add-environment = (
          "GIT_HTTP_EXPORT_ALL" => "",
          "GIT_PROJECT_ROOT" => "/srv/www/git01.mydomain.net_ssl/"
          )

        $HTTP["url"] =~ "^/git/CUSTOMER01/" {
          auth.backend = "htpasswd"
          auth.backend.htpasswd.userfile = "/etc/lighttpd/CUSTOMER01-htpasswd.user"
          auth.require = ( "" =>
                           ( "method" => "basic",
                             "realm" => "Git",
                             "require" => "valid-user"
                           )
                         )
        }
  }
}
EOT

/usr/sbin/lighty-enable-mod auth accesslog ssl gitrepo
/etc/init.d/lighttpd force-reload
htpasswd -c /etc/lighttpd/CUSTOMER01-htpasswd.user USER01

3. Create Git repositories, and the users would be able to read/write to them via HTTPS with password authentication.

, , ,

  1. #1 by nn on September 23, 2011 - 9:57 am

    Why do you not popularize nginx?

    • #2 by txlab on September 23, 2011 - 10:01 am

      why should I? I’m only writing about things that I experienced myself.

Leave a comment