Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
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...
commit 2a2b02e5e7a4537f1cf5eca6fbe64f1d2ab580a4 1 parent 363ebb5
@benschwarz authored
Showing with 62 additions and 1 deletion.
  1. +6 −1 config/install.rb
  2. +56 −0 config/stack/{server.rb → apache.rb}
View
7 config/install.rb
@@ -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
View
56 config/stack/server.rb → config/stack/apache.rb
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.