Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

353 lines (300 sloc) 13.96 kb
<VirtualHost *:80>
ServerName <%= configuration[:domain] || (Facter.to_hash["hostname"] + '.' + Facter.to_hash["domain"]) %>
<% if configuration[:domain_aliases] %>
ServerAlias <%= configuration[:domain_aliases].to_a.join(' ') %>
<% end %>
<% if configuration[:passenger].nil? || configuration[:passenger][:version].nil? || (configuration[:passenger][:version] == :latest || configuration[:passenger][:version] > '3.0.4') %>
<% if configuration[:union_station] && configuration[:union_station][:key] %>
UnionStationSupport on
UnionStationKey <%= configuration[:union_station][:key] %>
<% configuration[:union_station][:filters].to_a.each do |us_filter| %>
UnionStationFilter "<%= us_filter %>"
<% end %>
<% end %>
<% end %>
<% if configuration[:ssl] && configuration[:ssl][:only] %>
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteCond %{REQUEST_URI} !^/server-status
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
<% else %>
DocumentRoot <%= configuration[:deploy_to] + "/current/public" %>
<Directory <%= configuration[:deploy_to] + "/current/public" %>>
Options FollowSymLinks
AllowOverride <%= if configuration[:apache]; configuration[:apache][:allow_override] || 'None'; else 'None'; end %>
Order allow,deny
Allow from all
<%= "FileETag #{configuration[:apache][:file_etag]}" if configuration[:apache][:file_etag] %>
</Directory>
<% if configuration[:apache ] && (configuration[:apache][:users] || configuration[:apache][:allow] || configuration[:apache][:deny]) %>
<Location / >
<% if configuration[:apache][:users] %>
authtype basic
authuserfile <%= configuration[:apache][:htpasswd] || "#{configuration[:deploy_to]}/shared/config/htpasswd" %>
authname "<%= configuration[:authname] || configuration[:domain] %>"
<% end %>
<Limit GET POST DELETE PUT>
order deny,allow
<% if configuration[:apache][:users] || configuration[:apache][:allow] %>
deny from all
<% end %>
<% configuration[:apache][:deny].to_a.each do |deny| %>
deny from <%= deny %>
<% end %>
<% configuration[:apache][:allow].to_a.each do |allow| %>
allow from <%= allow %>
<% end %>
<% if configuration[:apache][:users] %>
require valid-user
<% end %>
Satisfy <%= configuration[:apache][:satisfy] || 'Any' %>
</Limit>
</Location>
<% end %>
##
## The following options are Rails specific options. They may occur
## here in your VirtualHost entry or in the global configuration.
##
## RailsAutoDetect
#
# Set whether Phusion Passenger should automatically detect whether
# a virtual host's document root is a Ruby on Rails application.
# The default is on.
# Options: <on|off>
RailsAutoDetect <%= passenger_config_boolean(configuration[:passenger][:rails_auto_detect]) %>
## RailsBaseURI
#
# Specify that the given URI is a Rails application. It is allowed to
# specify this option multiple times. Do this to deploy multiple
# Rails applications in different sub-URIs under the same virtual host.
<% if configuration[:passenger][:rails_base_uri] %>
RailsBaseURI <%= configuration[:passenger][:rails_base_uri] %>
<% else %>
# RailsBaseURI <uri>
<% end %>
<% if configuration[:passenger][:allow_mod_rewrite] %>
## RailsAllowModRewrite
#
# Passenger will not override mod_rewrite rules if this option
# is enabled. This option is deprecated and ignored in recent versions
# of Passenger.
# Options: <on|off>
RailsAllowModRewrite <%= passenger_config_boolean(configuration[:passenger][:allow_mod_rewrite]) %>
<% else %>
# RailsAllowModRewrite is deprecated. Passenger supports mod_rewrite by default now. configure(:passenger => { :allow_mod_rewrite => true/false }) if you still wish to use it.
<% end %>
## RackEnv
#
# Use this option to specify the default RACK_ENV value. The default
# setting is production.
RackEnv <%= configuration[:passenger][:rails_env] || ENV['RAILS_ENV'] || 'production' %>
## RailsEnv
#
# Use this option to specify the default RAILS_ENV value. The default
# setting is production.
RailsEnv <%= configuration[:passenger][:rails_env] || ENV['RAILS_ENV'] || 'production' %>
## RailsSpawnMethod
#
# Internally, Phusion Passenger spawns multiple Ruby on Rails processes
# in order to handle requests. But there are multiple ways with which
# processes can be spawned, each having its own set of pros and cons.
# Supported spawn methods are:
# smart
# When this spawn method is used, Phusion Passenger will attempt
# to cache Ruby on Rails framework code and application code for
# a limited period of time.
#
# conservative
# This spawning method is similar to the one used in Mongrel Cluster.
# It does not perform any code caching at all.
RailsSpawnMethod <%= configuration[:passenger][:rails_spawn_method] || 'smart' %>
# Deflate
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE <%= configuration[:apache][:gzip_types].join(' ') %>
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
</IfModule>
RewriteEngine On
<%= configuration[:passenger][:vhost_extra] %>
<% if configuration[:scm].to_s == 'subversion' %>
# Prevent access to svn metadata
RewriteRule ^(.*/)?\.svn/ - [F,L]
ErrorDocument 403 "Access Forbidden"
<% end %>
<% if configuration[:passenger][:maintenance_rewrite] %>
<%= configuration[:passenger][:maintenance_rewrite] %>
<% else %>
# Check for maintenance file and redirect all requests
RewriteCond %{REQUEST_URI} !\.(css|jpg|png|gif)$
RewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f
RewriteRule ^.*$ /system/maintenance.html [L]
<% end %>
# Rewrite index to check for static
RewriteCond %{THE_REQUEST} ^(GET|HEAD)
RewriteCond %{DOCUMENT_ROOT}<%= configuration[:passenger][:page_cache_directory] %>/index.html -f
RewriteRule ^/?$ <%= configuration[:passenger][:page_cache_directory] %>/index.html [QSA,L]
# Rewrite to check for Rails non-html cached pages (i.e. xml, json, atom, etc)
RewriteCond %{THE_REQUEST} ^(GET|HEAD)
RewriteCond %{DOCUMENT_ROOT}<%= configuration[:passenger][:page_cache_directory] %>%{REQUEST_URI} -f
RewriteRule ^(.*)$ <%= configuration[:passenger][:page_cache_directory] %>$1 [QSA,L]
# Rewrite to check for Rails cached html page
RewriteCond %{THE_REQUEST} ^(GET|HEAD)
RewriteCond %{DOCUMENT_ROOT}<%= configuration[:passenger][:page_cache_directory] %>%{REQUEST_URI}.html -f
RewriteRule ^(.*)$ <%= configuration[:passenger][:page_cache_directory] %>$1.html [QSA,L]
<% end %>
</VirtualHost>
<% if configuration[:ssl] %>
<VirtualHost <%= configuration[:ssl][:ip] || '_default_' %>:443>
RequestHeader set X_FORWARDED_PROTO "https"
SSLEngine on
SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL
SSLCertificateFile <%= configuration[:ssl][:certificate_file] || '/etc/ssl/certs/ssl-cert-snakeoil.pem' %>
SSLCertificateKeyFile <%= configuration[:ssl][:certificate_key_file] || '/etc/ssl/private/ssl-cert-snakeoil.key' %>
<% if configuration[:ssl][:certificate_chain_file] %>
SSLCertificateChainFile <%= configuration[:ssl][:certificate_chain_file] %>
<% else %>
# SSLCertificateChainFile /etc/apache2/ssl.crt/server-ca.crt
<% end %>
<% if configuration[:ssl][:protocol] %>
SSLProtocol <%= configuration[:ssl][:protocol] %>
<% end %>
BrowserMatch ".*MSIE.*" nokeepalive ssl-unclean-shutdown downgrade-1.0 force-response-1.0
ServerName <%= configuration[:domain] || (Facter.to_hash["hostname"] + '.' + Facter.to_hash["domain"]) %>
<% if configuration[:domain_aliases] %>
ServerAlias <%= configuration[:domain_aliases].to_a.join(' ') %>
<% end %>
DocumentRoot <%= configuration[:deploy_to] + "/current/public" %>
<% if configuration[:passenger].nil? || configuration[:passenger][:version].nil? || (configuration[:passenger][:version] == :latest || configuration[:passenger][:version] > '3.0.4') %>
<% if configuration[:union_station] && configuration[:union_station][:key] %>
UnionStationSupport on
UnionStationKey <%= configuration[:union_station][:key] %>
<% configuration[:union_station][:filters].to_a.each do |us_filter| %>
UnionStationFilter "<%= us_filter %>"
<% end %>
<% end %>
<% end %>
<Directory <%= configuration[:deploy_to] + "/current/public" %>>
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
<%= "FileETag #{configuration[:apache][:file_etag]}" if configuration[:apache][:file_etag] %>
</Directory>
<% if configuration[:apache ] and (configuration[:apache][:users] || configuration[:apache][:allow] || configuration[:apache][:deny]) %>
<Location / >
<% if configuration[:apache][:users] %>
authtype basic
authuserfile <%= configuration[:apache][:htpasswd] || "#{configuration[:deploy_to]}/shared/config/htpasswd" %>
authname "<%= configuration[:authname] || configuration[:domain] %>"
<% end %>
<Limit GET POST DELETE PUT>
order deny,allow
<% if configuration[:apache][:users] || configuration[:apache][:allow] %>
deny from all
<% end %>
<% configuration[:apache][:deny].to_a.each do |deny| %>
deny from <%= deny %>
<% end %>
<% configuration[:apache][:allow].to_a.each do |allow| %>
allow from <%= allow %>
<% end %>
<% if configuration[:apache][:users] %>
require valid-user
<% end %>
Satisfy <%= configuration[:apache][:satisfy] || 'Any' %>
</Limit>
</Location>
<% end %>
##
## The following options are Rails specific options. They may occur
## here in your VirtualHost entry or in the global configuration.
##
## RailsAutoDetect
#
# Set whether Phusion Passenger should automatically detect whether
# a virtual host's document root is a Ruby on Rails application.
# The default is on.
# Options: <on|off>
RailsAutoDetect <%= passenger_config_boolean(configuration[:passenger][:rails_auto_detect]) %>
## RailsBaseURI
#
# Specify that the given URI is a Rails application. It is allowed to
# specify this option multiple times. Do this to deploy multiple
# Rails applications in different sub-URIs under the same virtual host.
<% if configuration[:passenger][:rails_base_uri] %>
RailsBaseURI <%= configuration[:passenger][:rails_base_uri] %>
<% else %>
# RailsBaseURI <uri>
<% end %>
<% if configuration[:passenger][:allow_mod_rewrite] %>
## RailsAllowModRewrite
#
# Passenger will not override mod_rewrite rules if this option
# is enabled. This option is deprecated and ignored in recent versions
# of Passenger.
# Options: <on|off>
RailsAllowModRewrite <%= passenger_config_boolean(configuration[:passenger][:allow_mod_rewrite]) %>
<% else %>
# RailsAllowModRewrite is deprecated. Passenger supports mod_rewrite by default now. configure(:passenger => { :allow_mod_rewrite => true/false }) if you still wish to use it.
<% end %>
## RailsEnv
#
# Use this option to specify the default RAILS_ENV value. The default
# setting is production.
RailsEnv <%= configuration[:passenger][:rails_env] || ENV['RAILS_ENV'] || 'production' %>
## RailsSpawnMethod
#
# Internally, Phusion Passenger spawns multiple Ruby on Rails processes
# in order to handle requests. But there are multiple ways with which
# processes can be spawned, each having its own set of pros and cons.
# Supported spawn methods are:
# smart
# When this spawn method is used, Phusion Passenger will attempt
# to cache Ruby on Rails framework code and application code for
# a limited period of time.
#
# conservative
# This spawning method is similar to the one used in Mongrel Cluster.
# It does not perform any code caching at all.
RailsSpawnMethod <%= configuration[:passenger][:rails_spawn_method] || 'smart' %>
# Deflate
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE <%= configuration[:apache][:gzip_types].join(' ') %>
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
</IfModule>
RewriteEngine On
<% if configuration[:ssl] %>
<%= configuration[:ssl][:vhost_extra] %>
<% else %>
<%= configuration[:passenger][:vhost_extra] %>
<% end %>
<% if configuration[:scm].to_s == 'subversion' %>
# Prevent access to svn metadata
RewriteRule ^(.*/)?\.svn/ - [F,L]
ErrorDocument 403 "Access Forbidden"
<% end %>
<% if configuration[:passenger][:maintenance_rewrite] %>
<%= configuration[:passenger][:maintenance_rewrite] %>
<% else %>
# Check for maintenance file and redirect all requests
RewriteCond %{REQUEST_URI} !\.(css|jpg|png|gif)$
RewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f
RewriteRule ^.*$ /system/maintenance.html [L]
<% end %>
# Rewrite index to check for static
RewriteCond %{THE_REQUEST} ^(GET|HEAD)
RewriteCond %{DOCUMENT_ROOT}<%= configuration[:passenger][:page_cache_directory] %>/index.html -f
RewriteRule ^/?$ <%= configuration[:passenger][:page_cache_directory] %>/index.html [QSA,L]
# Rewrite to check for Rails non-html cached pages (i.e. xml, json, atom, etc)
RewriteCond %{THE_REQUEST} ^(GET|HEAD)
RewriteCond %{DOCUMENT_ROOT}<%= configuration[:passenger][:page_cache_directory] %>%{REQUEST_URI} -f
RewriteRule ^(.*)$ <%= configuration[:passenger][:page_cache_directory] %>$1 [QSA,L]
# Rewrite to check for Rails cached html page
RewriteCond %{THE_REQUEST} ^(GET|HEAD)
RewriteCond %{DOCUMENT_ROOT}<%= configuration[:passenger][:page_cache_directory] %>%{REQUEST_URI}.html -f
RewriteRule ^(.*)$ <%= configuration[:passenger][:page_cache_directory] %>$1.html [QSA,L]
</VirtualHost>
<% end %>
Jump to Line
Something went wrong with that request. Please try again.