Agiley-ec2onrails 0.9.9 → 0.9.10
Sign up to get free protection for your applications and to get access to all the features.
- data/{History.txt → CHANGELOG} +0 -0
- data/{COPYING.txt → COPYING} +0 -0
- data/Manifest +161 -0
- data/{website/index.txt → README.textile} +33 -5
- data/Rakefile +36 -4
- data/TODO +91 -0
- data/ec2onrails.gemspec +279 -0
- data/examples/Capfile +3 -0
- data/examples/deploy.rb +88 -0
- data/examples/s3.yml +9 -0
- data/lib/ec2onrails/capistrano_utils.rb +0 -11
- data/lib/ec2onrails/recipes.rb +165 -59
- data/lib/ec2onrails/version.rb +1 -1
- data/server/build-ec2onrails.sh +44 -0
- data/server/files/etc/aliases +5 -0
- data/server/files/etc/aliases.db +0 -0
- data/server/files/etc/apache2/apache2.conf +295 -0
- data/server/files/etc/apache2/conf.d/app.proxy_cluster.conf +7 -0
- data/server/files/etc/apache2/conf.d/app.proxy_frontend.conf +10 -0
- data/server/files/etc/apache2/mods-available/proxy.conf +18 -0
- data/server/files/etc/apache2/sites-available/app.common +56 -0
- data/server/files/etc/apache2/sites-available/app.custom +0 -0
- data/server/files/etc/apache2/sites-available/default +14 -0
- data/server/files/etc/apache2/sites-available/default-ssl +18 -0
- data/server/files/etc/cron.d/backup_app_db_to_s3 +6 -0
- data/server/files/etc/cron.daily/app +9 -0
- data/server/files/etc/cron.daily/logrotate_post +19 -0
- data/server/files/etc/cron.hourly/app +10 -0
- data/server/files/etc/cron.monthly/app +10 -0
- data/server/files/etc/cron.weekly/app +10 -0
- data/server/files/etc/ec2onrails/balancer_members +6 -0
- data/server/files/etc/ec2onrails/roles.yml +5 -0
- data/server/files/etc/environment +2 -0
- data/server/files/etc/event.d/monit +13 -0
- data/server/files/etc/init.d/ec2-every-startup +29 -0
- data/server/files/etc/init.d/ec2-first-startup +36 -0
- data/server/files/etc/init.d/mongrel +91 -0
- data/server/files/etc/init.d/nginx +78 -0
- data/server/files/etc/init.d/set_roles +3 -0
- data/server/files/etc/logrotate.d/apache2 +16 -0
- data/server/files/etc/logrotate.d/mongrel +11 -0
- data/server/files/etc/logrotate.d/nginx +11 -0
- data/server/files/etc/memcached.conf +47 -0
- data/server/files/etc/mongrel_cluster/app.yml +9 -0
- data/server/files/etc/monit/README +5 -0
- data/server/files/etc/monit/app.monitrc.erb +13 -0
- data/server/files/etc/monit/db_primary.monitrc.erb +10 -0
- data/server/files/etc/monit/memcache.monitrc +8 -0
- data/server/files/etc/monit/monitrc +12 -0
- data/server/files/etc/monit/system.monitrc +15 -0
- data/server/files/etc/monit/web.monitrc.erb +23 -0
- data/server/files/etc/motd.tail +13 -0
- data/server/files/etc/mysql/my.cnf +149 -0
- data/server/files/etc/nginx/nginx.conf +296 -0
- data/server/files/etc/postfix/main.cf +4 -0
- data/server/files/etc/rc0.d/K10mongrel +1 -0
- data/server/files/etc/rc1.d/K10mongrel +1 -0
- data/server/files/etc/rc2.d/S90mongrel +1 -0
- data/server/files/etc/rc3.d/S90mongrel +1 -0
- data/server/files/etc/rc4.d/S90mongrel +1 -0
- data/server/files/etc/rc5.d/S90mongrel +1 -0
- data/server/files/etc/rc6.d/K10mongrel +1 -0
- data/server/files/etc/rcS.d/S91ec2-first-startup +1 -0
- data/server/files/etc/rcS.d/S92ec2-every-startup +1 -0
- data/server/files/etc/rcS.d/S99set_roles +1 -0
- data/server/files/etc/ssh/sshd_config +94 -0
- data/server/files/etc/sudoers +1 -0
- data/server/files/etc/sudoers.full_access +26 -0
- data/server/files/etc/sudoers.restricted_access +28 -0
- data/server/files/etc/syslog.conf +69 -0
- data/server/files/usr/local/ec2onrails/COPYING +339 -0
- data/server/files/usr/local/ec2onrails/bin/archive_file.rb +44 -0
- data/server/files/usr/local/ec2onrails/bin/backup_app_db.rb +68 -0
- data/server/files/usr/local/ec2onrails/bin/init_services.rb +57 -0
- data/server/files/usr/local/ec2onrails/bin/mongrel_start +8 -0
- data/server/files/usr/local/ec2onrails/bin/mongrel_stop +8 -0
- data/server/files/usr/local/ec2onrails/bin/optimize_mysql.rb +339 -0
- data/server/files/usr/local/ec2onrails/bin/rails_env +35 -0
- data/server/files/usr/local/ec2onrails/bin/rebundle.sh +70 -0
- data/server/files/usr/local/ec2onrails/bin/restore_app_db.rb +58 -0
- data/server/files/usr/local/ec2onrails/bin/set_rails_env +40 -0
- data/server/files/usr/local/ec2onrails/bin/set_roles.rb +76 -0
- data/server/files/usr/local/ec2onrails/bin/setup_web_proxy.rb +106 -0
- data/server/files/usr/local/ec2onrails/config +30 -0
- data/server/files/usr/local/ec2onrails/lib/mysql_helper.rb +82 -0
- data/server/files/usr/local/ec2onrails/lib/roles_helper.rb +137 -0
- data/server/files/usr/local/ec2onrails/lib/s3_helper.rb +126 -0
- data/server/files/usr/local/ec2onrails/lib/utils.rb +16 -0
- data/server/files/usr/local/ec2onrails/lib/vendor/ini.rb +268 -0
- data/server/files/usr/local/ec2onrails/startup-scripts/every-startup/get-hostname.sh +27 -0
- data/server/files/usr/local/ec2onrails/startup-scripts/first-startup/README +5 -0
- data/server/files/usr/local/ec2onrails/startup-scripts/first-startup/create-dirs.sh +42 -0
- data/server/files/usr/local/ec2onrails/startup-scripts/first-startup/generate-default-web-cert-and-key.sh +49 -0
- data/server/files/usr/local/ec2onrails/startup-scripts/first-startup/misc.sh +27 -0
- data/server/files/usr/local/ec2onrails/startup-scripts/first-startup/prepare-mysql-data-dir.sh +24 -0
- data/server/files/usr/local/ec2onrails/startup-scripts/first-startup/setup-credentials.sh +29 -0
- data/server/rakefile.rb +222 -0
- data/test/autobench.conf +60 -0
- data/test/spec/lib/s3_helper_spec.rb +134 -0
- data/test/spec/lib/s3_old.yml +3 -0
- data/test/spec/test_files/test1 +0 -0
- data/test/spec/test_files/test2 +0 -0
- data/test/test_app/Capfile +3 -0
- data/test/test_app/README +182 -0
- data/test/test_app/Rakefile +10 -0
- data/test/test_app/app/controllers/application.rb +7 -0
- data/test/test_app/app/controllers/db_fast_controller.rb +6 -0
- data/test/test_app/app/controllers/fast_controller.rb +5 -0
- data/test/test_app/app/controllers/slow_controller.rb +6 -0
- data/test/test_app/app/controllers/very_slow_controller.rb +6 -0
- data/test/test_app/app/helpers/application_helper.rb +3 -0
- data/test/test_app/app/helpers/db_fast_helper.rb +2 -0
- data/test/test_app/app/helpers/fast_helper.rb +2 -0
- data/test/test_app/app/helpers/slow_helper.rb +2 -0
- data/test/test_app/app/helpers/very_slow_helper.rb +2 -0
- data/test/test_app/config/boot.rb +109 -0
- data/test/test_app/config/database.yml +19 -0
- data/test/test_app/config/deploy.rb +21 -0
- data/test/test_app/config/environment.rb +60 -0
- data/test/test_app/config/environments/development.rb +21 -0
- data/test/test_app/config/environments/production.rb +18 -0
- data/test/test_app/config/environments/test.rb +19 -0
- data/test/test_app/config/routes.rb +27 -0
- data/test/test_app/db/schema.rb +7 -0
- data/test/test_app/doc/README_FOR_APP +2 -0
- data/test/test_app/public/404.html +30 -0
- data/test/test_app/public/500.html +30 -0
- data/test/test_app/public/dispatch.cgi +10 -0
- data/test/test_app/public/dispatch.fcgi +24 -0
- data/test/test_app/public/dispatch.rb +10 -0
- data/test/test_app/public/favicon.ico +0 -0
- data/test/test_app/public/images/rails.png +0 -0
- data/test/test_app/public/javascripts/application.js +2 -0
- data/test/test_app/public/javascripts/controls.js +963 -0
- data/test/test_app/public/javascripts/dragdrop.js +972 -0
- data/test/test_app/public/javascripts/effects.js +1120 -0
- data/test/test_app/public/javascripts/prototype.js +4225 -0
- data/test/test_app/public/robots.txt +1 -0
- data/test/test_app/script/about +3 -0
- data/test/test_app/script/breakpointer +3 -0
- data/test/test_app/script/console +3 -0
- data/test/test_app/script/destroy +3 -0
- data/test/test_app/script/generate +3 -0
- data/test/test_app/script/performance/benchmarker +3 -0
- data/test/test_app/script/performance/profiler +3 -0
- data/test/test_app/script/performance/request +3 -0
- data/test/test_app/script/plugin +3 -0
- data/test/test_app/script/process/inspector +3 -0
- data/test/test_app/script/process/reaper +3 -0
- data/test/test_app/script/process/spawner +3 -0
- data/test/test_app/script/runner +3 -0
- data/test/test_app/script/server +3 -0
- data/test/test_app/test/functional/db_fast_controller_test.rb +18 -0
- data/test/test_app/test/functional/fast_controller_test.rb +18 -0
- data/test/test_app/test/functional/slow_controller_test.rb +18 -0
- data/test/test_app/test/functional/very_slow_controller_test.rb +18 -0
- metadata +193 -36
- data/Manifest.txt +0 -25
- data/README.txt +0 -1
- data/config/hoe.rb +0 -70
- data/config/requirements.rb +0 -17
- data/script/destroy +0 -14
- data/script/generate +0 -14
- data/script/txt2html +0 -74
- data/tasks/deployment.rake +0 -27
- data/tasks/environment.rake +0 -7
- data/tasks/website.rake +0 -17
- data/website/javascripts/rounded_corners_lite.inc.js +0 -285
- data/website/stylesheets/screen.css +0 -144
- data/website/template.rhtml +0 -53
@@ -0,0 +1,13 @@
|
|
1
|
+
<% @web_port_range.each do |port_num| %>
|
2
|
+
check process mongrel_<%= port_num %> with pidfile /mnt/app/shared/log/mongrel.<%= port_num %>.pid
|
3
|
+
start program = "/usr/local/ec2onrails/bin/mongrel_start --only <%= port_num %>"
|
4
|
+
stop program = "/usr/local/ec2onrails/bin/mongrel_stop --only <%= port_num %>"
|
5
|
+
if totalmem is greater than 170.0 MB for 4 cycles then restart
|
6
|
+
if cpu is greater than 80% for 4 cycles then restart
|
7
|
+
if failed port <%= port_num %> with timeout 10 seconds then restart
|
8
|
+
if loadavg(5min) greater than 10 for 8 cycles then restart # bad, bad, bad
|
9
|
+
if loadavg(15min) greater than 8 for 20 cycles then restart # bad, bad, bad
|
10
|
+
if 20 restarts within 20 cycles then timeout
|
11
|
+
mode manual
|
12
|
+
group app
|
13
|
+
<% end %>
|
@@ -0,0 +1,10 @@
|
|
1
|
+
check process mysql with pidfile /var/run/mysqld/mysqld.pid
|
2
|
+
start program = "/etc/init.d/mysql start"
|
3
|
+
stop program = "/etc/init.d/mysql stop"
|
4
|
+
if cpu > 80% for 5 cycles then restart
|
5
|
+
# TODO: this should take into account the settings from the optimize_mysql call.....
|
6
|
+
# if totalmem > 700.0 MB for 5 cycles then restart
|
7
|
+
if failed port 3306 protocol mysql with timeout 10 seconds then alert
|
8
|
+
if 3 restarts within 5 cycles then timeout
|
9
|
+
mode manual
|
10
|
+
group db_primary
|
@@ -0,0 +1,8 @@
|
|
1
|
+
check process memcached with pidfile /var/run/memcached.pid
|
2
|
+
start program = "/etc/init.d/memcached start"
|
3
|
+
stop program = "/etc/init.d/memcached stop"
|
4
|
+
if cpu > 80% for 5 cycles then restart
|
5
|
+
if failed port 11211 with timeout 10 seconds then restart
|
6
|
+
if 3 restarts within 5 cycles then timeout
|
7
|
+
mode manual
|
8
|
+
group memcache
|
@@ -0,0 +1,12 @@
|
|
1
|
+
set daemon 60
|
2
|
+
set logfile syslog facility log_daemon
|
3
|
+
set mailserver localhost
|
4
|
+
set mail-format {
|
5
|
+
from: app@localhost
|
6
|
+
subject: $HOST: $SERVICE $EVENT
|
7
|
+
}
|
8
|
+
set alert app@localhost only on { connection, exec, nonexist, resource, timeout }
|
9
|
+
set httpd port 2812
|
10
|
+
# address localhost
|
11
|
+
allow localhost
|
12
|
+
include /etc/monit/*.monitrc
|
@@ -0,0 +1,15 @@
|
|
1
|
+
check system localhost
|
2
|
+
if loadavg (5min) > 4 then alert
|
3
|
+
if memory usage > 80% then alert
|
4
|
+
|
5
|
+
check device rootfs with path /
|
6
|
+
if space usage > 75 % then alert
|
7
|
+
if space usage > 95 % then unmonitor
|
8
|
+
if inode usage > 75 % then alert
|
9
|
+
if inode usage > 95 % then unmonitor
|
10
|
+
|
11
|
+
check device mntfs with path /mnt
|
12
|
+
if space usage > 70 % then alert
|
13
|
+
if space usage > 95 % then unmonitor
|
14
|
+
if inode usage > 70 % then alert
|
15
|
+
if inode usage > 95 % then unmonitor
|
@@ -0,0 +1,23 @@
|
|
1
|
+
<% if system("which apache") %>
|
2
|
+
check process apache with pidfile /var/run/apache2.pid
|
3
|
+
start program = "/etc/init.d/apache2 start"
|
4
|
+
stop program = "/etc/init.d/apache2 stop"
|
5
|
+
if cpu > 80% for 5 cycles then restart
|
6
|
+
if totalmem > 300.0 MB for 5 cycles then restart
|
7
|
+
if children > 250 then alert
|
8
|
+
if failed port 80 with timeout 10 seconds then restart
|
9
|
+
if 3 restarts within 5 cycles then timeout
|
10
|
+
mode manual
|
11
|
+
group web
|
12
|
+
<% else %>
|
13
|
+
check process nginx with pidfile /var/run/nginx.pid
|
14
|
+
start program = "/etc/init.d/nginx start"
|
15
|
+
stop program = "/etc/init.d/nginx stop"
|
16
|
+
if cpu > 20% for 5 cycles then restart
|
17
|
+
if totalmem > 100.0 MB for 5 cycles then restart
|
18
|
+
if children > 10 then alert
|
19
|
+
if failed port 80 with timeout 10 seconds then restart
|
20
|
+
if 3 restarts within 5 cycles then timeout
|
21
|
+
mode manual
|
22
|
+
group web
|
23
|
+
<% end %>
|
@@ -0,0 +1,13 @@
|
|
1
|
+
|
2
|
+
EC2 on Rails
|
3
|
+
!!VERSION!!
|
4
|
+
http://rubyforge.org/projects/ec2onrails/
|
5
|
+
|
6
|
+
Copyright 2008 Paul Dowman, http://pauldowman.com/
|
7
|
+
|
8
|
+
Base AMI built using Eric Hammond's EC2 Ubuntu script:
|
9
|
+
http://alestic.com/
|
10
|
+
|
11
|
+
This is free software, and you are welcome to redistribute it under
|
12
|
+
certain conditions. This software comes with ABSOLUTELY NO WARRANTY.
|
13
|
+
See /usr/local/ec2onrails/COPYING for details.
|
@@ -0,0 +1,149 @@
|
|
1
|
+
#
|
2
|
+
# The MySQL database server configuration file.
|
3
|
+
#
|
4
|
+
# You can copy this to one of:
|
5
|
+
# - "/etc/mysql/my.cnf" to set global options,
|
6
|
+
# - "~/.my.cnf" to set user-specific options.
|
7
|
+
#
|
8
|
+
# One can use all long options that the program supports.
|
9
|
+
# Run program with --help to get a list of available options and with
|
10
|
+
# --print-defaults to see which it would actually understand and use.
|
11
|
+
#
|
12
|
+
# For explanations see
|
13
|
+
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html
|
14
|
+
|
15
|
+
# This will be passed to all mysql clients
|
16
|
+
# It has been reported that passwords should be enclosed with ticks/quotes
|
17
|
+
# escpecially if they contain "#" chars...
|
18
|
+
# Remember to edit /etc/mysql/debian.cnf when changing the socket location.
|
19
|
+
[client]
|
20
|
+
port = 3306
|
21
|
+
socket = /var/run/mysqld/mysqld.sock
|
22
|
+
|
23
|
+
# Here is entries for some specific programs
|
24
|
+
# The following values assume you have at least 32M ram
|
25
|
+
|
26
|
+
# This was formally known as [safe_mysqld]. Both versions are currently parsed.
|
27
|
+
[mysqld_safe]
|
28
|
+
socket = /var/run/mysqld/mysqld.sock
|
29
|
+
nice = 0
|
30
|
+
|
31
|
+
[mysqld]
|
32
|
+
#
|
33
|
+
# * Basic Settings
|
34
|
+
#
|
35
|
+
user = mysql
|
36
|
+
pid-file = /var/run/mysqld/mysqld.pid
|
37
|
+
socket = /var/run/mysqld/mysqld.sock
|
38
|
+
port = 3306
|
39
|
+
basedir = /usr
|
40
|
+
datadir = /mnt/mysql_data
|
41
|
+
tmpdir = /mnt/mysql_data/tmp
|
42
|
+
language = /usr/share/mysql/english
|
43
|
+
skip-external-locking
|
44
|
+
default-storage-engine = InnoDB
|
45
|
+
|
46
|
+
#
|
47
|
+
# Instead of skip-networking the default is now to listen only on
|
48
|
+
# localhost which is more compatible and is not less secure.
|
49
|
+
#bind-address = 127.0.0.1
|
50
|
+
#
|
51
|
+
# * Fine Tuning
|
52
|
+
#
|
53
|
+
key_buffer_size = 16M
|
54
|
+
max_allowed_packet = 16M
|
55
|
+
thread_stack = 128K
|
56
|
+
thread_cache_size = 8
|
57
|
+
#max_connections = 100
|
58
|
+
#table_cache = 64
|
59
|
+
#thread_concurrency = 10
|
60
|
+
#
|
61
|
+
# * Query Cache Configuration
|
62
|
+
#
|
63
|
+
query_cache_limit = 1M
|
64
|
+
query_cache_size = 64M
|
65
|
+
#
|
66
|
+
# * Logging and Replication
|
67
|
+
#
|
68
|
+
# Both location gets rotated by the cronjob.
|
69
|
+
# Be aware that this log type is a performance killer.
|
70
|
+
#log = /var/log/mysql/mysql.log
|
71
|
+
#
|
72
|
+
# Error logging goes to syslog. This is a Debian improvement :)
|
73
|
+
#
|
74
|
+
# Here you can see queries with especially long duration
|
75
|
+
#log_slow_queries = /mnt/log/mysql/mysql-slow.log
|
76
|
+
#long_query_time = 2
|
77
|
+
#log-queries-not-using-indexes
|
78
|
+
#
|
79
|
+
# The following can be used as easy to replay backup logs or for replication.
|
80
|
+
#server-id = 1
|
81
|
+
log_bin = /mnt/log/mysql/mysql-bin.log
|
82
|
+
# WARNING: Using expire_logs_days without bin_log crashes the server! See README.Debian!
|
83
|
+
expire_logs_days = 10
|
84
|
+
max_binlog_size = 100M
|
85
|
+
#binlog_do_db = include_database_name
|
86
|
+
#binlog_ignore_db = include_database_name
|
87
|
+
#
|
88
|
+
# * BerkeleyDB
|
89
|
+
#
|
90
|
+
# Using BerkeleyDB is now discouraged as its support will cease in 5.1.12.
|
91
|
+
skip-bdb
|
92
|
+
#
|
93
|
+
# * InnoDB
|
94
|
+
#
|
95
|
+
# InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/.
|
96
|
+
# Read the manual for more InnoDB related options. There are many!
|
97
|
+
# You might want to disable InnoDB to shrink the mysqld process by circa 100MB.
|
98
|
+
#skip-innodb
|
99
|
+
innodb_data_file_path=ibdata1:100M:autoextend
|
100
|
+
innodb_buffer_pool_size=200M
|
101
|
+
innodb_additional_mem_pool_size=20M
|
102
|
+
innodb_log_file_size=128M
|
103
|
+
innodb_log_buffer_size=8M
|
104
|
+
innodb_flush_log_at_trx_commit=1
|
105
|
+
innodb_lock_wait_timeout=20
|
106
|
+
# innodb_flush_method=O_DIRECT
|
107
|
+
# innodb_file_per_table
|
108
|
+
|
109
|
+
#
|
110
|
+
# * Security Features
|
111
|
+
#
|
112
|
+
# Read the manual, too, if you want chroot!
|
113
|
+
# chroot = /var/lib/mysql/
|
114
|
+
#
|
115
|
+
# For generating SSL certificates I recommend the OpenSSL GUI "tinyca".
|
116
|
+
#
|
117
|
+
# ssl-ca=/etc/mysql/cacert.pem
|
118
|
+
# ssl-cert=/etc/mysql/server-cert.pem
|
119
|
+
# ssl-key=/etc/mysql/server-key.pem
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
[mysqldump]
|
124
|
+
quick
|
125
|
+
quote-names
|
126
|
+
max_allowed_packet = 16M
|
127
|
+
|
128
|
+
[mysql]
|
129
|
+
#no-auto-rehash # faster start of mysql but no tab completition
|
130
|
+
|
131
|
+
[isamchk]
|
132
|
+
key_buffer = 16M
|
133
|
+
|
134
|
+
#
|
135
|
+
# * NDB Cluster
|
136
|
+
#
|
137
|
+
# See /usr/share/doc/mysql-server-*/README.Debian for more information.
|
138
|
+
#
|
139
|
+
# The following configuration is read by the NDB Data Nodes (ndbd processes)
|
140
|
+
# not from the NDB Management Nodes (ndb_mgmd processes).
|
141
|
+
#
|
142
|
+
# [MYSQL_CLUSTER]
|
143
|
+
# ndb-connectstring=127.0.0.1
|
144
|
+
|
145
|
+
|
146
|
+
#
|
147
|
+
# * IMPORTANT: Additional settings that can override those from this file!
|
148
|
+
#
|
149
|
+
!includedir /etc/mysql/conf.d/
|
@@ -0,0 +1,296 @@
|
|
1
|
+
# user and group to run as
|
2
|
+
user app app;
|
3
|
+
|
4
|
+
# number of nginx workers
|
5
|
+
worker_processes 6;
|
6
|
+
|
7
|
+
# pid of nginx master process
|
8
|
+
pid /var/run/nginx.pid;
|
9
|
+
|
10
|
+
# Number of worker connections. 1024 is a good default
|
11
|
+
events {
|
12
|
+
worker_connections 1024;
|
13
|
+
use epoll; # linux only!
|
14
|
+
}
|
15
|
+
|
16
|
+
# start the http module where we config http access.
|
17
|
+
http {
|
18
|
+
# pull in mime-types. You can break out your config
|
19
|
+
# into as many include's as you want to make it cleaner
|
20
|
+
include /etc/nginx/mime.types;
|
21
|
+
|
22
|
+
# set a default type for the rare situation that
|
23
|
+
# nothing matches from the mimie-type include
|
24
|
+
default_type application/octet-stream;
|
25
|
+
|
26
|
+
# configure log format
|
27
|
+
log_format main '$remote_addr [$time_local] '
|
28
|
+
'"$scheme $host $request" $status $body_bytes_sent "$http_referer" '
|
29
|
+
'"$http_user_agent" "$http_x_forwarded_for" '
|
30
|
+
'($request_time');
|
31
|
+
|
32
|
+
# main access log
|
33
|
+
access_log /mnt/log/nginx/access.log main;
|
34
|
+
|
35
|
+
# main error log - Do not comment out. If you do not want the log file set this to /dev/null
|
36
|
+
# use debug instead of notice if you want additional information
|
37
|
+
error_log /mnt/log/nginx/error.log notice;
|
38
|
+
|
39
|
+
# no sendfile on OSX
|
40
|
+
sendfile on;
|
41
|
+
|
42
|
+
# These are good default values.
|
43
|
+
tcp_nopush on;
|
44
|
+
tcp_nodelay on;
|
45
|
+
# output compression saves bandwidth
|
46
|
+
gzip on;
|
47
|
+
gzip_http_version 1.0;
|
48
|
+
gzip_comp_level 2;
|
49
|
+
gzip_proxied any;
|
50
|
+
gzip_types text/plain \
|
51
|
+
text/html \
|
52
|
+
text/css \
|
53
|
+
application/x-javascript \
|
54
|
+
text/xml \
|
55
|
+
application/xml \
|
56
|
+
application/xml+rss \
|
57
|
+
text/javascript;
|
58
|
+
|
59
|
+
|
60
|
+
# this is where you define your mongrel clusters.
|
61
|
+
# you need one of these blocks for each cluster
|
62
|
+
# and each one needs its own name to refer to it later.
|
63
|
+
include /etc/ec2onrails/nginx_upstream_members;
|
64
|
+
|
65
|
+
|
66
|
+
# the server directive is nginx's virtual host directive.
|
67
|
+
server {
|
68
|
+
# port to listen on. Can also be set to an IP:PORT
|
69
|
+
listen 80;
|
70
|
+
|
71
|
+
# Set the max size for file uploads to 50Mb
|
72
|
+
client_max_body_size 50M;
|
73
|
+
|
74
|
+
# sets the domain[s] that this vhost server requests for
|
75
|
+
# server_name www.[ec2onrails].com [ec2onrails].com;
|
76
|
+
server_name _;
|
77
|
+
|
78
|
+
# uncomment to force a redirect to www
|
79
|
+
# if ($host ~* "^[ec2onrails].com$"){
|
80
|
+
# rewrite ^(.*)$ http://www.[ec2onrails].com$1 permanent;
|
81
|
+
# break;
|
82
|
+
# }
|
83
|
+
|
84
|
+
# uncomment if you want to allow or force some or all pages to go to http:// instead of https://
|
85
|
+
# if redirecting all to https, you won't need any of the other directives below the rewrite/break
|
86
|
+
# set $sub 'www';
|
87
|
+
# if ($host ~* "^(.+?)\.[ec2onrails].com$"){
|
88
|
+
# set $sub $1;
|
89
|
+
# }
|
90
|
+
#
|
91
|
+
# if ( $uri ~* "^/.+$") {
|
92
|
+
# rewrite ^(.*)$ https://$sub.[ec2onrails].com$1 permanent;
|
93
|
+
# break;
|
94
|
+
# }
|
95
|
+
|
96
|
+
# doc root
|
97
|
+
root /mnt/app/current/public;
|
98
|
+
|
99
|
+
# vhost specific access log
|
100
|
+
access_log /mnt/log/nginx/vhost.access.log main;
|
101
|
+
error_page 400 /400.html;
|
102
|
+
error_page 500 502 503 504 /500.html;
|
103
|
+
location = /500.html {
|
104
|
+
root /mnt/app/current/public;
|
105
|
+
}
|
106
|
+
|
107
|
+
# this allows people to use images and css in their maintenance.html file
|
108
|
+
if ($request_filename ~* \.(css|jpg|gif|png)$) {
|
109
|
+
break;
|
110
|
+
}
|
111
|
+
|
112
|
+
# this rewrites all the requests to the maintenance.html
|
113
|
+
# page if it exists in the doc root. This is for capistrano's
|
114
|
+
# disable web task
|
115
|
+
if (-f $document_root/system/maintenance.html) {
|
116
|
+
rewrite ^(.*)$ /system/maintenance.html last;
|
117
|
+
break;
|
118
|
+
}
|
119
|
+
|
120
|
+
# see http://wiki.codemongers.com/NginxHttpStubStatusModule
|
121
|
+
# for more information
|
122
|
+
location /nginx_status {
|
123
|
+
# copied from http://blog.kovyrin.net/2006/04/29/monitoring-nginx-with-rrdtool/
|
124
|
+
stub_status on;
|
125
|
+
access_log off;
|
126
|
+
#only allow from localhost
|
127
|
+
allow 127.0.0.1;
|
128
|
+
deny all;
|
129
|
+
}
|
130
|
+
|
131
|
+
location / {
|
132
|
+
# FUTURE TODO...enable this and test the hell out of it
|
133
|
+
# if ($request_method = GET) {
|
134
|
+
# set $memcached_key $uri;
|
135
|
+
# memcached_pass 127.0.0.1:11211;
|
136
|
+
# error_page 404 502 = @myapp;
|
137
|
+
# break;
|
138
|
+
# }
|
139
|
+
|
140
|
+
index index.html index.htm;
|
141
|
+
|
142
|
+
# needed to forward user's IP address to rails
|
143
|
+
proxy_set_header X-Real-IP $remote_addr;
|
144
|
+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
145
|
+
proxy_set_header Host $http_host;
|
146
|
+
proxy_redirect false;
|
147
|
+
proxy_max_temp_file_size 0;
|
148
|
+
proxy_next_upstream error; # do not pass along to another mongrel instance if failed or timed out
|
149
|
+
proxy_read_timeout 400; # give plenty of time for long-running rails processing tasks
|
150
|
+
#the proxy_connect_timeout cannot be more than 75
|
151
|
+
proxy_connect_timeout 70;
|
152
|
+
|
153
|
+
location ~ ^/(images|javascripts|stylesheets)/ {
|
154
|
+
expires 10y;
|
155
|
+
}
|
156
|
+
|
157
|
+
if (-f $request_filename) {
|
158
|
+
break;
|
159
|
+
}
|
160
|
+
|
161
|
+
# this is the meat of the rails page caching config
|
162
|
+
# it adds .html to the end of the url and then checks
|
163
|
+
# the filesystem for that file. If it exists, then we
|
164
|
+
# rewite the url to have explicit .html on the end
|
165
|
+
# and then send it on its way to the next config rule.
|
166
|
+
# if there is no file on the fs then it sets all the
|
167
|
+
# necessary headers and proxies to our upstream mongrels
|
168
|
+
if (-f $request_filename.html) {
|
169
|
+
rewrite (.*) $1.html break;
|
170
|
+
}
|
171
|
+
|
172
|
+
#proxy to mongrel
|
173
|
+
if (!-f $request_filename) {
|
174
|
+
proxy_pass http://mongrel;
|
175
|
+
break;
|
176
|
+
}
|
177
|
+
}
|
178
|
+
}
|
179
|
+
|
180
|
+
# This server is setup for ssl. Uncomment if
|
181
|
+
# you are using ssl as well as port 80.
|
182
|
+
# server {
|
183
|
+
# # port to listen on. Can also be set to an IP:PORT
|
184
|
+
# listen 443;
|
185
|
+
#
|
186
|
+
# # Set the max size for file uploads to 50Mb
|
187
|
+
# client_max_body_size 50M;
|
188
|
+
#
|
189
|
+
# # sets the domain[s] that this vhost server requests for
|
190
|
+
# # server_name www.[ec2onrails].com [ec2onrails].com;
|
191
|
+
# server_name _;
|
192
|
+
#
|
193
|
+
# # uncomment to force a redirect to www
|
194
|
+
# # if ($host ~* "^[ec2onrails].com$"){
|
195
|
+
# # rewrite ^(.*)$ http://www.[ec2onrails].com$1 permanent;
|
196
|
+
# # break;
|
197
|
+
# # }
|
198
|
+
#
|
199
|
+
# ssl on;
|
200
|
+
# ssl_certificate /etc/nginx/your_cert.crt;
|
201
|
+
# ssl_certificate_key /etc/nginx/your_cert.key;
|
202
|
+
#
|
203
|
+
# # doc root
|
204
|
+
# root /mnt/app/current/public;
|
205
|
+
#
|
206
|
+
# # vhost specific access log
|
207
|
+
# access_log /mnt/log/nginx/vhost.access.log main;
|
208
|
+
# error_page 400 /400.html;
|
209
|
+
# error_page 500 502 503 504 /500.html;
|
210
|
+
# location = /500.html {
|
211
|
+
# root /mnt/app/current/public;
|
212
|
+
# }
|
213
|
+
#
|
214
|
+
# # this allows people to use images and css in their maintenance.html file
|
215
|
+
# if ($request_filename ~* \.(css|jpg|gif|png)$) {
|
216
|
+
# break;
|
217
|
+
# }
|
218
|
+
#
|
219
|
+
# # this rewrites all the requests to the maintenance.html
|
220
|
+
# # page if it exists in the doc root. This is for capistrano's
|
221
|
+
# # disable web task
|
222
|
+
# if (-f $document_root/system/maintenance.html) {
|
223
|
+
# rewrite ^(.*)$ /system/maintenance.html last;
|
224
|
+
# break;
|
225
|
+
# }
|
226
|
+
#
|
227
|
+
# # see http://wiki.codemongers.com/NginxHttpStubStatusModule
|
228
|
+
# # for more information
|
229
|
+
# location /nginx_status {
|
230
|
+
# # copied from http://blog.kovyrin.net/2006/04/29/monitoring-nginx-with-rrdtool/
|
231
|
+
# stub_status on;
|
232
|
+
# access_log off;
|
233
|
+
# #only allow from localhost
|
234
|
+
# allow 127.0.0.1;
|
235
|
+
# deny all;
|
236
|
+
# }
|
237
|
+
#
|
238
|
+
# location / {
|
239
|
+
# # FUTURE TODO...enable this and test the hell out of it
|
240
|
+
# # if ($request_method = GET) {
|
241
|
+
# # set $memcached_key $uri;
|
242
|
+
# # memcached_pass 127.0.0.1:11211;
|
243
|
+
# # error_page 404 502 = @myapp;
|
244
|
+
# # break;
|
245
|
+
# # }
|
246
|
+
#
|
247
|
+
# index index.html index.htm;
|
248
|
+
#
|
249
|
+
# # needed to forward user's IP address to rails
|
250
|
+
# proxy_set_header X-Real-IP $remote_addr;
|
251
|
+
# # needed for HTTPS
|
252
|
+
# proxy_set_header X_FORWARDED_PROTO https;
|
253
|
+
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
254
|
+
# proxy_set_header Host $http_host;
|
255
|
+
# proxy_redirect false;
|
256
|
+
# proxy_max_temp_file_size 0;
|
257
|
+
# proxy_next_upstream error; # do not pass along to another mongrel instance if failed or timed out
|
258
|
+
# proxy_read_timeout 400; # give plenty of time for long-running rails processing tasks
|
259
|
+
# #the proxy_connect_timeout cannot be more than 75
|
260
|
+
# proxy_connect_timeout 70;
|
261
|
+
#
|
262
|
+
# location ~ ^/(images|javascripts|stylesheets)/ {
|
263
|
+
# expires 10y;
|
264
|
+
# }
|
265
|
+
#
|
266
|
+
# if (-f $request_filename) {
|
267
|
+
# break;
|
268
|
+
# }
|
269
|
+
#
|
270
|
+
# # this is the meat of the rails page caching config
|
271
|
+
# # it adds .html to the end of the url and then checks
|
272
|
+
# # the filesystem for that file. If it exists, then we
|
273
|
+
# # rewite the url to have explicit .html on the end
|
274
|
+
# # and then send it on its way to the next config rule.
|
275
|
+
# # if there is no file on the fs then it sets all the
|
276
|
+
# # necessary headers and proxies to our upstream mongrels
|
277
|
+
# if (-f $request_filename.html) {
|
278
|
+
# rewrite (.*) $1.html break;
|
279
|
+
# }
|
280
|
+
#
|
281
|
+
# # ok to have this out here because PDF's should never
|
282
|
+
# # be fully paged cache anyway
|
283
|
+
# if ($request_filename ~* \.pdf$) {
|
284
|
+
# proxy_pass http://mongrel_pdf;
|
285
|
+
# break;
|
286
|
+
# }
|
287
|
+
#
|
288
|
+
# if (!-f $request_filename) {
|
289
|
+
# proxy_pass http://mongrel;
|
290
|
+
# break;
|
291
|
+
# }
|
292
|
+
# }
|
293
|
+
#
|
294
|
+
# }
|
295
|
+
}
|
296
|
+
|