git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/2] doc/http-backend: give some lighttpd config examples

From
Jeff King <peff@peff.net>
Date
Apr 11, 2013, 03:36 UTC
Message-ID
<20130411033613.GB14551@sigill.intra.peff.net>
In-Reply-To
<20130411033022.GA14462@sigill.intra.peff.net>

The examples in the documentation are all for Apache. Let's at least cover the basics: an anonymous server, an authenticated server, and a "half auth" server with anonymous read and authenticated write.

Signed-off-by: Jeff King <peff@peff.net>
---
I am by no means a lighttpd expert, so there may be better ways to do
some of these. But I did test that they all work as expected.

I was tempted for a moment to provide a mechanism for the t55* tests to use either lighttpd _or_ apache, so that these could get some automated testing. But I don't relish the thought of trying to keep both configs synchronized as people update one or the other.

There are also some advanced setups in the apache part of the doc that I didn't translate here (e.g., dumb-http fallback, and static serving of dumb-http files). Mostly because I don't think they are that commonly used these days, and I do not know enough about lighttpd configuration to translate them easily. If somebody wants to make a patch on top, they can.

 Documentation/git-http-backend.txt | 55 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 55 insertions(+)
diff --git a/Documentation/git-http-backend.txt b/Documentation/git-http-backend.txt
index f43980f..cad18ce 100644
--- a/Documentation/git-http-backend.txt
+++ b/Documentation/git-http-backend.txt
@@ -167,6 +167,61 @@ ScriptAlias /git/ /var/www/cgi-bin/gitweb.cgi/
 ScriptAlias /git/ /var/www/cgi-bin/gitweb.cgi/
 ----------------------------------------------------------------
 
+Lighttpd::
+	Ensure that `mod_cgi`, `mod_alias, `mod_auth`, `mod_setenv` are
+	loaded, then set `GIT_PROJECT_ROOT` appropriately and redirect
+	all requests to the CGI:
++
+----------------------------------------------------------------
+alias.url += ( "/git" => "/usr/lib/git-core/git-http-backend" )
+$HTTP["url"] =~ "^/git" {
+	cgi.assign = ("" => "")
+	setenv.add-environment = (
+		"GIT_PROJECT_ROOT" => "/var/www/git",
+		"GIT_HTTP_EXPORT_ALL" => ""
+	)
+}
+----------------------------------------------------------------
++
+To enable anonymous read access but authenticated write access:
++
+----------------------------------------------------------------
+$HTTP["querystring"] =~ "service=git-receive-pack" {
+	include "git-auth.conf"
+}
+$HTTP["url"] =~ "^/git/.*/git-receive-pack$" {
+	include "git-auth.conf"
+}
+----------------------------------------------------------------
++
+where `git-auth.conf` looks something like:
++
+----------------------------------------------------------------
+auth.require = (
+	"/" => (
+		"method" => "basic",
+		"realm" => "Git Access",
+		"require" => "valid-user"
+	       )
+)
+# ...and set up auth.backend here
+----------------------------------------------------------------
++
+Note that unlike the similar setup with Apache, we can easily match the
+query string for receive-pack, catching the initial request from the
+client. This means that the server administrator does not have to worry
+about configuring `http.receivepack` for the repositories (the default
+value, which enables it only in the case of authentication, is
+sufficient).
++
+To require authentication for both reads and writes:
++
+----------------------------------------------------------------
+$HTTP["url"] =~ "^/git/private" {
+	include "git-auth.conf"
+}
+----------------------------------------------------------------
+
 
 ENVIRONMENT
 -----------
-- 
1.8.2.rc0.33.gd915649
Previous: Magnus TherningNext: Jakub Narębski
Message 14 of 23 in “git-http-backend: anonymous read, authenticated write”
  1. Magnus TherningApr 9, 2013
  2. Jakub NarębskiApr 9, 2013
  3. Magnus TherningApr 10, 2013
  4. Jeff KingApr 9, 2013
  5. Magnus TherningApr 10, 2013
  6. Jeff KingApr 10, 2013
  7. Jakub NarębskiApr 10, 2013
  8. Jeff KingApr 10, 2013
  9. Magnus TherningApr 10, 2013
  10. Jeff KingApr 11, 2013
  11. 0/2 http-backend documentation examplesJeff King, Apr 11, 2013
  12. 1/2 doc/http-backend: clarify "half-auth" repo configurationJeff King, Apr 11, 2013
  13. Magnus TherningApr 11, 2013
  14. 2/2 doc/http-backend: give some lighttpd config examplesJeff King, Apr 11, 2013
  15. Jakub NarębskiApr 11, 2013
  16. Jeff KingApr 11, 2013
  17. Jakub NarębskiApr 11, 2013
  18. 3/2 doc/http-backend: match query-string in apache half-auth exampleJeff King, Apr 13, 2013
  19. Jakub NarębskiApr 13, 2013
  20. Magnus TherningApr 11, 2013
  21. Jeff KingApr 11, 2013
  22. Magnus TherningApr 12, 2013
  23. Jakub NarębskiApr 11, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.