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 <IfModule rewrite_module>
11 RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/
12 RewriteCond %{SERVER_NAME} =@@httpdnsname@@
13 RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [L,NE,R=301]
17 Alias /.well-known/acme-challenge/ @@webroot@@/../certs/acme/.well-known/acme-challenge/
18 <Directory "@@webroot@@/../certs/acme/.well-known/acme-challenge/">
32 # ---- BEGIN LINES TO DUPLICATE ----
34 ServerName @@httpdnsname@@
35 ServerAlias www.@@httpdnsname@@
38 # This is the standard "combined" log format modified as follows:
39 # the REMOTE_USER (%u) has double-quotes around it
40 # the received time is shown as [YYYY-mm-dd_HH:MM:SS +hhmm] (almost RFC 3339 format)
41 # -- this is one character shorter than the default but sorts so much better
42 # when the logio_module is present (almost always) the %O value is prefixed with:
43 # %I-> -- <bytes-received-including-request-and-headers>
44 # the first line of the request ("%r") is prefixed with
45 # %X%k: -- <connection-status><keepalive-request-num>
46 # <keepalive-request-num> will be omitted if apache < 2.2.11
47 # these fields are added to the end:
48 # :%{local}p -- :<actual-server-port>
49 # %Dus -- <request-time-in-microseconds>
50 # "%o{Content-Range}" -- <outgoing Content-Range header>
52 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
54 <IfVersion !>= 2.2.11>
55 LogFormat "%h %l \"%u\" %{[%F_%T %z]}t %X:\"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" :%{local}p %Dus \"%{Content-Range}o\"" girocco
57 <IfModule logio_module>
58 # %I and %O are only available with the logio_module
60 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
62 <IfVersion !>= 2.2.11>
63 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
67 # If your distribution does not set APACHE_LOG_DIR before
68 # starting Apache you will need to edit the next two directives
69 ErrorLog "/var/log/apache2/repo-error.log"
70 CustomLog "/var/log/apache2/repo-access.log" girocco
72 <IfModule mime_magic_module>
73 # Avoid spurious Content-Type values when git-http-backend
74 # fails to provide a Content-Type header in its output
75 MimeMagicFile /dev/null
78 DocumentRoot @@webroot@@
79 <Directory @@webroot@@>
80 # Add MultiViews only if pages are truly
81 # offered in more than a single language
82 # FollowSymLinks or SymLinksIfOwnerMatch is required for .htaccess files
83 Options FollowSymLinks
84 # FileInfo (or All) must be enabled to activate .htaccess file mod_rewrite rules
97 # The non-mod_rewrite items are handled first where the magic /[bchrw]
98 # prefix always forces selection of the prefix-indicated cgi handler.
100 ScriptAlias /w @@cgiroot@@/gitweb.cgi
101 ScriptAlias /b @@cgiroot@@/bundles.cgi
102 ScriptAlias /h @@cgiroot@@/html.cgi
103 ScriptAliasMatch ^/(?!(?i)gitweb\.cgi|bundles\.cgi|html\.cgi(?:/|$))([^/]+\.cgi(?:/.*)?)$ @@cgiroot@@/$1
105 # Any requests without the magic /[bchrw] are treated as Git requests if they
106 # are one of the few possible Git URLs otherwise they go to bundles or gitweb
108 # Change the setting of $SmartHTTPOnly in Girocco::Config.pm to
109 # change whether or not non-smart HTTP fetch access will be allowed.
111 <IfDefine !@@SmartHTTPOnly@@>
112 # This accelerates non-smart HTTP access to loose objects, packs and info
114 "(?x)^/(?![bchw]/)(?:r/)? \
115 ((?:[a-zA-Z0-9][a-zA-Z0-9+._-]*(?<!\.git)/)*[a-zA-Z0-9][a-zA-Z0-9+._-]*?)(?:\.git)?/( \
117 objects/info/alternates | \
118 objects/info/http-alternates | \
119 objects/info/packs | \
120 objects/[0-9a-f]{2}/[0-9a-f]{38} | \
121 objects/pack/pack-[0-9a-f]{40}\.(?:pack|idx) )$" \
122 @@reporoot@@/$1.git/$2
125 # SetEnv GIT_HTTP_BACKEND_BIN to override Config.pm $git_http_backend_bin
126 ScriptAlias /r/ @@basedir@@/bin/git-http-backend-verify/
129 "(?x)^/(?![bchrw]/) \
130 ((?:[a-zA-Z0-9][a-zA-Z0-9+._-]*(?<!\.git)/)*[a-zA-Z0-9][a-zA-Z0-9+._-]*?)(?:\.git)?/( \
134 [a-zA-Z0-9][a-zA-Z0-9+._-]*\.bundle )$" \
135 @@basedir@@/bin/git-http-backend-verify/$1.git/$2
137 # Everything else off to bundles.cgi or gitweb.cgi
139 "(?x)^/(?![bchrw]/) \
140 ((?:[a-zA-Z0-9][a-zA-Z0-9+._-]*(?<!\.git)/)*[a-zA-Z0-9][a-zA-Z0-9+._-]*?\.git/bundles)$" \
141 @@cgiroot@@/bundles.cgi/$1
143 "(?x)^/(?![bchrw]/) \
144 ((?:[a-zA-Z0-9][a-zA-Z0-9+._-]*(?<!\.git)/)*[a-zA-Z0-9][a-zA-Z0-9+._-]*?\.git(?!/bundles)(?:/.*)?)$" \
145 @@cgiroot@@/gitweb.cgi/$1
147 # mod_rewrite is not strictly required for gitweb and fetch access, but
148 # if it's not available the trailing ".git" is never optional for
149 # gitweb, the leading /h is always required for *.html, snapshots are
150 # not throttled, some bogus Git http protocol requests will not be
151 # detected early and, if non-smart HTTP is allowed, access to the
152 # /info/refs file will not be accelerated in non-smart HTTP mode.
154 <IfModule rewrite_module>
157 # Snapshot requests are only allowed via the PATH_INFO mechanism
158 RewriteCond %{QUERY_STRING} (^|[&;])a=snapshot([&;]|$) [NC]
159 RewriteRule .? - [NS,F,L]
161 # Redirect snapshot requests to snapshot.cgi
163 "(?x)^/(?![bchr]/)(?:w/)? \
164 ((?:[a-zA-Z0-9][a-zA-Z0-9+._-]*(?<!\.git)/)*[a-zA-Z0-9][a-zA-Z0-9+._-]*?\.git/ \
165 snapshot(?:/.*)?)$" \
166 @@cgiroot@@/snapshot.cgi/$1 [NS,L,H=cgi-script]
168 # Make the leading /h optional for requests that name an existing .html template
169 RewriteCond @@webroot@@/$1 !-f
170 RewriteCond @@cgiroot@@/$1 !-f
171 RewriteCond @@basedir@@/html/$1 -s
173 ^/(?![bchrw]/)(.*\.html)$ \
176 # Redirect bare gitweb requests without .git that name an existing repo...
177 RewriteCond @@webroot@@/$2 !-f
178 RewriteCond @@cgiroot@@/$2 !-f
179 RewriteCond @@reporoot@@/$2.git/HEAD -s
181 "(?x)^/(?![bchr]/)((?:w/)?) \
182 ((?:[a-zA-Z0-9][a-zA-Z0-9+._-]*(?<!\.git)/)*[a-zA-Z0-9][a-zA-Z0-9+._-]*(?<!\.git))$" \
183 /$1$2.git [NS,L,R=301]
185 # Of the 11 possible Git protocol URLs (i.e. passed to git-http-backend-verify),
186 # 9 are only valid with GET/HEAD and the other two are only valid with POST
187 # Furthermore, 7 are only valid when non-smart is allowed and
188 # 1 is only valid when smart-only is enabled if it has the correct query string.
190 # These two always require POST
191 RewriteCond %{REQUEST_METHOD} !=POST
193 "(?x)^/(?![bchw]/)(?:r/)? \
194 (?:[a-zA-Z0-9][a-zA-Z0-9+._-]*(?<!\.git)/)*[a-zA-Z0-9][a-zA-Z0-9+._-]*?(?:\.git)?/(?: \
196 git-receive-pack )$" \
199 <IfDefine @@SmartHTTPOnly@@>
200 # These 7 are always forbidden when non-smart HTTP is disabled
202 "(?x)^/(?![bchw]/)(?:r/)? \
203 (?:[a-zA-Z0-9][a-zA-Z0-9+._-]*(?<!\.git)/)*[a-zA-Z0-9][a-zA-Z0-9+._-]*?(?:\.git)?/(?: \
205 objects/info/alternates | \
206 objects/info/http-alternates | \
207 objects/info/packs | \
208 objects/[0-9a-f]{2}/[0-9a-f]{38} | \
209 objects/pack/pack-[0-9a-f]{40}\.(?:pack|idx) )$" \
211 # This one is forbidden without the magic query string when non-smart is disabled
212 RewriteCond %{REQUEST_METHOD} !^(?:GET|HEAD)$ [OR]
213 RewriteCond %{QUERY_STRING} !(^|&)service=git-(?:upload|receive)-pack(&|$)
215 "(?x)^/(?![bchw]/)(?:r/)? \
216 (?:[a-zA-Z0-9][a-zA-Z0-9+._-]*(?<!\.git)/)*[a-zA-Z0-9][a-zA-Z0-9+._-]*?(?:\.git)?/ \
219 # This one requires GET (or HEAD)
220 RewriteCond %{REQUEST_METHOD} !^(?:GET|HEAD)$
222 "(?x)^/(?![bchw]/)(?:r/)? \
223 (?:[a-zA-Z0-9][a-zA-Z0-9+._-]*(?<!\.git)/)*[a-zA-Z0-9][a-zA-Z0-9+._-]*?(?:\.git)?/ \
224 [a-zA-Z0-9][a-zA-Z0-9+._-]*\.bundle $" \
228 <IfDefine !@@SmartHTTPOnly@@>
229 # These 9 require GET (or HEAD)
230 RewriteCond %{REQUEST_METHOD} !^(?:GET|HEAD)$
232 "(?x)^/(?![bchw]/)(?:r/)? \
233 (?:[a-zA-Z0-9][a-zA-Z0-9+._-]*(?<!\.git)/)*[a-zA-Z0-9][a-zA-Z0-9+._-]*?(?:\.git)?/(?: \
236 objects/info/alternates | \
237 objects/info/http-alternates | \
238 objects/info/packs | \
239 objects/[0-9a-f]{2}/[0-9a-f]{38} | \
240 objects/pack/pack-[0-9a-f]{40}\.(?:pack|idx) | \
241 [a-zA-Z0-9][a-zA-Z0-9+._-]*\.bundle )$" \
243 # This one can be accelerated when accessed with non-smart HTTP
244 RewriteCond %{REQUEST_METHOD} ^(?:GET|HEAD)$
245 RewriteCond %{QUERY_STRING} !(^|&)service=git-(?:upload|receive)-pack(&|$)
247 "(?x)^/(?![bchw]/)(?:r/)? \
248 ((?:[a-zA-Z0-9][a-zA-Z0-9+._-]*(?<!\.git)/)*[a-zA-Z0-9][a-zA-Z0-9+._-]*?)(?:\.git)?/ \
250 @@reporoot@@/$1.git/info/refs [NS,L]
254 <Directory @@reporoot@@>
255 Options FollowSymLinks
266 <IfModule rewrite_module>
267 # Everything fetched over the non-smart git http
268 # protocol should be an existing file. If the request
269 # is not for an existing file, just send back an error
270 # message without emitting anything into the error log.
273 RewriteCond @@reporoot@@/$1 !-f
274 RewriteRule ^(.*)$ - [NS,R=404,L]
278 <Directory @@cgiroot@@>
279 # FollowSymLinks or SymLinksIfOwnerMatch is required for .htaccess files
280 Options SymLinksIfOwnerMatch
281 # FileInfo must be enabled to activate .htaccess file mod_rewrite rules
282 AllowOverride FileInfo
301 <IfModule !mod_fastcgi.c>
302 <IfModule !mod_fcgid.c>
303 SetHandler cgi-script
307 # Note that in testing mod_fastcgi (in dynamic mode)
308 # was found to be slightly faster than mod_fcgid.
310 # However, we prefer mod_fcgid if both are available
311 # because we cannot control the server-global settings
312 # of mod_fastcgi's "FastCgiConfig" options.
314 # In order for gitweb.cgi to run reasonably well as a
315 # mod_fastcgi dynamic FastCGI application, the
316 # "FastCgiConfig" option "-idle-timeout" value needs to
317 # be increased from the default value of "30" to at
318 # least "120", preferably more like "300". But that
319 # will affect ALL dynamic mod_fastcgi applications on
320 # the ENTIRE server, not just gitweb.cgi. Additionally
321 # the "FastCgiConfig" "-restart" option probably ought
322 # to be set as well. Also, unfortunately, there is no
323 # mod_fastcgi option corresponding to mod_fcgid's
324 # MaxRequestsPerProcess option and gitweb.cgi running
325 # in FastCGI mode (without using FCGI::ProcManager) will
326 # always exit after serving 100 requests (a good thing).
328 # The alternative is to make gitweb.cgi a static
329 # mod_fastcgi application (the "FastCgiServer"
330 # directive), but then the number of running instances
331 # will be fixed at whatever value is chosen for the
332 # "-processes" option rather than being dynamically
333 # adjusted based on load and that's probably undesirable
334 # in most cases unless you run gitweb.cgi under a
335 # front-end that dynamically forks multiple copies of
336 # gitweb.cgi based on the current load. See the CPAN
337 # FCGI::ProcManager::Dynamic module for an example of
338 # how to do this in Perl:
340 # http://search.cpan.org/search?query=FCGI::ProcManager::Dynamic&mode=module
342 # So instead we prefer mod_fcgid because we can adjust
343 # the necessary options for good gitweb.cgi behavior
344 # while affecting only gitweb.cgi and having it remain
345 # a dynamic application whose total number of running
346 # instances is adjusted based on current server load.
348 <IfModule mod_fcgid.c>
349 SetHandler fcgid-script
351 <IfModule !mod_fcgid.c>
352 <IfModule mod_fastcgi.c>
353 SetHandler fastcgi-script
357 <FilesMatch ^(?!(?i)gitweb\.cgi$).*\.cgi$>
359 SetHandler cgi-script
371 <IfModule mod_fcgid.c>
372 # mod_fcgid benefits from some additional config for gitweb.cgi
373 # gitweb.cgi has a hard-coded maximum of 100 requests
374 # and we do not want to give up too soon in case Git is lagging.
375 # Note that adding a 'MaxProcesses ...' option here may be valuable
376 # to limit the maximum number of gitweb.cgi processes that can be
377 # spawned (default is 100) -- perhaps to something much lower such
378 # as 1 or 2 times the number of CPU cores. Also note that in the
379 # unlikely event all the children finish their 100 requests at the
380 # same time, the server's FcgidSpawnScoreUpLimit (which defaults
381 # to 10 if not set) should be set to at least 3 times the
382 # MaxProcesses value chosen to allow them all to respawn
383 # immediately. FcgidSpawnScoreUpLimit MUST be at least twice the
384 # chosen MaxProcesses value (assuming FcgidTerminationScore is
385 # still set to the default 2) in order to allow any child at all to
386 # respawn immediately in this case without a delay.
387 FcgidCmdOptions @@cgiroot@@/gitweb.cgi \
388 MaxProcesses 8 MinProcesses 5 \
389 MaxRequestsPerProcess 100 IOTimeout 300
392 <Directory @@basedir@@/bin>
403 <Files git-http-backend-verify>
405 SetHandler cgi-script
417 # ---- END LINES TO DUPLICATE ----
422 # Change the setting of $TLSHost in Girocco::Config.pm to change
423 # whether or not the following https virtual host is enabled.
425 <IfDefine @@TLSHost@@>
427 # This is an example configuration of an https virtualhost running Girocco, as set
428 # up at repo.or.cz; unfortunately, completely independent from Girocco::Config.
429 # It is not essential for Girocco to use a special virtualhost, however.
430 # The Config.pm $httpspushurl variable needs to be defined to properly enable
434 # These certificate files will all be automatically generated, but the
435 # paths here may need to be corrected to match the paths
436 # (especially $certsdir) from Config.pm
438 SSLCertificateFile @@certsdir@@/acme/girocco_www_crt.pem
439 SSLCertificateKeyFile @@certsdir@@/acme/girocco_www_key.pem
440 SSLCertificateChainFile @@certsdir@@/acme/girocco_www_chain.pem
441 # when using a paid www server cert, only the above three lines should
442 # be changed. Changing any of the below two lines (other than updating
443 # the paths to match $certsdir) will likely break https client auth
444 SSLCACertificateFile @@certsdir@@/girocco_root_crt.pem
445 SSLCADNRequestFile @@certsdir@@/girocco_client_crt.pem
448 SSLOptions +FakeBasicAuth +StrictRequire
451 # This configuration allows fetching over https without a certificate
452 # while always requiring a certificate for pushing over https
454 SSLVerifyClient optional
455 RewriteCond %{REQUEST_METHOD} ^(GET|HEAD)$ [NC]
456 RewriteCond %{QUERY_STRING} (^|&)service=git-receive-pack(&|$) [NC]
457 RewriteRule /info/refs$ - [NC,NS,env=client_auth_required:1]
458 RewriteCond %{REQUEST_METHOD} =POST [NC]
459 RewriteRule /git-receive-pack$ - [NC,NS,env=client_auth_required:1]
460 RewriteCond %{ENV:client_auth_required} 1
461 RewriteCond %{SSL:SSL_CLIENT_VERIFY} !^SUCCESS$
462 RewriteRule .? %{REQUEST_URI} [NS,R=401]
465 SSLOptions +FakeBasicAuth
466 AuthName "Git Client Authentication"
468 AuthBasicProvider anon
472 Deny from env=client_auth_required
480 Require not env client_auth_required
486 ErrorDocument 401 /authrequired.cgi
488 # ---- BEGIN DUPLICATE LINES ----
492 ## ALL the entire contents from the <VirtualHost *:80> section at the top of
493 ## this file must be copied here.
495 ## To avoid this duplication, the contents of the <VirtualHost *:80> section
496 ## above can be moved to a separate file and then included both here and in
497 ## the <VirtualHost *:80> section using an Include directive. Be careful not
498 ## to place the new include file in one of the directories the standard apache
499 ## configuration blindly includes all files from.
501 # ---- END DUPLICATE LINES ----