railsmachine-railsmachine 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,108 @@
1
+ require 'railsmachine/recipes'
2
+
3
+ # This defines a deployment "recipe" that you can feed to capistrano
4
+ # (http://manuals.rubyonrails.com/read/book/17). It allows you to automate
5
+ # (among other things) the deployment of your application.
6
+
7
+ # =============================================================================
8
+ # REQUIRED VARIABLES
9
+ # =============================================================================
10
+ # You must always specify the application and repository for every recipe. The
11
+ # repository must be the URL of the repository you want this recipe to
12
+ # correspond to. The deploy_to path must be the path on each machine that will
13
+ # form the root of the application path.
14
+
15
+ # The name of your application. Used for directory and file names associated with
16
+ # the application.
17
+ set :application, "<%= singular_name %>"
18
+
19
+ # Target directory for the application on the web and app servers.
20
+ set :deploy_to, "/var/www/apps/#{application}"
21
+
22
+ # Primary domain name of your application. Used as a default for all server roles.
23
+ set :domain, "<%= domain_name %>"
24
+
25
+ # Login user for ssh.
26
+ set :user, "deploy"
27
+ set :runner, user
28
+ set :admin_runner, user
29
+
30
+ # Rails environment. Used by application setup tasks and migrate tasks.
31
+ set :rails_env, "production"
32
+
33
+ # Automatically symlink these directories from curent/public to shared/public.
34
+ # set :app_symlinks, %w{photo document asset}
35
+
36
+ # =============================================================================
37
+ # ROLES
38
+ # =============================================================================
39
+ # You can define any number of roles, each of which contains any number of
40
+ # machines. Roles might include such things as :web, or :app, or :db, defining
41
+ # what the purpose of each machine is. You can also specify options that can
42
+ # be used to single out a specific subset of boxes in a particular role, like
43
+ # :primary => true.
44
+
45
+ # Modify these values to execute tasks on a different server.
46
+ role :web, domain
47
+ role :app, domain
48
+ role :db, domain, :primary => true
49
+ role :scm, domain
50
+
51
+
52
+ # =============================================================================
53
+ # APPLICATION SERVER OPTIONS
54
+ # =============================================================================
55
+ # set :app_server, "passenger" # mongrel or passenger
56
+
57
+ # =============================================================================
58
+ # WEB SERVER OPTIONS
59
+ # =============================================================================
60
+ # set :httpd, "apache" # apache
61
+ # set :apache_server_name, domain
62
+ # set :apache_server_aliases, %w{alias1 alias2}
63
+ # set :apache_default_vhost, true # force use of apache_default_vhost_config
64
+ # set :apache_default_vhost_conf, "/etc/httpd/conf/default.conf"
65
+ # set :apache_conf, "/etc/httpd/conf/apps/#{application}.conf"
66
+ # set :apache_proxy_port, 8000
67
+ # set :apache_proxy_servers, 2
68
+ # set :apache_proxy_address, "127.0.0.1"
69
+ # set :apache_ssl_enabled, false
70
+ # set :apache_ssl_ip, "127.0.0.1"
71
+ # set :apache_ssl_forward_all, false
72
+ # set :apache_ctl, "/etc/init.d/httpd"
73
+
74
+
75
+
76
+ # =============================================================================
77
+ # MONGREL OPTIONS
78
+ # =============================================================================
79
+ # set :mongrel_servers, apache_proxy_servers
80
+ # set :mongrel_port, apache_proxy_port
81
+ # set :mongrel_address, apache_proxy_address
82
+ # set :mongrel_environment, "production"
83
+ # set :mongrel_pid_file, "/var/run/mongrel_cluster/#{application}.pid"
84
+ # set :mongrel_conf, "/etc/mongrel_cluster/#{application}.conf"
85
+ # set :mongrel_user, user
86
+ # set :mongrel_group, group
87
+
88
+ # =============================================================================
89
+ # DATABASE OPTIONS
90
+ # =============================================================================
91
+ # set :database, "mysql" # mysql or postgresql
92
+
93
+ # =============================================================================
94
+ # SCM OPTIONS
95
+ # =============================================================================
96
+ # set :scm, :subversion # :subversion or :git
97
+
98
+ # =============================================================================
99
+ # SSH OPTIONS
100
+ # =============================================================================
101
+ # ssh_options[:keys] = %w(/path/to/my/key /path/to/another/key)
102
+ # ssh_options[:port] = 25
103
+
104
+ # =============================================================================
105
+ # CAPISTRANO OPTIONS
106
+ # =============================================================================
107
+ # default_run_options[:pty] = true
108
+ # set :keep_releases, 3
@@ -0,0 +1,28 @@
1
+ Capistrano::Configuration.instance(:must_exist).load do
2
+ load 'config/deploy'
3
+ namespace :deploy do
4
+
5
+ desc <<-DESC
6
+ #{app_server.to_s == 'mongrel' ? "Start the mongrel processes on the app server." : "This task no effect when using Passenger as your application server."}
7
+ DESC
8
+ task :start, :roles => :app do
9
+ application_servlet.start
10
+ end
11
+
12
+ desc <<-DESC
13
+ Restart the #{app_server} processes on the app server.
14
+ DESC
15
+ task :restart, :roles => :app do
16
+ application_servlet.restart
17
+ end
18
+
19
+ desc <<-DESC
20
+ #{app_server.to_s == 'mongrel' ? "Stop the mongrel processes on the app server." : "This task no effect when using Passenger as your application server."}
21
+ DESC
22
+ task :stop, :roles => :app do
23
+ application_servlet.stop
24
+ end
25
+
26
+ end
27
+
28
+ end
@@ -0,0 +1,120 @@
1
+ Capistrano::Configuration.instance(:must_exist).load do
2
+ set :mongrel_servers, 2
3
+ set :mongrel_port, 8000
4
+ set :mongrel_address, "127.0.0.1"
5
+ set :mongrel_environment, "production"
6
+ set :mongrel_conf, nil
7
+ set :mongrel_user, nil
8
+ set :mongrel_group, nil
9
+ set :mongrel_prefix, nil
10
+ set :mongrel_rails, 'mongrel_rails'
11
+ set :mongrel_clean, false
12
+ set :mongrel_pid_file, nil
13
+ set :mongrel_log_file, nil
14
+ set :mongrel_config_script, nil
15
+
16
+ load 'config/deploy'
17
+
18
+ namespace :mongrel do
19
+
20
+ namespace :cluster do
21
+
22
+ desc <<-DESC
23
+ Configure Mongrel processes on the app server. This uses the :use_sudo
24
+ variable to determine whether to use sudo or not. By default, :use_sudo is
25
+ set to true.
26
+ DESC
27
+ task :configure, :roles => :app do
28
+ set_mongrel_conf
29
+ set_mongrel_pid_file
30
+
31
+ argv = []
32
+ argv << "#{mongrel_rails} cluster::configure"
33
+ argv << "-N #{mongrel_servers.to_s}"
34
+ argv << "-p #{mongrel_port.to_s}"
35
+ argv << "-e #{mongrel_environment}"
36
+ argv << "-a #{mongrel_address}"
37
+ argv << "-c #{current_path}"
38
+ argv << "-C #{mongrel_conf}"
39
+ argv << "-P #{mongrel_pid_file}"
40
+ argv << "-l #{mongrel_log_file}" if mongrel_log_file
41
+ argv << "--user #{mongrel_user}" if mongrel_user
42
+ argv << "--group #{mongrel_group}" if mongrel_group
43
+ argv << "--prefix #{mongrel_prefix}" if mongrel_prefix
44
+ argv << "-S #{mongrel_config_script}" if mongrel_config_script
45
+ cmd = argv.join " "
46
+ send(run_method, cmd)
47
+ end
48
+
49
+ desc <<-DESC
50
+ Start Mongrel processes on the app server. This uses the :use_sudo variable to determine whether to use sudo or not. By default, :use_sudo is
51
+ set to true.
52
+ DESC
53
+ task :start, :roles => :app do
54
+ set_mongrel_conf
55
+ cmd = "#{mongrel_rails} cluster::start -C #{mongrel_conf}"
56
+ cmd += " --clean" if mongrel_clean
57
+ send(run_method, cmd)
58
+ end
59
+
60
+ desc <<-DESC
61
+ Restart the Mongrel processes on the app server by starting and stopping the cluster. This uses the :use_sudo
62
+ variable to determine whether to use sudo or not. By default, :use_sudo is set to true.
63
+ DESC
64
+ task :restart, :roles => :app do
65
+ set_mongrel_conf
66
+ cmd = "#{mongrel_rails} cluster::restart -C #{mongrel_conf}"
67
+ cmd += " --clean" if mongrel_clean
68
+ send(run_method, cmd)
69
+ end
70
+
71
+ desc <<-DESC
72
+ Stop the Mongrel processes on the app server. This uses the :use_sudo
73
+ variable to determine whether to use sudo or not. By default, :use_sudo is
74
+ set to true.
75
+ DESC
76
+ task :stop, :roles => :app do
77
+ set_mongrel_conf
78
+ cmd = "#{mongrel_rails} cluster::stop -C #{mongrel_conf}"
79
+ cmd += " --clean" if mongrel_clean
80
+ send(run_method, cmd)
81
+ end
82
+
83
+ desc <<-DESC
84
+ Check the status of the Mongrel processes on the app server. This uses the :use_sudo
85
+ variable to determine whether to use sudo or not. By default, :use_sudo is
86
+ set to true.
87
+ DESC
88
+ task :status, :roles => :app do
89
+ set_mongrel_conf
90
+ send(run_method, "#{mongrel_rails} cluster::status -C #{mongrel_conf}")
91
+ end
92
+
93
+ desc <<-DESC
94
+ Remove the mongrel cluster configuration from the app server.
95
+ DESC
96
+ task :remove, :roles => :app do
97
+ set_mongrel_conf
98
+ alt_mongrel_conf = mongrel_conf.gsub('.conf','.yml')
99
+ run("[ -f #{mongrel_conf} ] || [ -f #{alt_mongrel_conf} ] && echo \"yes\" || echo \"no\"") do |c, s, o|
100
+ if o =~ /yes?/
101
+ exit if Capistrano::CLI.ui.ask("WARNING: You are about to remove your mongrel cluster configuration. Are you sure you want to proceed? [y/N]").upcase != "Y"
102
+ mongrel.cluster.stop
103
+ sudo("rm -f #{mongrel_conf}")
104
+ sudo("rm -f #{alt_mongrel_conf}")
105
+ end
106
+ end
107
+ end
108
+
109
+ end
110
+
111
+ end
112
+
113
+ def set_mongrel_conf
114
+ set :mongrel_conf, "/etc/mongrel_cluster/#{application}.conf" unless mongrel_conf
115
+ end
116
+
117
+ def set_mongrel_pid_file
118
+ set :mongrel_pid_file, "/var/run/mongrel_cluster/#{application}.pid" unless mongrel_pid_file
119
+ end
120
+ end
@@ -0,0 +1,20 @@
1
+ Capistrano::Configuration.instance(:must_exist).load do
2
+ set :use_mod_rewrite, false
3
+ load 'config/deploy'
4
+ namespace :passenger do
5
+
6
+ [:start, :stop].each do |t|
7
+ task t, :roles => :app do
8
+ puts "The :#{t} task no effect when using Passenger as your application server."
9
+ end
10
+ end
11
+
12
+ desc <<-DESC
13
+ Restart the Passenger processes on the app server by touching tmp/restart.txt.
14
+ DESC
15
+ task :restart, :roles => :app do
16
+ run "touch #{current_path}/tmp/restart.txt"
17
+ end
18
+
19
+ end
20
+ end
@@ -0,0 +1,62 @@
1
+ require 'yaml'
2
+ require 'capistrano'
3
+ require 'capistrano/cli'
4
+
5
+ module MySQLMethods
6
+
7
+ def execute(sql, user)
8
+ run "mysql --user=#{user} -p --execute=\"#{sql}\"" do |channel, stream, data|
9
+ handle_mysql_password(user, channel, stream, data)
10
+ end
11
+ end
12
+
13
+ private
14
+ def handle_mysql_password(user, channel, stream, data)
15
+ logger.info data, "[database on #{channel[:host]} asked for password]"
16
+ if data =~ /^Enter password:/
17
+ pass = Capistrano::CLI.password_prompt "Enter database password for '#{user}':"
18
+ channel.send_data "#{pass}\n"
19
+ end
20
+ end
21
+ end
22
+
23
+ Capistrano.plugin :mysql_helper, MySQLMethods
24
+
25
+ Capistrano::Configuration.instance(:must_exist).load do
26
+
27
+ set :mysql_admin, nil
28
+
29
+ namespace :db do
30
+
31
+ desc "Execute MySQL statements using --execute option. Set the 'sql' variable."
32
+ task :execute, :roles => :db, :only => { :primary => true } do
33
+ set_mysql_admin
34
+ mysql_helper.execute sql, mysql_admin
35
+ end
36
+
37
+ desc "Create MySQL database and user based on config/database.yml"
38
+ task :setup, :roles => :db, :only => { :primary => true } do
39
+ # on_rollback {}
40
+
41
+ set_mysql_admin
42
+ read_config
43
+
44
+ sql = "CREATE DATABASE #{db_name};"
45
+ sql += "GRANT ALL PRIVILEGES ON #{db_name}.* TO #{db_user}@localhost IDENTIFIED BY '#{db_password}';"
46
+ mysql_helper.execute sql, mysql_admin
47
+ end
48
+
49
+ end
50
+
51
+ def read_config
52
+ db_config = YAML.load_file('config/database.yml')
53
+ set :db_user, db_config[rails_env]["username"]
54
+ set :db_password, db_config[rails_env]["password"]
55
+ set :db_name, db_config[rails_env]["database"]
56
+ end
57
+
58
+ def set_mysql_admin
59
+ set :mysql_admin, user unless mysql_admin
60
+ end
61
+
62
+ end
@@ -0,0 +1,62 @@
1
+ # CentOS install for Rails Machine
2
+ # sudo su -
3
+ # yum install postgresql-client postgresql-server postgresql-devel
4
+ # chkconfig postgresql on
5
+ # service postgresql start
6
+ # gem install postgres
7
+ # su - postgres
8
+ # createuser deploy -a -d
9
+ # exit
10
+
11
+ require 'yaml'
12
+ require 'capistrano'
13
+ require 'capistrano/cli'
14
+
15
+ module PostgreSQLMethods
16
+
17
+ def createdb(db, user)
18
+ run "createdb -O #{user} #{db}"
19
+ end
20
+
21
+ def createuser(user, password)
22
+ cmd = "createuser -P -D -A -E #{user}"
23
+ run cmd do |channel, stream, data|
24
+ if data =~ /^Enter password for new user:/
25
+ channel.send_data "#{password}\n"
26
+ end
27
+ if data =~ /^Enter it again:/
28
+ channel.send_data "#{password}\n"
29
+ end
30
+ end
31
+ end
32
+
33
+ def command(sql, database)
34
+ run "psql --command=\"#{sql}\" #{database}"
35
+ end
36
+
37
+ end
38
+
39
+ Capistrano.plugin :pgsql, PostgreSQLMethods
40
+
41
+ Capistrano::Configuration.instance(:must_exist).load do
42
+
43
+ namespace :db do
44
+
45
+ desc "Create PosgreSQL database and user based on config/database.yml"
46
+ task :setup, :roles => :db, :only => { :primary => true } do
47
+ # on_rollback {} TODO
48
+ read_config
49
+ pgsql.createuser db_user, db_password
50
+ pgsql.createdb db_name, db_user
51
+ end
52
+
53
+ end
54
+
55
+ def read_config
56
+ db_config = YAML.load_file('config/database.yml')
57
+ set :db_user, db_config[rails_env]["username"]
58
+ set :db_password, db_config[rails_env]["password"]
59
+ set :db_name, db_config[rails_env]["database"]
60
+ end
61
+
62
+ end
@@ -0,0 +1,14 @@
1
+ require 'capistrano'
2
+ require 'capistrano/cli'
3
+
4
+ Capistrano::Configuration.instance(:must_exist).load do
5
+
6
+ namespace :db do
7
+
8
+ desc "Do nothing when using sqlite3."
9
+ task :setup, :roles => :db, :only => { :primary => true } do
10
+ end
11
+
12
+ end
13
+
14
+ end
@@ -0,0 +1,44 @@
1
+ require 'fileutils'
2
+ Capistrano::Configuration.instance(:must_exist).load do
3
+
4
+ namespace :localrepo do
5
+
6
+ desc "Setup directory structure and initialize git repository on remote server"
7
+ task :setup, :roles => :scm do
8
+ dir = "#{deploy_to}/repos/#{application}.git"
9
+ run "mkdir -p #{dir}"
10
+ sudo "chown -R #{user}:#{user} #{dir}"
11
+ run "cd #{dir} && git --bare init"
12
+ run "chmod 770 #{dir}"
13
+ end
14
+
15
+ desc "Import code into remote git repository."
16
+ task :import do
17
+ puts "Initializing local git repository"
18
+ system "git init"
19
+
20
+ puts "Adding remote server pointing to #{repository}"
21
+ system "git remote add origin #{repository}"
22
+
23
+ puts "Adding .gitignore file"
24
+ system "echo 'log/*'>> .gitignore"
25
+ system "echo 'tmp/*'>> .gitignore"
26
+ system "echo '.DS_Store'>> .gitignore"
27
+ system "echo 'public/cache/**/*'>> .gitignore"
28
+ system "git add .gitignore"
29
+
30
+ puts "Committing application locally"
31
+ system "git add *"
32
+ system 'git commit -a -v -m "initial import of site"'
33
+
34
+ puts "Pushing application to the remote server. The name of the branch is:"
35
+ system "git remote"
36
+ system "git push origin master"
37
+
38
+ puts "git setup complete"
39
+ puts "You can clone this repository with git clone #{repository} #{application}"
40
+ end
41
+
42
+ end
43
+
44
+ end
@@ -0,0 +1,47 @@
1
+ require 'fileutils'
2
+ Capistrano::Configuration.instance(:must_exist).load do
3
+
4
+ namespace :localrepo do
5
+
6
+ desc "Setup svn repository"
7
+ task :setup, :roles => :scm do
8
+ dir = "#{deploy_to}/repos"
9
+ run "mkdir -p #{dir}"
10
+ sudo "chown -R #{user}:#{user} #{dir}"
11
+ run "chmod 770 #{dir}"
12
+ run "svnadmin create #{dir}"
13
+ end
14
+
15
+ desc "Import code into svn repository."
16
+ task :import do
17
+ new_path = Dir.pwd + "_machine"
18
+ tags = repository.sub("trunk", "tags")
19
+ branches = repository.sub("trunk", "branches")
20
+ puts "Adding branches and tags"
21
+ system "svn mkdir -m 'Adding tags and branches directories' #{tags} #{branches}"
22
+ puts "Importing application."
23
+ system "svn import #{repository} -m 'Import'"
24
+ puts "Checking out to new directory."
25
+ system "svn co #{repository} #{new_path}"
26
+ cwd = Dir.getwd
27
+ Dir.chdir new_path
28
+ puts "removing log directory contents from svn"
29
+ system "svn remove log/*"
30
+ puts "ignoring log directory"
31
+ system "svn propset svn:ignore '*.log' log/"
32
+ system "svn update log/"
33
+ puts "removing tmp directory from svn"
34
+ system "svn remove tmp/"
35
+ puts "ignoring tmp directory"
36
+ system "svn propset svn:ignore '*' tmp/"
37
+ system "svn update tmp/"
38
+ puts "committing changes"
39
+ system "svn commit -m 'Removed and ignored log files and tmp'"
40
+ Dir.chdir cwd
41
+ puts "Your repository is: #{repository}"
42
+ puts "Please change to your new working directory: #{new_path}"
43
+ end
44
+
45
+ end
46
+
47
+ end
@@ -0,0 +1,87 @@
1
+ require 'erb'
2
+ Capistrano::Configuration.instance(:must_exist).load do
3
+
4
+
5
+ set :apache_server_name, nil
6
+ set :apache_conf, nil
7
+ set :apache_default_vhost, false
8
+ set :apache_default_vhost_conf, nil
9
+ set :apache_ctl, "/etc/init.d/httpd"
10
+ set :apache_server_aliases, []
11
+ set :apache_proxy_port, 8000
12
+ set :apache_proxy_servers, 2
13
+ set :apache_proxy_address, "127.0.0.1"
14
+ set :apache_ssl_enabled, false
15
+ set :apache_ssl_ip, nil
16
+ set :apache_ssl_forward_all, false
17
+
18
+ load 'config/deploy'
19
+
20
+ namespace :apache do
21
+
22
+ desc "Configure Apache. This uses the :use_sudo
23
+ variable to determine whether to use sudo or not. By default, :use_sudo is
24
+ set to true."
25
+ task :configure, :roles => :web do
26
+ set_apache_conf
27
+
28
+ run("[ -f #{ apache_conf} ] && echo \"yes\" || echo \"no\"") do |c, s, o|
29
+ if o =~ /yes?/
30
+ backup = "#{ apache_conf}.old.#{Time.now.strftime('%Y%m%d%H%M%S')}"
31
+ send(run_method, "cp #{ apache_conf} #{backup}")
32
+ exit if Capistrano::CLI.ui.ask("WARNING: You are about to change your existing Apache configuration. A backup has been created at #{backup}. Are you sure you want to proceed? [y/N]").upcase != "Y"
33
+ end
34
+ end
35
+
36
+ server_aliases = []
37
+ server_aliases << "www.#{ apache_server_name}"
38
+ server_aliases.concat apache_server_aliases
39
+ set :apache_server_aliases_array, server_aliases
40
+
41
+ file = File.join(File.dirname(__FILE__), "templates", app_server.to_s, "httpd.conf")
42
+ template = File.read(file)
43
+ buffer = ERB.new(template).result(binding)
44
+
45
+ if apache_ssl_enabled
46
+ file = File.join(File.dirname(__FILE__), "templates", app_server.to_s, "httpd-ssl.conf")
47
+ template = File.read(file)
48
+ ssl_buffer = ERB.new(template).result(binding)
49
+ buffer += ssl_buffer
50
+ end
51
+
52
+ put buffer, "#{shared_path}/httpd.conf", :mode => 0444
53
+ send(run_method, "cp #{shared_path}/httpd.conf #{ apache_conf}")
54
+ send(run_method, "rm -f #{shared_path}/httpd.conf")
55
+ end
56
+
57
+ desc "Start Apache "
58
+ task :start, :roles => :web do
59
+ send(run_method, "#{ apache_ctl} start")
60
+ end
61
+
62
+ desc "Restart Apache "
63
+ task :restart, :roles => :web do
64
+ send(run_method, "#{ apache_ctl} restart")
65
+ end
66
+
67
+ desc "Stop Apache "
68
+ task :stop, :roles => :web do
69
+ send(run_method, "#{ apache_ctl} stop")
70
+ end
71
+
72
+ desc "Reload Apache "
73
+ task :reload, :roles => :web do
74
+ send(run_method, "#{ apache_ctl} reload")
75
+ end
76
+
77
+ end
78
+
79
+ def set_apache_conf
80
+ if apache_default_vhost
81
+ set :apache_conf, "/etc/httpd/conf/default.conf" unless apache_default_vhost_conf
82
+ else
83
+ set :apache_conf, "/etc/httpd/conf/apps/#{application}.conf" unless apache_conf
84
+ end
85
+ end
86
+
87
+ end
@@ -0,0 +1,80 @@
1
+ <VirtualHost <%= apache_ssl_ip %>:443>
2
+
3
+ ServerName <%= apache_server_name %>
4
+ <% apache_server_aliases_array.each do |a| %>
5
+ ServerAlias <%= "#{a}" %>
6
+ <% end %>
7
+
8
+ <IfModule passenger_module>
9
+ RailsAutoDetect off
10
+ </IfModule>
11
+
12
+ DocumentRoot <%= "#{current_path}/public" %>
13
+
14
+ <Directory <%= "#{current_path}/public" %>>
15
+ Options FollowSymLinks
16
+ AllowOverride None
17
+ Order allow,deny
18
+ Allow from all
19
+ </Directory>
20
+
21
+ # Configure mongrel_cluster
22
+ <Proxy balancer://<%= "#{application}_cluster" %>>
23
+ <% start_port = apache_proxy_port %>
24
+ <% end_port = apache_proxy_port + apache_proxy_servers - 1 %>
25
+ <% start_port.upto(end_port) do |port| %>
26
+ BalancerMember http://<%= "#{ apache_proxy_address}:#{port.to_s}" %>
27
+ <% end %>
28
+ </Proxy>
29
+
30
+ RewriteEngine On
31
+
32
+ # Prevent access to .svn directories
33
+ RewriteRule ^(.*/)?\.svn/ - [F,L]
34
+ ErrorDocument 403 "Access Forbidden"
35
+
36
+ # Check for maintenance file and redirect all requests
37
+ RewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f
38
+ RewriteCond %{SCRIPT_FILENAME} !maintenance.html
39
+ RewriteRule ^.*$ /system/maintenance.html [L]
40
+
41
+ # Rewrite index to check for static
42
+ RewriteRule ^/$ /index.html [QSA]
43
+
44
+ # Rewrite to check for Rails cached page
45
+ RewriteRule ^([^.]+)$ $1.html [QSA]
46
+
47
+ # Redirect all non-static requests to cluster
48
+ RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
49
+ # Add header for Mongrel to set HTTPS environment for Rails
50
+ RequestHeader set X-Forwarded-Proto "https"
51
+ RewriteRule ^/(.*)$ balancer://<%= "#{application}_cluster" %>%{REQUEST_URI} [P,QSA,L]
52
+
53
+ # Deflate
54
+ AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css application/x-javascript
55
+ BrowserMatch ^Mozilla/4 gzip-only-text/html
56
+ BrowserMatch ^Mozilla/4\.0[678] no-gzip
57
+ BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
58
+
59
+ # SSL Engine Switch
60
+ SSLEngine on
61
+
62
+ # SSL Cipher Suite:
63
+ SSLProtocol -all +SSLv3
64
+ SSLCipherSuite SSLv3:+HIGH:+MEDIUM
65
+
66
+ # Server Certificate
67
+ SSLCertificateFile /etc/httpd/conf/ssl.crt/<%= domain %>.crt
68
+
69
+ # Server Private Key
70
+ SSLCertificateKeyFile /etc/httpd/conf/ssl.key/<%= domain %>.key
71
+
72
+ BrowserMatch ".*MSIE.*" \
73
+ nokeepalive ssl-unclean-shutdown \
74
+ downgrade-1.0 force-response-1.0
75
+
76
+ ErrorLog logs/<%= domain %>-error_log
77
+ CustomLog logs/<%= domain %>-access_log combined
78
+ CustomLog logs/<%= domain %>-ssl_log \
79
+ "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
80
+ </VirtualHost>