Skip to content

Commit

Permalink
Added special installers for gzipping, etags and expires headers.
Browse files Browse the repository at this point in the history
Renamed server.rb to apache.rb cause there's no coming back from here.
  • Loading branch information
benschwarz committed Mar 4, 2009
1 parent 363ebb5 commit 2a2b02e
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 1 deletion.
7 changes: 6 additions & 1 deletion config/install.rb
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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
Expand Down
56 changes: 56 additions & 0 deletions config/stack/server.rb → config/stack/apache.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.