Skip to content

Commit

Permalink
Update and simplify Apache config
Browse files Browse the repository at this point in the history
Use 'Require expr' feature of mod_authz_core to remove the need for
mod_rewrite and simplify the entire configuration.
  • Loading branch information
daviesj committed Feb 24, 2017
1 parent d7216d3 commit 973b3e9
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions book/04-git-server/sections/smart-http.asc
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ If you don't have Apache setup, you can do so on a Linux box with something like
[source,console]
----
$ sudo apt-get install apache2 apache2-utils
$ a2enmod cgi alias env rewrite
$ a2enmod cgi alias env
----

This also enables the `mod_cgi`, `mod_alias`, `mod_env`, and `mod_rewrite` modules, which are all needed for this to work properly.
This also enables the `mod_cgi`, `mod_alias`, and `mod_env` modules, which are all needed for this to work properly.

You’ll also need to set the Unix user group of the `/srv/git` directories to `www-data` so your web server can read- and write-access the repositories, because the Apache instance running the CGI script will (by default) be running as that user:

Expand All @@ -40,19 +40,12 @@ Finally you'll want to tell Apache to allow requests to `git-http-backend` and m

[source,console]
----
RewriteEngine On
RewriteCond %{QUERY_STRING} service=git-receive-pack [OR]
RewriteCond %{REQUEST_URI} /git-receive-pack$
RewriteRule ^/git/ - [E=AUTHREQUIRED]
<Files "git-http-backend">
AuthType Basic
AuthName "Git Access"
AuthUserFile /srv/git/.htpasswd
Require expr !(%{QUERY_STRING} -strmatch '*service=git-receive-pack*' || %{REQUEST_URI} =~ m#/git-receive-pack$#)
Require valid-user
Order deny,allow
Deny from env=AUTHREQUIRED
Satisfy any
</Files>
----

Expand Down

0 comments on commit 973b3e9

Please sign in to comment.