aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--config/httpd-vhost.conf-example161
1 files changed, 161 insertions, 0 deletions
diff --git a/config/httpd-vhost.conf-example b/config/httpd-vhost.conf-example
new file mode 100644
index 000000000..fbdc2db23
--- /dev/null
+++ b/config/httpd-vhost.conf-example
@@ -0,0 +1,161 @@
+# 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 /srv/www.example.com/
+
+ # TODO: Remove this and use PassengerUser
+ SuExecUserGroup foi foi
+
+ ErrorLog /var/log/httpd/www.example.com/error_log
+ CustomLog /var/log/httpd/www.example.com/access_log combined
+
+ # App server configuration
+ <IfModule mod_passenger.c>
+ PassengerAppRoot /opt/alaveteli
+ PassengerUser passenger
+ PassengerGroup alaveteli
+
+ # Set this to something like 100 if you have memory leak issues
+ PassengerMaxRequests 2000
+ PassengerResolveSymlinksInDocumentRoot on
+ PassengerMinInstances 3
+ PassengerMaxPoolSize 6
+
+ RailsEnv production
+ RackEnv production
+ </IfModule>
+
+ # This is your Rails app's public directory
+ <Directory "/srv/www.example.com/">
+ Options +ExecCGI -MultiViews
+ AllowOverride All
+ AddHandler fastcgi-script .cgi
+ AddType application/x-httpd-fastphp .php
+ Action application/x-httpd-fastphp /fcgi/php-basic
+ </Directory>
+
+ RewriteEngine On
+
+ # Rewrite all proxied HTTP requests to HTTPS.
+ RewriteCond %{HTTP:X-Forwarded-Proto} !https
+ RewriteRule /(.*) https://www.example.com/$1 [L,R=permanent]
+
+ # TODO: do we need this now we use Passenger?
+ # Pass through the HTTP basic authentication to mongrel. See also
+ # admin_http_auth_user in app/controllers/application.rb
+ # Note: Apache 2 only. Doesn't work in Apache 1.3, you'll need to live without
+ # it.
+ RewriteCond %{LA-U:REMOTE_USER} (.+)
+ RewriteRule . - [E=RU:%1]
+ RequestHeader add X-Forwarded-User %{RU}e
+
+ # 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
+
+ # This is needed for the PHP spell checker
+ <Location /fcgi>
+ Options +ExecCGI
+ SetHandler fastcgi-script
+ </Location>
+
+ # 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 /srv/www.example.com
+ </IfModule>
+ </Location>
+
+ # Commonlib is typically found in alaveteli/commonlib
+ Alias /jslib/ "/srv/www.example.com/jslib"
+ <Directory "/srv/www.example.com/commonlib/jslib">
+ Options +ExecCGI
+ AddHandler fastcgi-script .cgi
+ AddType application/x-httpd-fastphp .php
+ Action application/x-httpd-fastphp /fcgi/php-basic
+ </Directory>
+
+ Alias /files/ "/srv/www.example.com/files/"
+
+ # 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>
+
+ # 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>
+
+ # Cache assets
+ ExpiresActive On
+ <LocationMatch "^/(images|javascripts|stylesheets).*\.(ico|gif|jpe?g|png|js|css|svg|ttf|otf|eot|woff)$">
+ ExpiresDefault "access plus 1 day"
+ </LocationMatch>
+
+</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 /srv/files.example.com/files
+ <Directory "/srv/files.example.com/files">
+ Options +Indexes
+ </Directory>
+</VirtualHost>