Permalink
Browse files

Added special installers for gzipping, etags and expires headers.

Renamed server.rb to apache.rb cause there's no coming back from here.
  • Loading branch information...
1 parent 363ebb5 commit 2a2b02e5e7a4537f1cf5eca6fbe64f1d2ab580a4 @benschwarz committed Mar 3, 2009
Showing with 62 additions and 1 deletion.
  1. +6 −1 config/install.rb
  2. +56 −0 config/stack/{server.rb → apache.rb}
View
@@ -1,5 +1,5 @@
# Require our stack
-%w(essential server scm ruby_enterprise memcached postgresql mysql).each do |r|
+%w(essential apache scm ruby_enterprise memcached postgresql mysql).each do |r|
require File.join(File.dirname(__FILE__), 'stack', r)
end
@@ -8,6 +8,11 @@
# Build up your own and strip down your server until you get it right.
policy :passenger_stack, :roles => :app do
requires :webserver # Apache
+
+ requires :apache_etag_support # == Apache extras
+ requires :apache_deflate_support # Read about these specialties in
+ requires :apache_expires_support # stack/apache.rb
+
requires :appserver # Passenger
requires :ruby_enterprise # Ruby Enterprise edition
requires :database # MySQL or Postgres
@@ -44,4 +44,60 @@
end
requires :apache, :apache2_prefork_dev, :ruby_enterprise
+end
+
+# These "installers" are strictly optional, I believe
+# that everyone should be doing this to serve sites more quickly.
+# Simple wins.
+
+# Enable ETags
+package :apache_etag_support do
+ apache_conf = "/etc/apache2/apache2.conf"
+ config = <<eol
+ # Passenger-stack-etags
+ FileETag MTime Size
+eol
+
+ push_text config, apache_conf, :sudo => true
+ verify { file_contains apache_conf, "Passenger-stack-etags"}
+ requires :apache
+end
+
+# mod_deflate, compress scripts before serving.
+package :apache_deflate_support do
+ apache_conf = "/etc/apache2/apache2.conf"
+ config = <<eol
+ # Passenger-stack-deflate
+ <IfModule mod_deflate.c>
+ # compress content with type html, text, and css
+ AddOutputFilterByType DEFLATE text/css text/html text/javascript application/javascript application/x-javascript text/js
+ <IfModule mod_headers.c>
+ # properly handle requests coming from behind proxies
+ Header append Vary User-Agent
+ </IfModule>
+ </IfModule>
+eol
+
+ push_text config, apache_conf, :sudo => true
+ verify { file_contains apache_conf, "Passenger-stack-deflate"}
+ requires :apache
+end
+
+# mod_expires, add long expiry headers to css, js and image files
+package :apache_expires_support do
+ apache_conf = "/etc/apache2/apache2.conf"
+
+ config = <<eol
+ # Passenger-stack-expires
+ <ifmodule mod_expires.c>
+ <filesmatch "\.(jpg|gif|png|css|js)$">
+ ExpiresActive on
+ ExpiresDefault "access plus 1 year"
+ </filesmatch>
+ </ifmodule>
+eol
+
+ push_text config, apache_conf, :sudo => true
+ verify { file_contains apache_conf, "Passenger-stack-expires"}
+ requires :apache
end

0 comments on commit 2a2b02e

Please sign in to comment.