1 ## To convert this file to apache.conf using the current Girocco::Config
2 ## values either do "make" or "make apache.conf" or ./make-apache-conf.sh
4 # This is an example configuration of a virtualhost running Girocco, as set up
5 # at repo.or.cz; unfortunately, somewhat independent from Girocco::Config.
6 # It is not essential for Girocco to use a special virtualhost, however.
9 # ---- BEGIN LINES TO DUPLICATE ----
11 ServerName @@httpdnsname@@
12 ServerAlias www.@@httpdnsname@@
15 # This is the standard "combined" log format modified as follows:
16 # the received time is shown as [YYYY-mm-dd_HH:MM:SS +hhmm] (almost RFC 3339 format)
17 # -- this is one character shorter than the default but sorts so much better
18 # when the logio_module is present (almost always) the %O value is prefixed with:
19 # %I-> -- <bytes-received-including-request-and-headers>
20 # the first line of the request ("%r") is prefixed with
21 # %X%k: -- <connection-status><keepalive-request-num>
22 # <keepalive-request-num> will be omitted if apache < 2.2.11
23 # these fields are added to the end:
24 # :%{local}p -- :<actual-server-port>
25 # %Dus -- <request-time-in-microseconds>
26 # "%o{Content-Range}" -- <outgoing Content-Range header>
28 LogFormat "%h %l %u %{[%F_%T %z]}t %X%k:\"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" :%{local}p %Dus \"%{Content-Range}o\"" girocco
30 <IfVersion !>= 2.2.11>
31 LogFormat "%h %l %u %{[%F_%T %z]}t %X:\"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" :%{local}p %Dus \"%{Content-Range}o\"" girocco
33 <IfModule logio_module>
34 # %I and %O are only available with the logio_module
36 LogFormat "%h %l %u %{[%F_%T %z]}t %X%k:\"%r\" %>s %I->%O \"%{Referer}i\" \"%{User-Agent}i\" :%{local}p %Dus \"%{Content-Range}o\"" girocco
38 <IfVersion !>= 2.2.11>
39 LogFormat "%h %l %u %{[%F_%T %z]}t %X:\"%r\" %>s %I->%O \"%{Referer}i\" \"%{User-Agent}i\" :%{local}p %Dus \"%{Content-Range}o\"" girocco
43 # If your distribution does not set APACHE_LOG_DIR before
44 # starting Apache you will need to edit the next two directives
45 ErrorLog "${APACHE_LOG_DIR}/@@nickname@@-error.log"
46 CustomLog "${APACHE_LOG_DIR}/@@nickname@@-access.log" girocco
48 <IfModule mime_magic_module>
49 # Avoid spurious Content-Type values when git-http-backend
50 # fails to provide a Content-Type header in its output
51 MimeMagicFile /dev/null
54 DocumentRoot @@webroot@@
55 <Directory @@webroot@@>
56 # Add MultiViews only if pages are truly
57 # offered in more than a single language
58 # FollowSymLinks or SymLinksIfOwnerMatch is required for .htaccess files
59 Options FollowSymLinks
60 # FileInfo (or All) must be enabled to activate .htaccess file mod_rewrite rules
73 # The non-mod_rewrite items are handled first where the magic /[bchrw]
74 # prefix always forces selection of the prefix-indicated cgi handler.
76 ScriptAlias /w @@cgiroot@@/gitweb.cgi
77 ScriptAlias /b @@cgiroot@@/bundles.cgi
78 ScriptAlias /h @@cgiroot@@/html.cgi
79 ScriptAliasMatch ^/(?!(?i)gitweb\.cgi|bundles\.cgi|html\.cgi(?:/|$))([^/]+\.cgi(?:/.*)?)$ @@cgiroot@@/$1
81 # Any requests without the magic /[bchrw] are treated as Git requests if they
82 # are one of the few possible Git URLs otherwise they go to bundles or gitweb
84 # Change the setting of $SmartHTTPOnly in Girocco::Config.pm to
85 # change whether or not non-smart HTTP fetch access will be allowed.
87 <IfDefine !@@SmartHTTPOnly@@>
88 # This accelerates non-smart HTTP access to loose objects, packs and info
90 "(?x)^/(?![bchw]/)(?:r/)? \
91 ((?:[a-zA-Z0-9][a-zA-Z0-9+._-]*(?<!\.git)/)*[a-zA-Z0-9][a-zA-Z0-9+._-]*?)(?:\.git)?/( \
93 objects/info/alternates | \
94 objects/info/http-alternates | \
95 objects/info/packs | \
96 objects/[0-9a-f]{2}/[0-9a-f]{38} | \
97 objects/pack/pack-[0-9a-f]{40}\.(?:pack|idx) )$" \
98 @@reporoot@@/$1.git/$2
101 # SetEnv GIT_HTTP_BACKEND_BIN to override Config.pm $git_http_backend_bin
102 ScriptAlias /r/ @@basedir@@/bin/git-http-backend-verify/
105 "(?x)^/(?![bchrw]/) \
106 ((?:[a-zA-Z0-9][a-zA-Z0-9+._-]*(?<!\.git)/)*[a-zA-Z0-9][a-zA-Z0-9+._-]*?)(?:\.git)?/( \
110 [a-zA-Z0-9][a-zA-Z0-9+._-]*\.bundle )$" \
111 @@basedir@@/bin/git-http-backend-verify/$1.git/$2
113 # Everything else off to bundles.cgi or gitweb.cgi
115 "(?x)^/(?![bchrw]/) \
116 ((?:[a-zA-Z0-9][a-zA-Z0-9+._-]*(?<!\.git)/)*[a-zA-Z0-9][a-zA-Z0-9+._-]*?\.git/bundles)$" \
117 @@cgiroot@@/bundles.cgi/$1
119 "(?x)^/(?![bchrw]/) \
120 ((?:[a-zA-Z0-9][a-zA-Z0-9+._-]*(?<!\.git)/)*[a-zA-Z0-9][a-zA-Z0-9+._-]*?\.git(?!/bundles)(?:/.*)?)$" \
121 @@cgiroot@@/gitweb.cgi/$1
123 # mod_rewrite is not strictly required for gitweb and fetch access, but
124 # if it's not available the trailing ".git" is never optional for
125 # gitweb, the leading /h is always required for *.html, snapshots are
126 # not throttled, some bogus Git http protocol requests will not be
127 # detected early and, if non-smart HTTP is allowed, access to the
128 # /info/refs file will not be accelerated in non-smart HTTP mode.
130 <IfModule rewrite_module>
133 # Snapshot requests are only allowed via the PATH_INFO mechanism
134 RewriteCond %{QUERY_STRING} (^|[&;])a=snapshot([&;]|$) [NC]
135 RewriteRule .? - [NS,F,L]
137 # Redirect snapshot requests to snapshot.cgi
139 "(?x)^/(?![bchr]/)(?:w/)? \
140 ((?:[a-zA-Z0-9][a-zA-Z0-9+._-]*(?<!\.git)/)*[a-zA-Z0-9][a-zA-Z0-9+._-]*?\.git/ \
141 snapshot(?:/.*)?)$" \
142 @@cgiroot@@/snapshot.cgi/$1 [NS,L,H=cgi-script]
144 # Make the leading /h optional for requests that name an existing .html template
145 RewriteCond @@webroot@@/$1 !-f
146 RewriteCond @@cgiroot@@/$1 !-f
147 RewriteCond @@basedir@@/html/$1 -s
149 ^/(?![bchrw]/)(.*\.html)$ \
152 # Redirect bare gitweb requests without .git that name an existing repo...
153 RewriteCond @@webroot@@/$2 !-f
154 RewriteCond @@cgiroot@@/$2 !-f
155 RewriteCond @@reporoot@@/$2.git/HEAD -s
157 "(?x)^/(?![bchr]/)((?:w/)?) \
158 ((?:[a-zA-Z0-9][a-zA-Z0-9+._-]*(?<!\.git)/)*[a-zA-Z0-9][a-zA-Z0-9+._-]*(?<!\.git))$" \
159 /$1$2.git [NS,L,R=301]
161 # Of the 11 possible Git protocol URLs (i.e. passed to git-http-backend-verify),
162 # 9 are only valid with GET/HEAD and the other two are only valid with POST
163 # Furthermore, 7 are only valid when non-smart is allowed and
164 # 1 is only valid when smart-only is enabled if it has the correct query string.
166 # These two always require POST
167 RewriteCond %{REQUEST_METHOD} !=POST
169 "(?x)^/(?![bchw]/)(?:r/)? \
170 (?:[a-zA-Z0-9][a-zA-Z0-9+._-]*(?<!\.git)/)*[a-zA-Z0-9][a-zA-Z0-9+._-]*?(?:\.git)?/(?: \
172 git-receive-pack )$" \
175 <IfDefine @@SmartHTTPOnly@@>
176 # These 7 are always forbidden when non-smart HTTP is disabled
178 "(?x)^/(?![bchw]/)(?:r/)? \
179 (?:[a-zA-Z0-9][a-zA-Z0-9+._-]*(?<!\.git)/)*[a-zA-Z0-9][a-zA-Z0-9+._-]*?(?:\.git)?/(?: \
181 objects/info/alternates | \
182 objects/info/http-alternates | \
183 objects/info/packs | \
184 objects/[0-9a-f]{2}/[0-9a-f]{38} | \
185 objects/pack/pack-[0-9a-f]{40}\.(?:pack|idx) )$" \
187 # This one is forbidden without the magic query string when non-smart is disabled
188 RewriteCond %{REQUEST_METHOD} !^(?:GET|HEAD)$ [OR]
189 RewriteCond %{QUERY_STRING} !(^|&)service=git-(?:upload|receive)-pack(&|$)
191 "(?x)^/(?![bchw]/)(?:r/)? \
192 (?:[a-zA-Z0-9][a-zA-Z0-9+._-]*(?<!\.git)/)*[a-zA-Z0-9][a-zA-Z0-9+._-]*?(?:\.git)?/ \
195 # This one requires GET (or HEAD)
196 RewriteCond %{REQUEST_METHOD} !^(?:GET|HEAD)$
198 "(?x)^/(?![bchw]/)(?:r/)? \
199 (?:[a-zA-Z0-9][a-zA-Z0-9+._-]*(?<!\.git)/)*[a-zA-Z0-9][a-zA-Z0-9+._-]*?(?:\.git)?/ \
200 [a-zA-Z0-9][a-zA-Z0-9+._-]*\.bundle $" \
204 <IfDefine !@@SmartHTTPOnly@@>
205 # These 9 require GET (or HEAD)
206 RewriteCond %{REQUEST_METHOD} !^(?:GET|HEAD)$
208 "(?x)^/(?![bchw]/)(?:r/)? \
209 (?:[a-zA-Z0-9][a-zA-Z0-9+._-]*(?<!\.git)/)*[a-zA-Z0-9][a-zA-Z0-9+._-]*?(?:\.git)?/(?: \
212 objects/info/alternates | \
213 objects/info/http-alternates | \
214 objects/info/packs | \
215 objects/[0-9a-f]{2}/[0-9a-f]{38} | \
216 objects/pack/pack-[0-9a-f]{40}\.(?:pack|idx) | \
217 [a-zA-Z0-9][a-zA-Z0-9+._-]*\.bundle )$" \
219 # This one can be accelerated when accessed with non-smart HTTP
220 RewriteCond %{REQUEST_METHOD} ^(?:GET|HEAD)$
221 RewriteCond %{QUERY_STRING} !(^|&)service=git-(?:upload|receive)-pack(&|$)
223 "(?x)^/(?![bchw]/)(?:r/)? \
224 ((?:[a-zA-Z0-9][a-zA-Z0-9+._-]*(?<!\.git)/)*[a-zA-Z0-9][a-zA-Z0-9+._-]*?)(?:\.git)?/ \
226 @@reporoot@@/$1.git/info/refs [NS,L]
230 <Directory @@reporoot@@>
231 Options FollowSymLinks
242 <IfModule rewrite_module>
243 # Everything fetched over the non-smart git http
244 # protocol should be an existing file. If the request
245 # is not for an existing file, just send back an error
246 # message without emitting anything into the error log.
249 RewriteCond @@reporoot@@/$1 !-f
250 RewriteRule ^(.*)$ - [NS,R=404,L]
254 <Directory @@cgiroot@@>
255 # FollowSymLinks or SymLinksIfOwnerMatch is required for .htaccess files
256 Options SymLinksIfOwnerMatch
257 # FileInfo must be enabled to activate .htaccess file mod_rewrite rules
258 AllowOverride FileInfo
277 <IfModule !mod_fastcgi.c>
278 <IfModule !mod_fcgid.c>
279 SetHandler cgi-script
283 # Note that in testing mod_fastcgi (in dynamic mode)
284 # was found to be slightly faster than mod_fcgid.
286 # However, we prefer mod_fcgid if both are available
287 # because we cannot control the server-global settings
288 # of mod_fastcgi's "FastCgiConfig" options.
290 # In order for gitweb.cgi to run reasonably well as a
291 # mod_fastcgi dynamic FastCGI application, the
292 # "FastCgiConfig" option "-idle-timeout" value needs to
293 # be increased from the default value of "30" to at
294 # least "120", preferably more like "300". But that
295 # will affect ALL dynamic mod_fastcgi applications on
296 # the ENTIRE server, not just gitweb.cgi. Additionally
297 # the "FastCgiConfig" "-restart" option probably ought
298 # to be set as well. Also, unfortunately, there is no
299 # mod_fastcgi option corresponding to mod_fcgid's
300 # MaxRequestsPerProcess option and gitweb.cgi running
301 # in FastCGI mode (without using FCGI::ProcManager) will
302 # always exit after serving 100 requests (a good thing).
304 # The alternative is to make gitweb.cgi a static
305 # mod_fastcgi application (the "FastCgiServer"
306 # directive), but then the number of running instances
307 # will be fixed at whatever value is chosen for the
308 # "-processes" option rather than being dynamically
309 # adjusted based on load and that's probably undesirable
310 # in most cases unless you run gitweb.cgi under a
311 # front-end that dynamically forks multiple copies of
312 # gitweb.cgi based on the current load. See the CPAN
313 # FCGI::ProcManager::Dynamic module for an example of
314 # how to do this in Perl:
316 # http://search.cpan.org/search?query=FCGI::ProcManager::Dynamic&mode=module
318 # So instead we prefer mod_fcgid because we can adjust
319 # the necessary options for good gitweb.cgi behavior
320 # while affecting only gitweb.cgi and having it remain
321 # a dynamic application whose total number of running
322 # instances is adjusted based on current server load.
324 <IfModule mod_fcgid.c>
325 SetHandler fcgid-script
327 <IfModule !mod_fcgid.c>
328 <IfModule mod_fastcgi.c>
329 SetHandler fastcgi-script
333 <FilesMatch ^(?!(?i)gitweb\.cgi$).*\.cgi$>
335 SetHandler cgi-script
347 <IfModule mod_fcgid.c>
348 # mod_fcgid benefits from some additional config for gitweb.cgi
349 # gitweb.cgi has a hard-coded maximum of 100 requests
350 # and we do not want to give up too soon in case Git is lagging.
351 # Note that adding a 'MaxProcesses ...' option here may be valuable
352 # to limit the maximum number of gitweb.cgi processes that can be
353 # spawned (default is 100) -- perhaps to something much lower such
354 # as 1 or 2 times the number of CPU cores. Also note that in the
355 # unlikely event all the children finish their 100 requests at the
356 # same time, the server's FcgidSpawnScoreUpLimit (which defaults
357 # to 10 if not set) should be set to at least 3 times the
358 # MaxProcesses value chosen to allow them all to respawn
359 # immediately. FcgidSpawnScoreUpLimit MUST be at least twice the
360 # chosen MaxProcesses value (assuming FcgidTerminationScore is
361 # still set to the default 2) in order to allow any child at all to
362 # respawn immediately in this case without a delay.
363 FcgidCmdOptions @@cgiroot@@/gitweb.cgi \
364 MaxRequestsPerProcess 100 IOTimeout 300
367 <Directory @@basedir@@/bin>
378 <Files git-http-backend-verify>
380 SetHandler cgi-script
392 # ---- END LINES TO DUPLICATE ----
397 # Change the setting of $TLSHost in Girocco::Config.pm to change
398 # whether or not the following https virtual host is enabled.
400 <IfDefine @@TLSHost@@>
402 # This is an example configuration of an https virtualhost running Girocco, as set
403 # up at repo.or.cz; unfortunately, completely independent from Girocco::Config.
404 # It is not essential for Girocco to use a special virtualhost, however.
405 # The Config.pm $httpspushurl variable needs to be defined to properly enable
409 # These certificate files will all be automatically generated, but the
410 # paths here may need to be corrected to match the paths
411 # (especially $certsdir) from Config.pm
413 SSLCertificateFile @@certsdir@@/girocco_www_crt.pem
414 SSLCertificateKeyFile @@certsdir@@/girocco_www_key.pem
415 SSLCertificateChainFile @@certsdir@@/girocco_www_chain.pem
416 # when using a paid www server cert, only the above three lines should
417 # be changed. Changing any of the below two lines (other than updating
418 # the paths to match $certsdir) will likely break https client auth
419 SSLCACertificateFile @@certsdir@@/girocco_root_crt.pem
420 SSLCADNRequestFile @@certsdir@@/girocco_client_crt.pem
423 SSLOptions +FakeBasicAuth +StrictRequire
426 # This configuration allows fetching over https without a certificate
427 # while always requiring a certificate for pushing over https
429 SSLVerifyClient optional
430 RewriteCond %{REQUEST_METHOD} ^(GET|HEAD)$ [NC]
431 RewriteCond %{QUERY_STRING} (^|&)service=git-receive-pack(&|$) [NC]
432 RewriteRule /info/refs$ - [NC,NS,env=client_auth_required:1]
433 RewriteCond %{REQUEST_METHOD} =POST [NC]
434 RewriteRule /git-receive-pack$ - [NC,NS,env=client_auth_required:1]
435 RewriteCond %{ENV:client_auth_required} 1
436 RewriteCond %{SSL:SSL_CLIENT_VERIFY} !^SUCCESS$
437 RewriteRule .? %{REQUEST_URI} [NS,R=401]
440 SSLOptions +FakeBasicAuth
441 AuthName "Git Client Authentication"
443 AuthBasicProvider anon
447 Deny from env=client_auth_required
455 Require not env client_auth_required
461 ErrorDocument 401 /authrequired.cgi
463 # ---- BEGIN DUPLICATE LINES ----
467 ## ALL the entire contents from the <VirtualHost *:80> section at the top of
468 ## this file must be copied here.
470 ## To avoid this duplication, the contents of the <VirtualHost *:80> section
471 ## above can be moved to a separate file and then included both here and in
472 ## the <VirtualHost *:80> section using an Include directive. Be careful not
473 ## to place the new include file in one of the directories the standard apache
474 ## configuration blindly includes all files from.
476 # ---- END DUPLICATE LINES ----