blob: 9736cafff044b05cd34d7ca5779feabcd9a4d41b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
|
# Redirect other domains to canonical domain
<VirtualHost *:80>
ServerName example.com
ServerAlias example.org
ServerAlias www.example.org
RedirectPermanent / http://www.example.com/
</VirtualHost>
# Canonical domain vHost
<VirtualHost *:80>
ServerName www.example.com
ServerAdmin webmaster@example.com
DocumentRoot /var/www/alaveteli/public
# TODO: Remove this and use PassengerUser when supported
# This is the user that runs the rails application processes
SuExecUserGroup alaveteli alaveteli
RewriteEngine On
ErrorLog /var/log/apache2/alaveteli_error.log
CustomLog /var/log/apache2/alaveteli_access.log combined
# App server configuration
<IfModule mod_passenger.c>
PassengerAppRoot /var/www/alaveteli
PassengerResolveSymlinksInDocumentRoot on
# See http://blog.phusion.nl/2013/03/12/tuning-phusion-passengers-concurrency-settings/
# and http://blog.scoutapp.com/articles/2009/12/08/production-rails-tuning-with-passenger-passengermaxprocesses
# for more information on tuning Passenger
# Set this to something like 100 if you have memory leak issues
PassengerMaxRequests 2000
# Passenger's default MaxPoolSize is 6. At the time of writing
# normal instances of Alaveteli seem to take 150-200MB per
# process, so we've set this conservatively at 3. Read the guides
# above to tune this for your system
PassengerMaxPoolSize 3
# The RAILS_ENV that the app is running in. This can be any of
# the environments listed in APP_ROOT/config/environments.
RailsEnv production
RackEnv production
</IfModule>
# This is your Rails app's public directory
<Directory "/var/www/alaveteli/public">
Options +ExecCGI -MultiViews
AllowOverride All
</Directory>
# Maintenance Page
# Make a file down.html in the DocumentRoot to bring down the whole
# site and display itself.
RewriteEngine on
ErrorDocument 503 /down.html
Redirect 503 /down
# If down.html exists, and that's what's been asked for,
# just hand it over
RewriteCond %{DOCUMENT_ROOT}/down.html -s
RewriteRule /down.html /down.html [L]
RewriteCond %{DOCUMENT_ROOT}/down.html -s
RewriteRule /(.+).cgi /down [PT]
RewriteCond %{DOCUMENT_ROOT}/down.html -s
RewriteRule /(.+).php /down [PT]
# Mainly for Rails/Django type sites - anything without a . can go down
# TODO: could we just check that it is an HTML content-type?
RewriteCond %{DOCUMENT_ROOT}/down.html -s
RewriteRule /([^.]*)$ /down [PT]
# END Maintenance Page
# Set the Sendfile header and switch sendfile on - Apache will
# now handle send_file calls from Alaveteli
<Location />
<IfModule mod_xsendfile.c>
RequestHeader Set X-Sendfile-Type X-Sendfile
XSendFile On
XSendFilePath /var/www/alaveteli/public
</IfModule>
</Location>
# Commonlib is typically found in alaveteli/commonlib
Alias /jslib/ "/var/www/alaveteli/commonlib/jslib"
<Directory "/var/www/alaveteli/commonlib/jslib">
Options +ExecCGI
AddHandler fastcgi-script .cgi
</Directory>
# Serve attachments directly from the cache, if possible.
#
# The file names are URL-encoded on disk, and sharded by the first
# three digits of the request id, which is why this is as complicated
# as it is. The RewriteMap directive makes the URL-escaping function
# available to use in the other directives.
#
# The condition means that the rule will fire only if the cached
# file exists.
RewriteMap escape int:escape
RewriteCond %{DOCUMENT_ROOT}/views_cache/request/$2/$1/${escape:$3} -f
RewriteRule ^/request/((\d{1,3})\d*)/(response/\d+/attach/(html/)?\d+/.+) /views_cache/request/$2/$1/${escape:$3} [L]
RewriteCond %{DOCUMENT_ROOT}/views_cache/cy/request/$2/$1/${escape:$3} -f
RewriteRule ^/cy/request/((\d{1,3})\d*)/(response/\d+/attach/(html/)?\d+/.+) /views_cache/cy/request/$2/$1/${escape:$3} [L]
# Compress assets
<Location />
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/css application/javascript text/plain
</IfModule>
</Location>
# Cache assets
ExpiresActive On
<LocationMatch "^/(assets).*\.(ico|gif|jpe?g|png|js|css|svg|ttf|otf|eot|woff)$">
ExpiresDefault "access plus 1 day"
</LocationMatch>
# Compress font resources
<IfModule mod_deflate.c>
<IfModule mod_mime.c>
Addtype font/opentype .otf
Addtype font/opentype .woff
Addtype font/eot .eot
Addtype font/truetype .ttf
</IfModule>
AddOutputFilterByType DEFLATE font/opentype font/truetype font/eot
AddOutputFilterByType DEFLATE image/svg+xml
</IfModule>
# Include optional configuration
Include vhost.d/alaveteli
</VirtualHost>
# Large / static files for WhatDoTheyKnow. Used for manual sysadmin uploads.
# Is on its own files.example.com subdomain (instead of old /files URL)
# as mod_alias doesn't work with Passenger.
# <VirtualHost *:80>
# ServerName files.example.com
# DocumentRoot /var/www/alaveteli/files
# <Directory "/var/www/alaveteli/files">
# Options +Indexes
# </Directory>
# </VirtualHost>
|