Skip to content

Commit 973b3e9

Browse files
committed
Update and simplify Apache config
Use 'Require expr' feature of mod_authz_core to remove the need for mod_rewrite and simplify the entire configuration.
1 parent d7216d3 commit 973b3e9

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

book/04-git-server/sections/smart-http.asc

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ If you don't have Apache setup, you can do so on a Linux box with something like
1313
[source,console]
1414
----
1515
$ sudo apt-get install apache2 apache2-utils
16-
$ a2enmod cgi alias env rewrite
16+
$ a2enmod cgi alias env
1717
----
1818

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

2121
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:
2222

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

4141
[source,console]
4242
----
43-
RewriteEngine On
44-
RewriteCond %{QUERY_STRING} service=git-receive-pack [OR]
45-
RewriteCond %{REQUEST_URI} /git-receive-pack$
46-
RewriteRule ^/git/ - [E=AUTHREQUIRED]
47-
4843
<Files "git-http-backend">
4944
AuthType Basic
5045
AuthName "Git Access"
5146
AuthUserFile /srv/git/.htpasswd
47+
Require expr !(%{QUERY_STRING} -strmatch '*service=git-receive-pack*' || %{REQUEST_URI} =~ m#/git-receive-pack$#)
5248
Require valid-user
53-
Order deny,allow
54-
Deny from env=AUTHREQUIRED
55-
Satisfy any
5649
</Files>
5750
----
5851

0 commit comments

Comments
 (0)