config/httpd.conf-example
# 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
# Uncomment the following line if you want to run Alaveteli
# with the ruby set by rbenv
# PassengerRuby /home/alaveteli/.rbenv/shims/ruby
# 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
# Require bundler so correct versions gems that shipped with Ruby are
# loaded
SetEnv RUBYOPT "-r bundler/setup"
</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>
# Favicon in the Rails asset pipeline are served from /assets/favicon.ico yet we
# still get requests for it in the root directory.
RewriteRule ^/favicon\.ico$ /assets/favicon.ico [L]
# 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.
#
# The second condition-rule pair handles the same transformation for
# files served from a non-default locale, 'cy'. You will need one
# set of rules for each non-default locale.
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]
# Don't allow anything to execute from the cache
<Directory "/var/www/alaveteli/public/views_cache">
Options -ExecCGI
SetHandler default-handler
AllowOverride None
</Directory>
# 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 year"
</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
IncludeOptional vhost.d/alaveteli/*.conf
</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>