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 REMOTE_USER (%u) has double-quotes around it
17 # the received time is shown as [YYYY-mm-dd_HH:MM:SS +hhmm] (almost RFC 3339 format)
18 # -- this is one character shorter than the default but sorts so much better
19 # when the logio_module is present (almost always) the %O value is prefixed with:
20 # %I-> -- <bytes-received-including-request-and-headers>
21 # the first line of the request ("%r") is prefixed with
22 # %X%k: -- <connection-status><keepalive-request-num>
23 # <keepalive-request-num> will be omitted if apache < 2.2.11
24 # these fields are added to the end:
25 # :%{local}p -- :<actual-server-port>
26 # %Dus -- <request-time-in-microseconds>
27 # "%o{Content-Range}" -- <outgoing Content-Range header>
29 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
31 <IfVersion !>= 2.2.11>
32 LogFormat "%h %l \"%u\" %{[%F_%T %z]}t %X:\"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" :%{local}p %Dus \"%{Content-Range}o\"" girocco
34 <IfModule logio_module>
35 # %I and %O are only available with the logio_module
37 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
39 <IfVersion !>= 2.2.11>
40 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
44 # If your distribution does not set APACHE_LOG_DIR before
45 # starting Apache you will need to edit the next two directives
46 ErrorLog "${APACHE_LOG_DIR}/@@nickname@@-error.log"
47 CustomLog "${APACHE_LOG_DIR}/@@nickname@@-access.log" girocco
49 <IfModule mime_magic_module>
50 # Avoid spurious Content-Type values when git-http-backend
51 # fails to provide a Content-Type header in its output
52 MimeMagicFile /dev/null
55 DocumentRoot @@webroot@@
56 <Directory @@webroot@@>
57 # Add MultiViews only if pages are truly
58 # offered in more than a single language
59 # FollowSymLinks or SymLinksIfOwnerMatch is required for .htaccess files
60 Options FollowSymLinks
61 # FileInfo (or All) must be enabled to activate .htaccess file mod_rewrite rules
74 # The non-mod_rewrite items are handled first where the magic /[bchrw]
75 # prefix always forces selection of the prefix-indicated cgi handler.
77 ScriptAlias /w @@cgiroot@@/gitweb.cgi
78 ScriptAlias /b @@cgiroot@@/bundles.cgi
79 AliasMatch ^/h/(.*\.html)$ @@cgiroot@@/html/$1
80 ScriptAliasMatch ^/(?!(?i)gitweb\.cgi|bundles\.cgi|html\.cgi(?:/|$))([^/]+\.cgi(?:/.*)?)$ @@cgiroot@@/$1
82 # Any requests without the magic /[bchrw] are treated as Git requests if they
83 # are one of the few possible Git URLs otherwise they go to bundles or gitweb
85 # Change the setting of $SmartHTTPOnly in Girocco::Config.pm to
86 # change whether or not non-smart HTTP fetch access will be allowed.
88 <IfDefine !@@SmartHTTPOnly@@>
89 # This accelerates non-smart HTTP access to loose objects, packs and info
91 "(?x)^/(?![bchw]/)(?:r/)? \
92 ((?:[a-zA-Z0-9][a-zA-Z0-9+._-]*(?<!\.git)/)*[a-zA-Z0-9][a-zA-Z0-9+._-]*?)(?:\.git)?/( \
94 objects/info/alternates | \
95 objects/info/http-alternates | \
96 objects/info/packs | \
97 objects/[0-9a-f]{2}/[0-9a-f]{38} | \
98 objects/pack/pack-[0-9a-f]{40}\.(?:pack|idx) )$" \
99 @@reporoot@@/$1.git/$2
102 # SetEnv GIT_HTTP_BACKEND_BIN to override Config.pm $git_http_backend_bin
103 ScriptAlias /r/ @@basedir@@/bin/git-http-backend-verify/
106 "(?x)^/(?![bchrw]/) \
107 ((?:[a-zA-Z0-9][a-zA-Z0-9+._-]*(?<!\.git)/)*[a-zA-Z0-9][a-zA-Z0-9+._-]*?)(?:\.git)?/( \
111 [a-zA-Z0-9][a-zA-Z0-9+._-]*\.bundle )$" \
112 @@basedir@@/bin/git-http-backend-verify/$1.git/$2
114 # Everything else off to bundles.cgi or gitweb.cgi
116 "(?x)^/(?![bchrw]/) \
117 ((?:[a-zA-Z0-9][a-zA-Z0-9+._-]*(?<!\.git)/)*[a-zA-Z0-9][a-zA-Z0-9+._-]*?\.git/bundles)$" \
118 @@cgiroot@@/bundles.cgi/$1
120 "(?x)^/(?![bchrw]/) \
121 ((?:[a-zA-Z0-9][a-zA-Z0-9+._-]*(?<!\.git)/)*[a-zA-Z0-9][a-zA-Z0-9+._-]*?\.git(?!/bundles)(?:/.*)?)$" \
122 @@cgiroot@@/gitweb.cgi/$1
124 # mod_rewrite is not strictly required for gitweb and fetch access, but
125 # if it's not available the trailing ".git" is never optional for
126 # gitweb, the leading /h is always required for *.html, snapshots are
127 # not throttled, some bogus Git http protocol requests will not be
128 # detected early and, if non-smart HTTP is allowed, access to the
129 # /info/refs file will not be accelerated in non-smart HTTP mode.
131 <IfModule rewrite_module>
134 # Snapshot/blob_plain requests are only allowed via the PATH_INFO mechanism
135 RewriteCond %{QUERY_STRING} (^|[&;])a=(?:snapshot|blob_plain)([&;]|$) [NC]
136 RewriteRule .? - [NS,F,L]
138 # Redirect snapshot requests to snapshot.cgi
140 "(?x)^/(?![bchr]/)(?:w/)? \
141 ((?:[a-zA-Z0-9][a-zA-Z0-9+._-]*(?<!\.git)/)*[a-zA-Z0-9][a-zA-Z0-9+._-]*?\.git/ \
142 snapshot(?:/.*)?)$" \
143 @@cgiroot@@/snapshot.cgi/$1 [NS,L,H=cgi-script]
145 # Detect blob_plain requests with is_blob_plain
147 "(?x)^/(?![bchr]/)(?:w/)? \
148 ((?:[a-zA-Z0-9][a-zA-Z0-9+._-]*(?<!\.git)/)*[a-zA-Z0-9][a-zA-Z0-9+._-]*?\.git)/ \
149 blob_plain(?:/.*)?$" \
150 - [E=is_blob_plain:$1]
152 # Reject blob_plain requests if .no_blob_plain file exists and is not zero bytes
153 RewriteCond "%{ENV:is_blob_plain}" !=""
154 RewriteCond "@@reporoot@@/%{ENV:is_blob_plain}/.no_blob_plain" -s
155 RewriteRule ^ - [NS,F]
157 # Reject blob_plain requests if .no_blob_plain file exists AND mismatched Referer
158 # We require the referer host and port and git project to match the current request
159 RewriteCond "%{ENV:is_blob_plain}" !=""
160 RewriteCond "@@reporoot@@/%{ENV:is_blob_plain}/.no_blob_plain" -f
161 RewriteRule ^ - [C,E=is_blob_ref:1]
162 RewriteRule ^ - [C,E=ref_host:]
163 RewriteRule ^ - [E=ref_path:]
164 RewriteCond "%{ENV:is_blob_ref}" =1
165 RewriteCond "%{HTTP_REFERER}" "^https?://(?:[^@/]*@)?([^@:/?#]+(?::[0-9]+)?)"
166 RewriteRule ^ - [E=ref_host:%1]
167 RewriteCond "%{ENV:is_blob_ref}" =1
168 RewriteCond "%{HTTP_REFERER}" "^https?://(?:[^@/]*@)?[^@:/?#]+(?::[0-9]*)?(?:/w)?(.*)$"
169 RewriteRule ^ - [E=ref_path:%1]
170 RewriteCond "%{ENV:is_blob_ref}" =1
171 RewriteCond "@%{HTTP_HOST}=%{ENV:ref_host}@" "!^@([^=]*)=\1@$" [NC,OR]
172 RewriteCond "@/%{ENV:is_blob_plain}=%{ENV:ref_path}" "!^@([^=]*)=\1(?:[/?#]|$)"
173 RewriteRule ^ - [NS,F]
175 # Make the leading /h optional for requests that name an existing .html template
176 RewriteCond @@webroot@@/$1 !-f
177 RewriteCond @@cgiroot@@/$1 !-f
178 RewriteCond @@cgiroot@@/html/$1 -s
180 ^/(?![bchrw]/)(.*\.html)$ \
183 # Redirect bare gitweb requests without .git that name an existing repo...
184 RewriteCond @@webroot@@/$2 !-f
185 RewriteCond @@cgiroot@@/$2 !-f
186 RewriteCond @@reporoot@@/$2.git/HEAD -s
188 "(?x)^/(?![bchr]/)((?:w/)?) \
189 ((?:[a-zA-Z0-9][a-zA-Z0-9+._-]*(?<!\.git)/)*[a-zA-Z0-9][a-zA-Z0-9+._-]*(?<!\.git))$" \
190 /$1$2.git [NS,L,R=301]
192 # Of the 11 possible Git protocol URLs (i.e. passed to git-http-backend-verify),
193 # 9 are only valid with GET/HEAD and the other two are only valid with POST
194 # Furthermore, 7 are only valid when non-smart is allowed and
195 # 1 is only valid when smart-only is enabled if it has the correct query string.
197 # These two always require POST
198 RewriteCond %{REQUEST_METHOD} !=POST
200 "(?x)^/(?![bchw]/)(?:r/)? \
201 (?:[a-zA-Z0-9][a-zA-Z0-9+._-]*(?<!\.git)/)*[a-zA-Z0-9][a-zA-Z0-9+._-]*?(?:\.git)?/(?: \
203 git-receive-pack )$" \
206 <IfDefine @@SmartHTTPOnly@@>
207 # These 7 are always forbidden when non-smart HTTP is disabled
209 "(?x)^/(?![bchw]/)(?:r/)? \
210 (?:[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) )$" \
218 # This one is forbidden without the magic query string when non-smart is disabled
219 RewriteCond %{REQUEST_METHOD} !^(?:GET|HEAD)$ [OR]
220 RewriteCond %{QUERY_STRING} !(^|&)service=git-(?:upload|receive)-pack(&|$)
222 "(?x)^/(?![bchw]/)(?:r/)? \
223 (?:[a-zA-Z0-9][a-zA-Z0-9+._-]*(?<!\.git)/)*[a-zA-Z0-9][a-zA-Z0-9+._-]*?(?:\.git)?/ \
226 # This one requires GET (or HEAD)
227 RewriteCond %{REQUEST_METHOD} !^(?:GET|HEAD)$
229 "(?x)^/(?![bchw]/)(?:r/)? \
230 (?:[a-zA-Z0-9][a-zA-Z0-9+._-]*(?<!\.git)/)*[a-zA-Z0-9][a-zA-Z0-9+._-]*?(?:\.git)?/ \
231 [a-zA-Z0-9][a-zA-Z0-9+._-]*\.bundle $" \
235 <IfDefine !@@SmartHTTPOnly@@>
236 # These 9 require GET (or HEAD)
237 RewriteCond %{REQUEST_METHOD} !^(?:GET|HEAD)$
239 "(?x)^/(?![bchw]/)(?:r/)? \
240 (?:[a-zA-Z0-9][a-zA-Z0-9+._-]*(?<!\.git)/)*[a-zA-Z0-9][a-zA-Z0-9+._-]*?(?:\.git)?/(?: \
243 objects/info/alternates | \
244 objects/info/http-alternates | \
245 objects/info/packs | \
246 objects/[0-9a-f]{2}/[0-9a-f]{38} | \
247 objects/pack/pack-[0-9a-f]{40}\.(?:pack|idx) | \
248 [a-zA-Z0-9][a-zA-Z0-9+._-]*\.bundle )$" \
250 # This one can be accelerated when accessed with non-smart HTTP
251 RewriteCond %{REQUEST_METHOD} ^(?:GET|HEAD)$
252 RewriteCond %{QUERY_STRING} !(^|&)service=git-(?:upload|receive)-pack(&|$)
254 "(?x)^/(?![bchw]/)(?:r/)? \
255 ((?:[a-zA-Z0-9][a-zA-Z0-9+._-]*(?<!\.git)/)*[a-zA-Z0-9][a-zA-Z0-9+._-]*?)(?:\.git)?/ \
257 @@reporoot@@/$1.git/info/refs [NS,L]
261 <Directory @@reporoot@@>
262 Options FollowSymLinks
273 <IfModule rewrite_module>
274 # Everything fetched over the non-smart git http
275 # protocol should be an existing file. If the request
276 # is not for an existing file, just send back an error
277 # message without emitting anything into the error log.
280 RewriteCond @@reporoot@@/$1 !-f
281 RewriteRule ^(.*)$ - [NS,R=404,L]
285 <Directory @@cgiroot@@>
286 # FollowSymLinks or SymLinksIfOwnerMatch is required for .htaccess files
287 Options SymLinksIfOwnerMatch
288 # FileInfo must be enabled to activate .htaccess file mod_rewrite rules
289 AllowOverride FileInfo
308 <IfModule !mod_fastcgi.c>
309 <IfModule !mod_fcgid.c>
310 SetHandler cgi-script
314 # Note that in testing mod_fastcgi (in dynamic mode)
315 # was found to be slightly faster than mod_fcgid.
317 # However, we prefer mod_fcgid if both are available
318 # because we cannot control the server-global settings
319 # of mod_fastcgi's "FastCgiConfig" options.
321 # In order for gitweb.cgi to run reasonably well as a
322 # mod_fastcgi dynamic FastCGI application, the
323 # "FastCgiConfig" option "-idle-timeout" value needs to
324 # be increased from the default value of "30" to at
325 # least "120", preferably more like "300". But that
326 # will affect ALL dynamic mod_fastcgi applications on
327 # the ENTIRE server, not just gitweb.cgi. Additionally
328 # the "FastCgiConfig" "-restart" option probably ought
329 # to be set as well. Also, unfortunately, there is no
330 # mod_fastcgi option corresponding to mod_fcgid's
331 # MaxRequestsPerProcess option and gitweb.cgi running
332 # in FastCGI mode (without using FCGI::ProcManager) will
333 # always exit after serving 100 requests (a good thing).
335 # The alternative is to make gitweb.cgi a static
336 # mod_fastcgi application (the "FastCgiServer"
337 # directive), but then the number of running instances
338 # will be fixed at whatever value is chosen for the
339 # "-processes" option rather than being dynamically
340 # adjusted based on load and that's probably undesirable
341 # in most cases unless you run gitweb.cgi under a
342 # front-end that dynamically forks multiple copies of
343 # gitweb.cgi based on the current load. See the CPAN
344 # FCGI::ProcManager::Dynamic module for an example of
345 # how to do this in Perl:
347 # http://search.cpan.org/search?query=FCGI::ProcManager::Dynamic&mode=module
349 # So instead we prefer mod_fcgid because we can adjust
350 # the necessary options for good gitweb.cgi behavior
351 # while affecting only gitweb.cgi and having it remain
352 # a dynamic application whose total number of running
353 # instances is adjusted based on current server load.
355 <IfModule mod_fcgid.c>
356 SetHandler fcgid-script
358 <IfModule !mod_fcgid.c>
359 <IfModule mod_fastcgi.c>
360 SetHandler fastcgi-script
364 <FilesMatch ^(?!(?i)gitweb\.cgi$).*\.cgi$>
366 SetHandler cgi-script
377 <Directory @@cgiroot@@/html>
387 ForceType "text/html; charset=utf-8"
391 <IfModule mod_fcgid.c>
392 # mod_fcgid benefits from some additional config for gitweb.cgi
393 # gitweb.cgi has a hard-coded maximum of 100 requests
394 # and we do not want to give up too soon in case Git is lagging.
395 # Note that adding a 'MaxProcesses ...' option here may be valuable
396 # to limit the maximum number of gitweb.cgi processes that can be
397 # spawned (default is 100) -- perhaps to something much lower such
398 # as 1 or 2 times the number of CPU cores. Also note that in the
399 # unlikely event all the children finish their 100 requests at the
400 # same time, the server's FcgidSpawnScoreUpLimit (which defaults
401 # to 10 if not set) should be set to at least 3 times the
402 # MaxProcesses value chosen to allow them all to respawn
403 # immediately. FcgidSpawnScoreUpLimit MUST be at least twice the
404 # chosen MaxProcesses value (assuming FcgidTerminationScore is
405 # still set to the default 2) in order to allow any child at all to
406 # respawn immediately in this case without a delay.
407 FcgidCmdOptions @@cgiroot@@/gitweb.cgi \
408 MaxRequestsPerProcess 100 IOTimeout 300
411 <Directory @@basedir@@/bin>
422 <Files git-http-backend-verify>
424 SetHandler cgi-script
436 # ---- END LINES TO DUPLICATE ----
441 # Change the setting of $TLSHost in Girocco::Config.pm to change
442 # whether or not the following https virtual host is enabled.
444 <IfDefine @@TLSHost@@>
446 # This is an example configuration of an https virtualhost running Girocco, as set
447 # up at repo.or.cz; unfortunately, completely independent from Girocco::Config.
448 # It is not essential for Girocco to use a special virtualhost, however.
449 # The Config.pm $httpspushurl variable needs to be defined to properly enable
453 # These certificate files will all be automatically generated, but the
454 # paths here may need to be corrected to match the paths
455 # (especially $certsdir) from Config.pm
457 SSLCertificateFile @@certsdir@@/girocco_www_crt.pem
458 SSLCertificateKeyFile @@certsdir@@/girocco_www_key.pem
459 SSLCertificateChainFile @@certsdir@@/girocco_www_chain.pem
460 # When using a www server cert signed by a pre-trusted root, only
461 # the above three lines should be changed. Changing either of the
462 # below two lines will likely break https client authentication.
463 SSLCACertificateFile @@certsdir@@/girocco_root_crt.pem
464 SSLCADNRequestFile @@certsdir@@/girocco_client_crt.pem
467 SSLOptions +FakeBasicAuth +StrictRequire
470 # This configuration allows fetching over https without a certificate
471 # while always requiring a certificate for pushing over https
473 SSLVerifyClient optional
474 RewriteCond %{REQUEST_METHOD} ^(GET|HEAD)$ [NC]
475 RewriteCond %{QUERY_STRING} (^|&)service=git-receive-pack(&|$) [NC]
476 RewriteRule /info/refs$ - [NC,NS,env=client_auth_required:1]
477 RewriteCond %{REQUEST_METHOD} =POST [NC]
478 RewriteRule /git-receive-pack$ - [NC,NS,env=client_auth_required:1]
479 RewriteCond %{ENV:client_auth_required} 1
480 RewriteCond %{SSL:SSL_CLIENT_VERIFY} !^SUCCESS$
481 RewriteRule .? %{REQUEST_URI} [NS,R=401]
484 SSLOptions +FakeBasicAuth
485 AuthName "Git Client Authentication"
487 AuthBasicProvider anon
491 Deny from env=client_auth_required
499 Require not env client_auth_required
505 ErrorDocument 401 /authrequired.cgi
507 # ---- BEGIN DUPLICATE LINES ----
511 ## ALL the entire contents from the <VirtualHost *:80> section at the top of
512 ## this file must be copied here.
514 ## To avoid this duplication, the contents of the <VirtualHost *:80> section
515 ## above can be moved to a separate file and then included both here and in
516 ## the <VirtualHost *:80> section using an Include directive. Be careful not
517 ## to place the new include file in one of the directories the standard apache
518 ## configuration blindly includes all files from.
520 # ---- END DUPLICATE LINES ----