To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.

Statistics Download as Zip
| Branch: | Tag: | Revision:

root / deploy / config @ 1606:16325d2ab2dd

1 1601:07deb8466f65 Chris
2
# Apache config with SSL and admin auth stubbed in. You must provide
3
# the key/cert and auth files.
4
5
# Note this has been updated for Apache 2.4, which introduced a number
6
# of (welcome) changes to access control directives.
7
8
PerlLoadModule Apache::Authn::SoundSoftware
9
10
<VirtualHost *:80>
11
        ServerName code.soundsoftware.ac.uk
12
        ServerAdmin chris.cannam@soundsoftware.ac.uk
13
14
        DocumentRoot /var/www/code/public
15
        PassengerRestartDir restart_files
16
        PassengerHighPerformance on
17
        PassengerMaxRequests 50000
18
        PassengerStatThrottleRate 5
19
	PassengerFriendlyErrorPages off
20
        RailsSpawnMethod smart
21
        ExpiresDefault "access plus 1 minute"
22
23
        # Redirect all activity to secure site
24
        Redirect seeother / "https://code.soundsoftware.ac.uk/"
25
26
        <DirectoryMatch "^/.*/\.svn/">
27
                Require all denied
28
        </DirectoryMatch>
29
30
        <DirectoryMatch "^/.*/\.hg/">
31
                Require all denied
32
        </DirectoryMatch>
33
34
        <DirectoryMatch "^/.*/\.git/">
35
                Require all denied
36
        </DirectoryMatch>
37
38
        <Directory /var/www/code/public>
39
                Options -MultiViews
40
	</Directory>
41
42
	ErrorLog /var/log/apache2/code-error.log
43
	CustomLog /var/log/apache2/code-access.log vhost_combined
44
45
        LogLevel warn
46
        ServerSignature Off
47
</VirtualHost>
48
49 1605:18643ab36008 Chris
<VirtualHost *:443>
50 1601:07deb8466f65 Chris
        ServerName code.soundsoftware.ac.uk
51
        ServerAdmin chris.cannam@soundsoftware.ac.uk
52
53 1605:18643ab36008 Chris
        SSLEngine on
54
	SSLCertificateFile /etc/apache2/certs/code.soundsoftware.ac.uk.crt
55
	SSLCertificateKeyFile /etc/apache2/certs/code.soundsoftware.ac.uk.key
56
	SSLCertificateChainFile /etc/apache2/certs/code.soundsoftware.ac.uk.ca-bundle
57
	SSLVerifyClient none
58
	SSLProtocol all -SSLv2 -SSLv3
59
	SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM:+LOW
60
61 1601:07deb8466f65 Chris
        DocumentRoot /var/www/code/public
62
        PassengerRestartDir restart_files
63
        PassengerHighPerformance on
64
        PassengerMaxRequests 50000
65
        PassengerStatThrottleRate 5
66
	PassengerStartTimeout 60
67
	PassengerFriendlyErrorPages off
68
        RailsSpawnMethod smart
69
        ExpiresDefault "access plus 1 minute"
70
71
        <Location /sys>
72
		AuthType Basic
73
		AuthUserFile "/etc/apache2/auth/user.htpasswd"
74
		AuthName "code.soundsoftware.ac.uk"
75
		Require user user
76
	</Location>
77
78
	<Location /admin>
79
		AuthType Digest
80
		AuthUserFile "/etc/apache2/auth/admin.htdigest"
81
		AuthName "code.soundsoftware.ac.uk admin interface"
82
		Require user admin
83
	</Location>
84
85
        <DirectoryMatch "^/.*/\.svn/">
86
                Require all denied
87
        </DirectoryMatch>
88
89
        <DirectoryMatch "^/.*/\.hg/">
90
                Require all denied
91
        </DirectoryMatch>
92
93
        <DirectoryMatch "^/.*/\.git/">
94
                Require all denied
95
        </DirectoryMatch>
96
97
        <Directory /var/www/code/public>
98
                Options -MultiViews
99
	</Directory>
100
101
        <Directory /var/www/code/public/themes/soundsoftware/stylesheets/fonts>
102
		# Avoid other sites embedding our fonts
103
		RewriteEngine on
104
		RewriteCond %{HTTP_REFERER} !^$
105
		RewriteCond %{HTTP_REFERER} !^http(s)?://code.soundsoftware.ac.uk/.*$ [NC]
106
		RewriteRule \.(ttf|woff|eot|otf|svg|zip|gz|html|txt)$ - [F]
107
	</Directory>
108
109
	ScriptAlias /hg "/var/hg/index.cgi"
110
111
	<Location /hg>
112
               	AuthName "Mercurial"
113
                AuthType Basic
114
                Require valid-user
115
		PerlAccessHandler Apache::Authn::SoundSoftware::access_handler
116
      		PerlAuthenHandler Apache::Authn::SoundSoftware::authen_handler
117
		PerlSetVar HTTPS "on"
118
		SoundSoftwareDSN "dbi:Pg:database=code;host=localhost"
119
    		SoundSoftwareDbUser "code"
120
     		SoundSoftwareDbPass "INSERT_DATABASE_PASSWORD_HERE"
121
		SoundSoftwareRepoPrefix "/var/hg/"
122
                SoundSoftwareSslRequired "on"
123
		Options +ExecCGI
124
		AddHandler cgi-script .cgi
125
		ExpiresDefault now
126
        </Location>
127
128
	Alias /git "/var/files/git-mirror"
129
130
	<Directory "/var/files/git-mirror">
131
		Options -Indexes +FollowSymLinks
132
                Require all granted
133
	</Directory>
134
	<Directory ~ "/var/files/git-mirror/.*\.workdir">
135
                Require all denied
136
	</Directory>
137
	<Directory ~ "/var/files/git-mirror/__.*">
138
                Require all denied
139
	</Directory>
140
141
	ErrorLog /var/log/apache2/code-error.log
142
	CustomLog /var/log/apache2/code-access.log vhost_combined
143
144
        LogLevel warn
145
        ServerSignature Off
146
147
</VirtualHost>
148
149 1570:ae2f71010562 Chris
150
# A test Apache config. Lacks SSL, lacks a desirable extra layer of
151
# authentication for admin interface paths. Do not deploy this.
152
153 1593:83412a0a2389 Chris
# Note this has been updated for Apache 2.4, which introduced a number
154
# of (welcome) changes to access control directives.
155
156 1570:ae2f71010562 Chris
PerlLoadModule Apache::Authn::SoundSoftware
157
158
<VirtualHost *:80>
159
        ServerName code.soundsoftware.ac.uk
160
        ServerAdmin chris.cannam@soundsoftware.ac.uk
161
162
        DocumentRoot /var/www/code/public
163
        PassengerRestartDir restart_files
164
        PassengerHighPerformance on
165
        PassengerMaxRequests 50000
166
        PassengerStatThrottleRate 5
167
	PassengerStartTimeout 60
168 1571:4c2b25b7e85f Chris
	PassengerFriendlyErrorPages on
169 1570:ae2f71010562 Chris
        RailsSpawnMethod smart
170
        ExpiresDefault "access plus 1 minute"
171
172 1590:c18460da6620 Chris
#        <Location /sys>
173
#		AuthType Basic
174
#		AuthUserFile "/etc/apache2/auth/user.htpasswd"
175
#		AuthName "code.soundsoftware.ac.uk"
176
#		Require user user
177
#	</Location>
178
179
#	<Location /admin>
180
#		AuthType Digest
181
#		AuthUserFile "/etc/apache2/auth/admin.htdigest"
182
#		AuthName "code.soundsoftware.ac.uk admin interface"
183
#		Require user admin
184
#	</Location>
185
186 1570:ae2f71010562 Chris
        <DirectoryMatch "^/.*/\.svn/">
187 1593:83412a0a2389 Chris
                Require all denied
188 1570:ae2f71010562 Chris
        </DirectoryMatch>
189
190
        <DirectoryMatch "^/.*/\.hg/">
191 1593:83412a0a2389 Chris
                Require all denied
192 1570:ae2f71010562 Chris
        </DirectoryMatch>
193
194
        <DirectoryMatch "^/.*/\.git/">
195 1593:83412a0a2389 Chris
                Require all denied
196 1570:ae2f71010562 Chris
        </DirectoryMatch>
197
198
        <Directory /var/www/code/public>
199
                Options -MultiViews
200
	</Directory>
201
202
        <Directory /var/www/code/public/themes/soundsoftware/stylesheets/fonts>
203
		# Avoid other sites embedding our fonts
204
		RewriteEngine on
205
		RewriteCond %{HTTP_REFERER} !^$
206
		RewriteCond %{HTTP_REFERER} !^http(s)?://code.soundsoftware.ac.uk/.*$ [NC]
207
		RewriteRule \.(ttf|woff|eot|otf|svg|zip|gz|html|txt)$ - [F]
208
	</Directory>
209
210
	ScriptAlias /hg "/var/hg/index.cgi"
211
212
	<Location /hg>
213
               	AuthName "Mercurial"
214
                AuthType Basic
215
                Require valid-user
216
		PerlAccessHandler Apache::Authn::SoundSoftware::access_handler
217
      		PerlAuthenHandler Apache::Authn::SoundSoftware::authen_handler
218 1601:07deb8466f65 Chris
		PerlSetVar HTTPS "off"
219 1570:ae2f71010562 Chris
		SoundSoftwareDSN "dbi:Pg:database=code;host=localhost"
220
    		SoundSoftwareDbUser "code"
221 1593:83412a0a2389 Chris
     		SoundSoftwareDbPass "INSERT_DATABASE_PASSWORD_HERE"
222 1570:ae2f71010562 Chris
		SoundSoftwareRepoPrefix "/var/hg/"
223 1576:d1de6986e429 Chris
                #!!! "on" in production please!:
224
                SoundSoftwareSslRequired "off"
225 1570:ae2f71010562 Chris
		Options +ExecCGI
226
		AddHandler cgi-script .cgi
227
		ExpiresDefault now
228
        </Location>
229
230
	Alias /git "/var/files/git-mirror"
231
232
	<Directory "/var/files/git-mirror">
233
		Options -Indexes +FollowSymLinks
234 1593:83412a0a2389 Chris
                Require all granted
235 1570:ae2f71010562 Chris
	</Directory>
236
	<Directory ~ "/var/files/git-mirror/.*\.workdir">
237 1593:83412a0a2389 Chris
                Require all denied
238 1570:ae2f71010562 Chris
	</Directory>
239
	<Directory ~ "/var/files/git-mirror/__.*">
240 1593:83412a0a2389 Chris
                Require all denied
241 1570:ae2f71010562 Chris
	</Directory>
242
243
	ErrorLog /var/log/apache2/code-error.log
244
	CustomLog /var/log/apache2/code-access.log vhost_combined
245
246
        LogLevel warn
247
        ServerSignature Off
248
249
</VirtualHost>
250
251 1586:d0d59d12db94 Chris
#!/bin/sh
252 1590:c18460da6620 Chris
253 1586:d0d59d12db94 Chris
outfile="/var/files/backups/postgres-dumpall-`date +%Y%m%d%H%M`"
254 1590:c18460da6620 Chris
255 1586:d0d59d12db94 Chris
oldmask=`umask`
256
umask 0277
257 1590:c18460da6620 Chris
258 1586:d0d59d12db94 Chris
su postgres -c /usr/bin/pg_dumpall > "$outfile" && bzip2 "$outfile"
259 1590:c18460da6620 Chris
260 1586:d0d59d12db94 Chris
umask "$oldmask"
261
#!/bin/bash
262 1590:c18460da6620 Chris
263 1586:d0d59d12db94 Chris
cd /tmp
264 1590:c18460da6620 Chris
265 1586:d0d59d12db94 Chris
/var/www/code/docgen/extract-docs.sh
266 1590:c18460da6620 Chris
267 1586:d0d59d12db94 Chris
#!/bin/bash
268 1590:c18460da6620 Chris
269 1586:d0d59d12db94 Chris
sudo -u code sh -c "cd /var/www/code ; ./script/rails runner -e production extra/soundsoftware/get-statistics.rb >> log/statistics.log"
270 1590:c18460da6620 Chris
271 1586:d0d59d12db94 Chris
#!/bin/bash
272 1590:c18460da6620 Chris
273 1586:d0d59d12db94 Chris
tail -2 /var/log/external-repos.log
274
#!/bin/bash
275
276 1590:c18460da6620 Chris
## No longer used - this site is now static
277
278
# /usr/bin/wget -O - -q -t 1 http://www.soundsoftware.ac.uk/cron.php
279
280 1586:d0d59d12db94 Chris
#!/bin/bash
281 1590:c18460da6620 Chris
282 1586:d0d59d12db94 Chris
sudo -u code sh -c "cd /var/www/code ; ./script/rails runner \"Repository.fetch_changesets\" -e production 2>&1 | grep -v 'Not trusting' | grep -v 'svn:' | grep -v 'working copy' | grep -v 'deprecated' | grep -v 'version_requirements'"
283
exit 0
284 1590:c18460da6620 Chris
285 1586:d0d59d12db94 Chris
#!/bin/bash
286 1590:c18460da6620 Chris
287 1586:d0d59d12db94 Chris
sudo -H -u www-data /var/www/code/reposman/run-external.sh
288 1590:c18460da6620 Chris
289 1586:d0d59d12db94 Chris
#!/bin/sh
290 1590:c18460da6620 Chris
291 1586:d0d59d12db94 Chris
rm -f /var/www/code/tmp/cache/*/*/views*explore*
292
#!/bin/bash
293 1590:c18460da6620 Chris
294 1586:d0d59d12db94 Chris
logfile="/var/www/code/log/export-git.log"
295 1590:c18460da6620 Chris
296 1586:d0d59d12db94 Chris
sudo -u code sh -c "cd /tmp ; /var/www/code/extra/soundsoftware/export-git.sh production /var/hg /var/files/git-mirror >> $logfile 2>&1"
297 1590:c18460da6620 Chris
298 1586:d0d59d12db94 Chris
#!/bin/bash
299 1590:c18460da6620 Chris
300 1586:d0d59d12db94 Chris
sudo -u www-data /var/www/code/reposman/run-reposman.sh
301
302
#!/bin/sh
303 1596:45b0571b684d Chris
cd /
304 1586:d0d59d12db94 Chris
for location in var/www etc/apache2 etc/cron.*; do
305
	target="/var/files/backups/`echo $location | sed 's,/,_,g'`-`date +%Y%m%d%H%M`"
306
	oldmask=`umask`
307
	umask 0277
308
	tar cjf "$target".tar.bz2 "$location"
309
	umask "$oldmask"
310
done
311
312 1570:ae2f71010562 Chris
production:
313
  adapter: postgresql
314
  database: code
315
  host: localhost
316
  username: code
317 1593:83412a0a2389 Chris
  password: "INSERT_DATABASE_PASSWORD_HERE"
318 1570:ae2f71010562 Chris
319 1576:d1de6986e429 Chris
[paths]
320
/ = /var/hg/*
321
322
[web]
323
allow_archive = gz, zip, bz2
324
allow_push = *
325
#!/usr/bin/env python
326
#
327
# An example CGI script to export multiple hgweb repos, edit as necessary
328
329
# adjust python path if not a system-wide install:
330
#import sys
331
#sys.path.insert(0, "/path/to/python/lib")
332
333
# enable importing on demand to reduce startup time
334
from mercurial import demandimport; demandimport.enable()
335
336
# Uncomment to send python tracebacks to the browser if an error occurs:
337
import cgitb
338
cgitb.enable()
339
340
# If you'd like to serve pages with UTF-8 instead of your default
341
# locale charset, you can do so by uncommenting the following lines.
342
# Note that this will cause your .hgrc files to be interpreted in
343
# UTF-8 and all your repo files to be displayed using UTF-8.
344
#
345
import os
346
os.environ["HGENCODING"] = "UTF-8"
347
348
from mercurial.hgweb.hgwebdir_mod import hgwebdir
349
import mercurial.hgweb.wsgicgi as wsgicgi
350
351
# The config file looks like this.  You can have paths to individual
352
# repos, collections of repos in a directory tree, or both.
353
#
354
# [paths]
355
# virtual/path1 = /real/path1
356
# virtual/path2 = /real/path2
357
# virtual/root = /real/root/*
358
# / = /real/root2/*
359
# virtual/root2 = /real/root2/**
360
#
361
# [collections]
362
# /prefix/to/strip/off = /root/of/tree/full/of/repos
363
#
364
# paths example:
365
#
366
# * First two lines mount one repository into one virtual path, like
367
# '/real/path1' into 'virtual/path1'.
368
#
369
# * The third entry mounts every mercurial repository found in '/real/root'
370
# in 'virtual/root'. This format is preferred over the [collections] one,
371
# since using absolute paths as configuration keys is not supported on every
372
# platform (especially on Windows).
373
#
374
# * The fourth entry is a special case mounting all repositories in
375
# /'real/root2' in the root of the virtual directory.
376
#
377
# * The fifth entry recursively finds all repositories under the real root,
378
# and mounts them using their relative path (to given real root) under the
379
# virtual root.
380
#
381
# collections example: say directory tree /foo contains repos /foo/bar,
382
# /foo/quux/baz.  Give this config section:
383
#   [collections]
384
#   /foo = /foo
385
# Then repos will list as bar and quux/baz.
386
#
387
# Alternatively you can pass a list of ('virtual/path', '/real/path') tuples
388
# or use a dictionary with entries like 'virtual/path': '/real/path'
389
390
application = hgwebdir('hgweb.config')
391
wsgicgi.launch(application)
392 1586:d0d59d12db94 Chris
# see "man logrotate" for details
393
# rotate log files weekly
394
weekly
395
396 1590:c18460da6620 Chris
# use the syslog group by default, since this is the owning group
397
# of /var/log/syslog.
398
su root syslog
399
400 1586:d0d59d12db94 Chris
# keep 4 weeks worth of backlogs
401
rotate 4
402
403
# create new (empty) log files after rotating old ones
404
create
405
406
# uncomment this if you want your log files compressed
407
#compress
408
409
# packages drop log rotation information into this directory
410
include /etc/logrotate.d
411
412
# no packages own wtmp, or btmp -- we'll rotate them here
413
/var/log/wtmp {
414
    missingok
415
    monthly
416
    create 0664 root utmp
417
    rotate 1
418
}
419
420
/var/log/btmp {
421
    missingok
422
    monthly
423
    create 0660 root utmp
424
    rotate 1
425
}
426
427
# system-specific logs may be configured here
428
/var/www/code/log/*.log {
429
	weekly
430
	missingok
431
	rotate 52
432
	compress
433
	delaycompress
434
	create 640 code code
435
	sharedscripts
436
	postrotate
437
		touch /var/www/code/restart_files/restart.txt
438
	endscript
439
}
440
441
/var/log/reposman.log {
442
        weekly
443
        missingok
444
        rotate 52
445
        compress
446
        delaycompress
447
        create 640 www-data code
448
        sharedscripts
449
}
450
451
/var/log/external-repos.log {
452
        weekly
453
        missingok
454
        rotate 52
455
        compress
456
        delaycompress
457
        create 640 www-data code
458
        sharedscripts
459
}
460
461 1571:4c2b25b7e85f Chris
PassengerMaxPoolSize 60
462
463
LoadModule passenger_module /var/lib/gems/2.3.0/gems/passenger-4.0.60/buildout/apache2/mod_passenger.so
464
PassengerRoot /var/lib/gems/2.3.0/gems/passenger-4.0.60
465
PassengerDefaultRuby /usr/bin/ruby2.3
466
# Apache::DBI is supposed to be a transparent replacement for Perl DBI with
467
# better performance when multiple connections are made with common DSN, user
468
# and password
469
PerlModule Apache::DBI
470 1590:c18460da6620 Chris
#!/bin/bash
471
logfile=/var/log/external-repos.log
472
(
473
flock -s 200
474
echo >> $logfile
475
date >> $logfile
476
/var/www/code/reposman/convert-external-repos.rb \
477
	-s /var/hg \
478 1593:83412a0a2389 Chris
	-r INSERT_API_SCHEME_HERE://INSERT_API_HOST_HERE/ \
479 1590:c18460da6620 Chris
	-k INSERT_API_KEY_HERE \
480
	-v \
481 1593:83412a0a2389 Chris
	--http-user=INSERT_API_USER_HERE \
482
	--http-pass=INSERT_API_PASSWORD_HERE \
483 1590:c18460da6620 Chris
        -c "/var/www/code/reposman/update-external-repo.sh" \
484
	>> $logfile 2>&1
485
date >> $logfile
486
echo Done >> $logfile
487
)200>>$logfile
488
#!/bin/bash
489
logfile=/var/log/reposman.log
490
(
491
flock -s 200
492
echo >> $logfile
493
/var/www/code/reposman/reposman-soundsoftware.rb \
494
	-s /var/hg \
495 1593:83412a0a2389 Chris
	-r INSERT_API_SCHEME_HERE://INSERT_API_HOST_HERE/ \
496 1590:c18460da6620 Chris
	-k INSERT_API_KEY_HERE \
497 1593:83412a0a2389 Chris
	--http-user=INSERT_API_USER_HERE \
498
	--http-pass=INSERT_API_PASSWORD_HERE \
499 1590:c18460da6620 Chris
	-o www-data \
500
	-g code \
501
	-c "/var/www/code/reposman/run-hginit.sh" \
502
	--scm=Mercurial \
503
	>> $logfile 2>&1
504
)200>>$logfile
505 1606:16325d2ab2dd Chris
<VirtualHost *:80>
506
        ServerName soundsoftware.ac.uk
507
	ServerAlias www.soundsoftware.ac.uk
508
        ServerAdmin chris.cannam@eecs.qmul.ac.uk
509
510
        DocumentRoot /var/www/soundsoftware-static/soundsoftware.ac.uk
511
512
	ErrorLog /var/log/apache2/soundsoftware-error.log
513
	CustomLog /var/log/apache2/soundsoftware-access.log vhost_combined
514
515
	<Directory /var/www/soundsoftware-static/soundsoftware.ac.uk>
516
		RewriteEngine on
517
		RewriteCond %{REQUEST_FILENAME} !-d
518
		RewriteCond %{REQUEST_FILENAME}\.html -f
519
		RewriteRule ^(.*)$ $1.html
520
	</Directory>
521
522
	<FilesMatch "^.*\.(install|inc)$">
523
	     Order Deny,Allow
524
	     deny from all
525
	</FilesMatch>
526
527
        <DirectoryMatch "\.(hg|svn|git)">
528
                Order allow,deny
529
                Deny from all
530
                Satisfy All
531
        </DirectoryMatch>
532
533
	LogLevel warn
534
	ServerSignature Off
535
</VirtualHost>
536
537
<VirtualHost *:443>
538
	# We don't serve SSL: redirect to the code site
539
	ServerName soundsoftware.ac.uk
540
        ServerAlias www.soundsoftware.ac.uk
541
        ServerAdmin chris.cannam@eecs.qmul.ac.uk
542
543
	SSLEngine on
544
	SSLCertificateFile /etc/apache2/certs/code.soundsoftware.ac.uk.crt
545
	SSLCertificateKeyFile /etc/apache2/certs/code.soundsoftware.ac.uk.key
546
	SSLCertificateChainFile /etc/apache2/certs/code.soundsoftware.ac.uk.ca-bundle
547
	SSLVerifyClient none
548
	SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM:+LOW
549
550
        DocumentRoot /var/www/soundsoftware-static/soundsoftware.ac.uk
551
552
	Redirect permanent / https://code.soundsoftware.ac.uk/
553
554
        ErrorLog /var/log/apache2/code-error.log
555
        CustomLog /var/log/apache2/code-access.log vhost_combined
556
557
        LogLevel warn
558
        ServerSignature Off
559
</VirtualHost>