arpitjain11-ec2onrails 0.9.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (163) hide show
  1. data/CHANGELOG +180 -0
  2. data/COPYING +339 -0
  3. data/Manifest +162 -0
  4. data/README.textile +214 -0
  5. data/Rakefile +36 -0
  6. data/TODO +102 -0
  7. data/ec2onrails.gemspec +42 -0
  8. data/examples/Capfile +3 -0
  9. data/examples/deploy.rb +101 -0
  10. data/examples/s3.yml +9 -0
  11. data/lib/ec2onrails.rb +20 -0
  12. data/lib/ec2onrails/capistrano_utils.rb +43 -0
  13. data/lib/ec2onrails/recipes.rb +844 -0
  14. data/lib/ec2onrails/version.rb +31 -0
  15. data/server/build-ec2onrails.sh +44 -0
  16. data/server/files/etc/aliases +5 -0
  17. data/server/files/etc/aliases.db +0 -0
  18. data/server/files/etc/apache2/apache2.conf +295 -0
  19. data/server/files/etc/apache2/conf.d/app.proxy_cluster.conf +7 -0
  20. data/server/files/etc/apache2/conf.d/app.proxy_frontend.conf +10 -0
  21. data/server/files/etc/apache2/mods-available/proxy.conf +18 -0
  22. data/server/files/etc/apache2/sites-available/app.common +56 -0
  23. data/server/files/etc/apache2/sites-available/app.custom +0 -0
  24. data/server/files/etc/apache2/sites-available/default +14 -0
  25. data/server/files/etc/apache2/sites-available/default-ssl +19 -0
  26. data/server/files/etc/cron.d/backup_app_db_to_s3 +16 -0
  27. data/server/files/etc/cron.daily/app +9 -0
  28. data/server/files/etc/cron.daily/logrotate_post +19 -0
  29. data/server/files/etc/cron.hourly/app +10 -0
  30. data/server/files/etc/cron.monthly/app +10 -0
  31. data/server/files/etc/cron.weekly/app +10 -0
  32. data/server/files/etc/denyhosts.conf +628 -0
  33. data/server/files/etc/dpkg/dpkg.cfg +13 -0
  34. data/server/files/etc/ec2onrails/README +32 -0
  35. data/server/files/etc/ec2onrails/balancer_members +6 -0
  36. data/server/files/etc/ec2onrails/roles.yml +5 -0
  37. data/server/files/etc/environment +2 -0
  38. data/server/files/etc/god/app.god +35 -0
  39. data/server/files/etc/god/db.god +17 -0
  40. data/server/files/etc/god/examples/have_god_daemonize.god +18 -0
  41. data/server/files/etc/god/master.conf +35 -0
  42. data/server/files/etc/god/memcache.god +15 -0
  43. data/server/files/etc/god/notifications.god +14 -0
  44. data/server/files/etc/god/system.god +34 -0
  45. data/server/files/etc/god/web.god +36 -0
  46. data/server/files/etc/init.d/ec2-every-startup +29 -0
  47. data/server/files/etc/init.d/ec2-first-startup +36 -0
  48. data/server/files/etc/init.d/god +42 -0
  49. data/server/files/etc/init.d/nginx +78 -0
  50. data/server/files/etc/init.d/set_roles +3 -0
  51. data/server/files/etc/logrotate.d/apache2 +16 -0
  52. data/server/files/etc/logrotate.d/mongrel +11 -0
  53. data/server/files/etc/logrotate.d/nginx +11 -0
  54. data/server/files/etc/memcached.conf +47 -0
  55. data/server/files/etc/mongrel_cluster/app.yml +9 -0
  56. data/server/files/etc/motd.tail +13 -0
  57. data/server/files/etc/mysql/my.cnf +152 -0
  58. data/server/files/etc/nginx/nginx.conf +296 -0
  59. data/server/files/etc/postfix/main.cf +4 -0
  60. data/server/files/etc/rcS.d/S91ec2-first-startup +1 -0
  61. data/server/files/etc/rcS.d/S92ec2-every-startup +1 -0
  62. data/server/files/etc/rcS.d/S99set_roles +1 -0
  63. data/server/files/etc/ssh/sshd_config +94 -0
  64. data/server/files/etc/sudoers +1 -0
  65. data/server/files/etc/sudoers.full_access +26 -0
  66. data/server/files/etc/sudoers.restricted_access +28 -0
  67. data/server/files/etc/syslog.conf +69 -0
  68. data/server/files/usr/bin/god +26 -0
  69. data/server/files/usr/local/ec2onrails/COPYING +339 -0
  70. data/server/files/usr/local/ec2onrails/bin/archive_file.rb +44 -0
  71. data/server/files/usr/local/ec2onrails/bin/backup_app_db.rb +159 -0
  72. data/server/files/usr/local/ec2onrails/bin/ec2_meta_data.rb +80 -0
  73. data/server/files/usr/local/ec2onrails/bin/exec_runner +73 -0
  74. data/server/files/usr/local/ec2onrails/bin/init_services.rb +64 -0
  75. data/server/files/usr/local/ec2onrails/bin/optimize_mysql.rb +348 -0
  76. data/server/files/usr/local/ec2onrails/bin/rails_env +35 -0
  77. data/server/files/usr/local/ec2onrails/bin/rebundle.sh +70 -0
  78. data/server/files/usr/local/ec2onrails/bin/restore_app_db.rb +58 -0
  79. data/server/files/usr/local/ec2onrails/bin/set_rails_env +40 -0
  80. data/server/files/usr/local/ec2onrails/bin/set_roles.rb +87 -0
  81. data/server/files/usr/local/ec2onrails/bin/setup_web_proxy.rb +109 -0
  82. data/server/files/usr/local/ec2onrails/config +30 -0
  83. data/server/files/usr/local/ec2onrails/lib/aws_helper.rb +76 -0
  84. data/server/files/usr/local/ec2onrails/lib/god_helper.rb +129 -0
  85. data/server/files/usr/local/ec2onrails/lib/god_patch.rb +43 -0
  86. data/server/files/usr/local/ec2onrails/lib/mysql_helper.rb +101 -0
  87. data/server/files/usr/local/ec2onrails/lib/roles_helper.rb +151 -0
  88. data/server/files/usr/local/ec2onrails/lib/s3_helper.rb +99 -0
  89. data/server/files/usr/local/ec2onrails/lib/utils.rb +16 -0
  90. data/server/files/usr/local/ec2onrails/lib/vendor/ini.rb +268 -0
  91. data/server/files/usr/local/ec2onrails/startup-scripts/every-startup/get-hostname.sh +25 -0
  92. data/server/files/usr/local/ec2onrails/startup-scripts/first-startup/README +5 -0
  93. data/server/files/usr/local/ec2onrails/startup-scripts/first-startup/create-dirs.sh +39 -0
  94. data/server/files/usr/local/ec2onrails/startup-scripts/first-startup/generate-default-web-cert-and-key.sh +49 -0
  95. data/server/files/usr/local/ec2onrails/startup-scripts/first-startup/misc.sh +27 -0
  96. data/server/files/usr/local/ec2onrails/startup-scripts/first-startup/prepare-mysql-data-dir.sh +24 -0
  97. data/server/files/usr/local/ec2onrails/startup-scripts/first-startup/setup-credentials.sh +29 -0
  98. data/server/files/usr/local/ec2onrails/startup-scripts/first-startup/setup-file-permissions.sh +30 -0
  99. data/server/rakefile.rb +248 -0
  100. data/setup.rb +1585 -0
  101. data/test/autobench.conf +60 -0
  102. data/test/spec/lib/s3_helper_spec.rb +134 -0
  103. data/test/spec/lib/s3_old.yml +3 -0
  104. data/test/spec/test_files/test1 +0 -0
  105. data/test/spec/test_files/test2 +0 -0
  106. data/test/test_app/Capfile +3 -0
  107. data/test/test_app/README +182 -0
  108. data/test/test_app/Rakefile +10 -0
  109. data/test/test_app/app/controllers/application.rb +7 -0
  110. data/test/test_app/app/controllers/db_fast_controller.rb +6 -0
  111. data/test/test_app/app/controllers/fast_controller.rb +5 -0
  112. data/test/test_app/app/controllers/slow_controller.rb +6 -0
  113. data/test/test_app/app/controllers/very_slow_controller.rb +6 -0
  114. data/test/test_app/app/helpers/application_helper.rb +3 -0
  115. data/test/test_app/app/helpers/db_fast_helper.rb +2 -0
  116. data/test/test_app/app/helpers/fast_helper.rb +2 -0
  117. data/test/test_app/app/helpers/slow_helper.rb +2 -0
  118. data/test/test_app/app/helpers/very_slow_helper.rb +2 -0
  119. data/test/test_app/config/boot.rb +109 -0
  120. data/test/test_app/config/database.yml +19 -0
  121. data/test/test_app/config/deploy.rb +21 -0
  122. data/test/test_app/config/environment.rb +60 -0
  123. data/test/test_app/config/environments/development.rb +21 -0
  124. data/test/test_app/config/environments/production.rb +18 -0
  125. data/test/test_app/config/environments/test.rb +19 -0
  126. data/test/test_app/config/routes.rb +27 -0
  127. data/test/test_app/db/schema.rb +7 -0
  128. data/test/test_app/doc/README_FOR_APP +2 -0
  129. data/test/test_app/public/404.html +30 -0
  130. data/test/test_app/public/500.html +30 -0
  131. data/test/test_app/public/dispatch.cgi +10 -0
  132. data/test/test_app/public/dispatch.fcgi +24 -0
  133. data/test/test_app/public/dispatch.rb +10 -0
  134. data/test/test_app/public/favicon.ico +0 -0
  135. data/test/test_app/public/images/rails.png +0 -0
  136. data/test/test_app/public/javascripts/application.js +2 -0
  137. data/test/test_app/public/javascripts/controls.js +963 -0
  138. data/test/test_app/public/javascripts/dragdrop.js +972 -0
  139. data/test/test_app/public/javascripts/effects.js +1120 -0
  140. data/test/test_app/public/javascripts/prototype.js +4225 -0
  141. data/test/test_app/public/robots.txt +1 -0
  142. data/test/test_app/script/about +3 -0
  143. data/test/test_app/script/breakpointer +3 -0
  144. data/test/test_app/script/console +3 -0
  145. data/test/test_app/script/destroy +3 -0
  146. data/test/test_app/script/generate +3 -0
  147. data/test/test_app/script/performance/benchmarker +3 -0
  148. data/test/test_app/script/performance/profiler +3 -0
  149. data/test/test_app/script/performance/request +3 -0
  150. data/test/test_app/script/plugin +3 -0
  151. data/test/test_app/script/process/inspector +3 -0
  152. data/test/test_app/script/process/reaper +3 -0
  153. data/test/test_app/script/process/spawner +3 -0
  154. data/test/test_app/script/runner +3 -0
  155. data/test/test_app/script/server +3 -0
  156. data/test/test_app/test/functional/db_fast_controller_test.rb +18 -0
  157. data/test/test_app/test/functional/fast_controller_test.rb +18 -0
  158. data/test/test_app/test/functional/slow_controller_test.rb +18 -0
  159. data/test/test_app/test/functional/very_slow_controller_test.rb +18 -0
  160. data/test/test_app/test/test_helper.rb +28 -0
  161. data/test/test_ec2onrails.rb +11 -0
  162. data/test/test_helper.rb +2 -0
  163. metadata +278 -0
@@ -0,0 +1,3 @@
1
+ #!/bin/sh
2
+
3
+ /usr/local/ec2onrails/bin/set_roles.rb
@@ -0,0 +1,16 @@
1
+ /mnt/log/apache2/*.log {
2
+ daily
3
+ missingok
4
+ dateext
5
+ create 640 root app
6
+ compress
7
+ notifempty
8
+ sharedscripts
9
+ extension gz
10
+ copytruncate
11
+ postrotate
12
+ if [ -f /var/run/apache2.pid ]; then
13
+ /etc/init.d/apache2 reload > /dev/null
14
+ fi
15
+ endscript
16
+ }
@@ -0,0 +1,11 @@
1
+ /mnt/app/current/log/*/*.log /mnt/app/current/log/*.log {
2
+ daily
3
+ missingok
4
+ dateext
5
+ rotate 365
6
+ compress
7
+ notifempty
8
+ sharedscripts
9
+ extension gz
10
+ copytruncate
11
+ }
@@ -0,0 +1,11 @@
1
+ /mnt/log/nginx/*.log {
2
+ daily
3
+ missingok
4
+ dateext
5
+ compress
6
+ create 640 root app
7
+ notifempty
8
+ sharedscripts
9
+ extension gz
10
+ copytruncate
11
+ }
@@ -0,0 +1,47 @@
1
+ # memcached default config file
2
+ # 2003 - Jay Bonci <jaybonci@debian.org>
3
+ # This configuration file is read by the start-memcached script provided as
4
+ # part of the Debian GNU/Linux distribution.
5
+
6
+ # Run memcached as a daemon. This command is implied, and is not needed for the
7
+ # daemon to run. See the README.Debian that comes with this package for more
8
+ # information.
9
+ -d
10
+
11
+ # Log memcached's output to /var/log/memcached
12
+ logfile /mnt/log/memcached.log
13
+
14
+ # Be verbose
15
+ # -v
16
+
17
+ # Be even more verbose (print client commands as well)
18
+ # -vv
19
+
20
+ # Start with a cap of 64 megs of memory. It's reasonable, and the daemon default
21
+ # Note that the daemon will grow to this size, but does not start out holding this much
22
+ # memory
23
+ -m 128
24
+
25
+ # Default connection port is 11211
26
+ -p 11211
27
+
28
+ # Run the daemon as root. The start-memcached will default to running as root if no
29
+ # -u command is present in this config file
30
+ -u nobody
31
+
32
+ # Specify which IP address to listen on. The default is to listen on all IP addresses
33
+ # This parameter is one of the only security measures that memcached has, so make sure
34
+ # it's listening on a firewalled interface.
35
+ #-l 127.0.0.1
36
+
37
+ # Limit the number of simultaneous incoming connections. The daemon default is 1024
38
+ # -c 1024
39
+
40
+ # Lock down all paged memory. Consult with the README and homepage before you do this
41
+ # -k
42
+
43
+ # Return error when memory is exhausted (rather than removing items)
44
+ # -M
45
+
46
+ # Maximize core file limit
47
+ # -r
@@ -0,0 +1,9 @@
1
+ ---
2
+ cwd: /mnt/app/current
3
+ port: "8000"
4
+ environment: production
5
+ pid_file: log/mongrel.pid
6
+ servers: 6
7
+ daemon: true
8
+ user: app
9
+ group: app
@@ -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,152 @@
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
+ character-set-server = utf8
46
+ collation-server = utf8_general_ci
47
+
48
+ #
49
+ # Instead of skip-networking the default is now to listen only on
50
+ # localhost which is more compatible and is not less secure.
51
+ #bind-address = 127.0.0.1
52
+ #
53
+ # * Fine Tuning
54
+ #
55
+ key_buffer_size = 16M
56
+ max_allowed_packet = 16M
57
+ thread_stack = 128K
58
+ thread_cache_size = 8
59
+ #max_connections = 100
60
+ #table_cache = 64
61
+ #thread_concurrency = 10
62
+ #
63
+ # * Query Cache Configuration
64
+ #
65
+ query_cache_limit = 1M
66
+ query_cache_size = 64M
67
+ #
68
+ # * Logging and Replication
69
+ #
70
+ # Both location gets rotated by the cronjob.
71
+ # Be aware that this log type is a performance killer.
72
+ #log = /var/log/mysql/mysql.log
73
+ #
74
+ # Error logging goes to syslog. This is a Debian improvement :)
75
+ #
76
+ # Here you can see queries with especially long duration
77
+ log_slow_queries = /mnt/log/mysql/mysql-slow.log
78
+ long_query_time = 2
79
+ log-queries-not-using-indexes
80
+ #
81
+ # The following can be used as easy to replay backup logs or for replication.
82
+ #server-id = 1
83
+ log_bin = /mnt/log/mysql/mysql-bin.log
84
+ # WARNING: Using expire_logs_days without bin_log crashes the server! See README.Debian!
85
+ expire_logs_days = 10
86
+ max_binlog_size = 100M
87
+ #binlog_do_db = include_database_name
88
+ #binlog_ignore_db = include_database_name
89
+ #
90
+ # * BerkeleyDB
91
+ #
92
+ # Using BerkeleyDB is now discouraged as its support will cease in 5.1.12.
93
+ skip-bdb
94
+ #
95
+ # * InnoDB
96
+ #
97
+ # InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/.
98
+ # Read the manual for more InnoDB related options. There are many!
99
+ # You might want to disable InnoDB to shrink the mysqld process by circa 100MB.
100
+ #skip-innodb
101
+ innodb_data_file_path=ibdata1:100M:autoextend
102
+ innodb_buffer_pool_size=200M
103
+ innodb_additional_mem_pool_size=20M
104
+ innodb_log_file_size=128M
105
+ innodb_log_buffer_size=8M
106
+ innodb_flush_log_at_trx_commit=1
107
+ innodb_lock_wait_timeout=20
108
+ # innodb_flush_method=O_DIRECT
109
+ innodb_file_per_table
110
+
111
+ #
112
+ # * Security Features
113
+ #
114
+ # Read the manual, too, if you want chroot!
115
+ # chroot = /var/lib/mysql/
116
+ #
117
+ # For generating SSL certificates I recommend the OpenSSL GUI "tinyca".
118
+ #
119
+ # ssl-ca=/etc/mysql/cacert.pem
120
+ # ssl-cert=/etc/mysql/server-cert.pem
121
+ # ssl-key=/etc/mysql/server-key.pem
122
+
123
+
124
+
125
+ [mysqldump]
126
+ quick
127
+ quote-names
128
+ max_allowed_packet = 16M
129
+
130
+ [mysql]
131
+ default-character-set = utf8
132
+ #no-auto-rehash # faster start of mysql but no tab completition
133
+
134
+ [isamchk]
135
+ key_buffer = 16M
136
+
137
+ #
138
+ # * NDB Cluster
139
+ #
140
+ # See /usr/share/doc/mysql-server-*/README.Debian for more information.
141
+ #
142
+ # The following configuration is read by the NDB Data Nodes (ndbd processes)
143
+ # not from the NDB Management Nodes (ndb_mgmd processes).
144
+ #
145
+ # [MYSQL_CLUSTER]
146
+ # ndb-connectstring=127.0.0.1
147
+
148
+
149
+ #
150
+ # * IMPORTANT: Additional settings that can override those from this file!
151
+ #
152
+ !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 5;
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
+