capistrano-kitchen 0.0.0.pre
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.
- checksums.yaml +7 -0
- data/.gitignore +23 -0
- data/.rspec +2 -0
- data/.ruby-gemset.template +1 -0
- data/.ruby-version.template +1 -0
- data/.travis.yml +7 -0
- data/.yardopts +5 -0
- data/Gemfile +8 -0
- data/Guardfile +13 -0
- data/LICENSE.txt +46 -0
- data/Rakefile +14 -0
- data/capistrano-kitchen.gemspec +29 -0
- data/lib/capistrano-kitchen.rb +41 -0
- data/lib/capistrano_kitchen/dishes/aptitude/manage.rb +38 -0
- data/lib/capistrano_kitchen/dishes/bundler/hooks.rb +7 -0
- data/lib/capistrano_kitchen/dishes/bundler/install.rb +79 -0
- data/lib/capistrano_kitchen/dishes/git/hooks.rb +3 -0
- data/lib/capistrano_kitchen/dishes/git/install.rb +18 -0
- data/lib/capistrano_kitchen/dishes/java_7_oracle/hooks.rb +5 -0
- data/lib/capistrano_kitchen/dishes/java_7_oracle/install.rb +17 -0
- data/lib/capistrano_kitchen/dishes/nginx_unicorn/app.conf +66 -0
- data/lib/capistrano_kitchen/dishes/nginx_unicorn/hooks.rb +11 -0
- data/lib/capistrano_kitchen/dishes/nginx_unicorn/install.rb +176 -0
- data/lib/capistrano_kitchen/dishes/nginx_unicorn/manage.rb +1 -0
- data/lib/capistrano_kitchen/dishes/nginx_unicorn/mime.types.erb +79 -0
- data/lib/capistrano_kitchen/dishes/nginx_unicorn/nginx.conf +138 -0
- data/lib/capistrano_kitchen/dishes/nginx_unicorn/nginx_unicorn.god +47 -0
- data/lib/capistrano_kitchen/dishes/nginx_unicorn/nginx_unicorn.init +95 -0
- data/lib/capistrano_kitchen/dishes/nginx_unicorn/nginx_unicorn.logrotate +18 -0
- data/lib/capistrano_kitchen/dishes/nginx_unicorn/stub_status.conf +16 -0
- data/lib/capistrano_kitchen/dishes/nodejs/hooks.rb +4 -0
- data/lib/capistrano_kitchen/dishes/nodejs/install.rb +13 -0
- data/lib/capistrano_kitchen/dishes/provision/empty_roles.rb +60 -0
- data/lib/capistrano_kitchen/dishes/provision/manage.rb +49 -0
- data/lib/capistrano_kitchen/dishes/provision/task_once.rb +62 -0
- data/lib/capistrano_kitchen/dishes/ruby/hooks.rb +7 -0
- data/lib/capistrano_kitchen/dishes/ruby/install.rb +55 -0
- data/lib/capistrano_kitchen/dishes/teelogger/teelogger.rb +121 -0
- data/lib/capistrano_kitchen/dishes/unicorn/hooks.rb +9 -0
- data/lib/capistrano_kitchen/dishes/unicorn/install.rb +120 -0
- data/lib/capistrano_kitchen/dishes/unicorn/unicorn.god +71 -0
- data/lib/capistrano_kitchen/dishes/unicorn/unicorn.rb.erb +191 -0
- data/lib/capistrano_kitchen/recipes/aptitude.rb +1 -0
- data/lib/capistrano_kitchen/recipes/bundler.rb +1 -0
- data/lib/capistrano_kitchen/recipes/git.rb +1 -0
- data/lib/capistrano_kitchen/recipes/java_7_oracle.rb +1 -0
- data/lib/capistrano_kitchen/recipes/nginx_unicorn.rb +1 -0
- data/lib/capistrano_kitchen/recipes/nodejs.rb +1 -0
- data/lib/capistrano_kitchen/recipes/provision.rb +1 -0
- data/lib/capistrano_kitchen/recipes/ruby.rb +1 -0
- data/lib/capistrano_kitchen/recipes/teelogger.rb +1 -0
- data/lib/capistrano_kitchen/recipes/unicorn.rb +1 -0
- data/lib/capistrano_kitchen/recipes/utilities.rb +442 -0
- data/lib/capistrano_kitchen/version.rb +3 -0
- data/spec/capistrano_kitchen_spec.rb +5 -0
- data/spec/spec_helper.rb +21 -0
- metadata +200 -0
@@ -0,0 +1,11 @@
|
|
1
|
+
# @author Donovan Bray <donnoman@donovanbray.com>
|
2
|
+
|
3
|
+
Capistrano::Configuration.instance(true).load do
|
4
|
+
after "deploy:provision", "nginx_unicorn:install"
|
5
|
+
after "deploy:setup", "nginx_unicorn:setup"
|
6
|
+
after "logrotate:rotate", "nginx_unicorn:reopen"
|
7
|
+
after "sdagent:setup", "nginx_unicorn:setup_sdagent"
|
8
|
+
after "nginx_unicorn:install", "nginx_unicorn:setup"
|
9
|
+
after "nginx_unicorn:setup", "nginx_unicorn:configure"
|
10
|
+
on :load, "nginx_unicorn:watcher"
|
11
|
+
end
|
@@ -0,0 +1,176 @@
|
|
1
|
+
# @author Donovan Bray <donnoman@donovanbray.com>
|
2
|
+
require File.expand_path(File.dirname(__FILE__) + '/../utilities')
|
3
|
+
|
4
|
+
# This Nginx is targeted for the :app role meant to be acting as a front end
|
5
|
+
# to a unicorn based application
|
6
|
+
|
7
|
+
# Additions
|
8
|
+
# https://github.com/newobj/nginx-x-rid-header
|
9
|
+
# https://github.com/yaoweibin/nginx_syslog_patch
|
10
|
+
|
11
|
+
# Possible Future Additions
|
12
|
+
# https://support.newrelic.com/kb/features/tracking-front-end-time
|
13
|
+
|
14
|
+
Capistrano::Configuration.instance(true).load do
|
15
|
+
|
16
|
+
namespace :nginx_unicorn do
|
17
|
+
set :nginx_unicorn_init_d, "nginx_unicorn"
|
18
|
+
set :nginx_unicorn_root, "/opt/nginx_unicorn"
|
19
|
+
set :nginx_unicorn_conf_path, File.join(File.dirname(__FILE__),'nginx.conf')
|
20
|
+
set(:nginx_unicorn_conf_dir) {"#{nginx_unicorn_root}/conf"}
|
21
|
+
set :nginx_unicorn_init_d_path, File.join(File.dirname(__FILE__),'nginx_unicorn.init')
|
22
|
+
set :nginx_unicorn_stub_conf_path, File.join(File.dirname(__FILE__),'stub_status.conf')
|
23
|
+
set :nginx_unicorn_god_path, File.join(File.dirname(__FILE__),'nginx_unicorn.god')
|
24
|
+
set :nginx_unicorn_logrotate_path, File.join(File.dirname(__FILE__),'nginx_unicorn.logrotate')
|
25
|
+
set :nginx_unicorn_mime_types_erb, File.join(File.dirname(__FILE__),'mime.types.erb')
|
26
|
+
# must be above 1.1.7 http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2012-1180
|
27
|
+
set :nginx_unicorn_src, "http://nginx.org/download/nginx-1.2.0.tar.gz"
|
28
|
+
set(:nginx_unicorn_ver) { nginx_unicorn_src.match(/\/([^\/]*)\.tar\.gz$/)[1] }
|
29
|
+
set(:nginx_unicorn_source_dir) {"#{nginx_unicorn_root}/src/#{nginx_unicorn_ver}"}
|
30
|
+
set(:nginx_unicorn_patch_dir) {"#{nginx_unicorn_root}/src"}
|
31
|
+
set(:nginx_unicorn_upstream_socket){"#{shared_path}/sockets/unicorn.sock"}
|
32
|
+
set(:nginx_unicorn_log_dir) {"#{nginx_unicorn_root}/logs"}
|
33
|
+
set(:nginx_unicorn_pid_file) {"#{nginx_unicorn_log_dir}/nginx.pid"}
|
34
|
+
set(:nginx_unicorn_sbin_file) {"#{nginx_unicorn_root}/sbin/nginx"}
|
35
|
+
set :nginx_unicorn_watcher, nil
|
36
|
+
set :nginx_unicorn_user, "nobody"
|
37
|
+
set :nginx_unicorn_suppress_runner, false
|
38
|
+
set :nginx_unicorn_port, '80'
|
39
|
+
set :nginx_unicorn_server_name, 'localhost'
|
40
|
+
set :nginx_unicorn_app_conf_path, File.join(File.dirname(__FILE__),'app.conf')
|
41
|
+
set :nginx_unicorn_set_scheme, true
|
42
|
+
set :nginx_unicorn_worker_processes, "1" # should be cpu's - 1
|
43
|
+
set :nginx_unicorn_gzip, true
|
44
|
+
set :nginx_unicorn_fail_timeout, nil
|
45
|
+
set :nginx_unicorn_syslog_patch, true
|
46
|
+
set :nginx_unicorn_rid_header_patch, false # while we want this to be true by default it makes the configurations incompatible
|
47
|
+
# with the previous default. Which can cause a working NGINX to stop working until recompiled.
|
48
|
+
set :nginx_unicorn_use_503_instead_of_502, false # useful if you are behind a load balancer that only understands 503's.
|
49
|
+
|
50
|
+
set(:nginx_unicorn_configure_flags) {[
|
51
|
+
"--prefix=#{nginx_unicorn_root}",
|
52
|
+
"--sbin-path=#{nginx_unicorn_sbin_file}",
|
53
|
+
"--pid-path=#{nginx_unicorn_pid_file}",
|
54
|
+
"--conf-path=#{nginx_unicorn_conf_dir}/nginx.conf",
|
55
|
+
"--with-debug",
|
56
|
+
"--with-http_gzip_static_module",
|
57
|
+
"--with-http_stub_status_module",
|
58
|
+
"--with-http_ssl_module",
|
59
|
+
"--with-ld-opt=-lossp-uuid",
|
60
|
+
"--with-cc-opt=-I/usr/include/ossp"
|
61
|
+
]}
|
62
|
+
|
63
|
+
desc "select watcher"
|
64
|
+
task :watcher do
|
65
|
+
nginx_unicorn.send("watch_with_#{nginx_unicorn_watcher}".to_sym) unless nginx_unicorn_watcher.nil?
|
66
|
+
end
|
67
|
+
|
68
|
+
desc "Use GOD as nginx_unicorn's runner"
|
69
|
+
task :watch_with_god do
|
70
|
+
#rejigger the maintenance tasks to use god when god is in play
|
71
|
+
%w(start stop restart).each do |t|
|
72
|
+
task t.to_sym, :roles => :app do
|
73
|
+
god.cmd "#{t} nginx_unicorn" unless nginx_unicorn_suppress_runner
|
74
|
+
end
|
75
|
+
end
|
76
|
+
after "god:setup", "nginx_unicorn:setup_god"
|
77
|
+
end
|
78
|
+
|
79
|
+
desc "setup god to watch nginx_unicorn"
|
80
|
+
task :setup_god, :roles => :app do
|
81
|
+
god.upload nginx_unicorn_god_path, 'nginx_unicorn.god'
|
82
|
+
end
|
83
|
+
|
84
|
+
desc 'Installs nginx for unicorn'
|
85
|
+
task :install, :roles => :app do
|
86
|
+
utilities.apt_install "libssl-dev zlib1g-dev libcurl4-openssl-dev libpcre3-dev libossp-uuid-dev git-core"
|
87
|
+
sudo "mkdir -p #{nginx_unicorn_source_dir}"
|
88
|
+
run "cd #{nginx_unicorn_root}/src && #{sudo} wget --tries=2 -c --progress=bar:force #{nginx_unicorn_src} && #{sudo} tar zxvf #{nginx_unicorn_ver}.tar.gz"
|
89
|
+
if nginx_unicorn_syslog_patch
|
90
|
+
nginx_unicorn_configure_flags << "--add-module=#{nginx_unicorn_patch_dir}/nginx_syslog_patch"
|
91
|
+
utilities.git_clone_or_pull "git://github.com/yaoweibin/nginx_syslog_patch.git", "#{nginx_unicorn_patch_dir}/nginx_syslog_patch"
|
92
|
+
run "cd #{nginx_unicorn_source_dir} && #{sudo} sh -c 'patch -p1 < #{nginx_unicorn_patch_dir}/nginx_syslog_patch/syslog_#{nginx_unicorn_ver.split('-').last}.patch'"
|
93
|
+
end
|
94
|
+
if nginx_unicorn_rid_header_patch
|
95
|
+
nginx_unicorn_configure_flags << "--add-module=#{nginx_unicorn_patch_dir}/nginx-x-rid-header"
|
96
|
+
utilities.git_clone_or_pull "git://github.com/newobj/nginx-x-rid-header.git", "#{nginx_unicorn_patch_dir}/nginx-x-rid-header"
|
97
|
+
end
|
98
|
+
run "cd #{nginx_unicorn_source_dir} && #{sudo} ./configure #{nginx_unicorn_configure_flags.join(" ")} && #{sudo} make"
|
99
|
+
run "cd #{nginx_unicorn_source_dir} && #{sudo} make install"
|
100
|
+
end
|
101
|
+
|
102
|
+
task :setup, :roles => :app do
|
103
|
+
sudo "mkdir -p #{nginx_unicorn_conf_dir}/sites-available #{nginx_unicorn_conf_dir}/sites-enabled #{nginx_unicorn_log_dir}"
|
104
|
+
utilities.sudo_upload_template nginx_unicorn_conf_path,"#{nginx_unicorn_conf_dir}/nginx.conf"
|
105
|
+
utilities.sudo_upload_template nginx_unicorn_mime_types_erb,"#{nginx_unicorn_conf_dir}/mime.types"
|
106
|
+
utilities.sudo_upload_template nginx_unicorn_stub_conf_path,"#{nginx_unicorn_conf_dir}/sites-available/stub_status.conf"
|
107
|
+
sudo "ln -sf #{nginx_unicorn_conf_dir}/sites-available/stub_status.conf #{nginx_unicorn_conf_dir}/sites-enabled/stub_status.conf"
|
108
|
+
utilities.sudo_upload_template nginx_unicorn_init_d_path,"/etc/init.d/#{nginx_unicorn_init_d}", :mode => "u+x"
|
109
|
+
utilities.sudo_upload_template nginx_unicorn_logrotate_path,"/etc/logrotate.d/#{nginx_unicorn_init_d}"
|
110
|
+
end
|
111
|
+
|
112
|
+
desc "Nginx Unicorn Reload"
|
113
|
+
task :reload, :roles => :app do
|
114
|
+
sudo "/etc/init.d/#{nginx_unicorn_init_d} reload"
|
115
|
+
end
|
116
|
+
|
117
|
+
desc "Nginx Unicorn Reopen"
|
118
|
+
task :reopen, :roles => :app do
|
119
|
+
sudo "/etc/init.d/#{nginx_unicorn_init_d} reopen"
|
120
|
+
end
|
121
|
+
|
122
|
+
task :remove_default, :roles => :app do
|
123
|
+
sudo "rm -f #{nginx_unicorn_conf_dir}/sites-enabled/default"
|
124
|
+
end
|
125
|
+
|
126
|
+
desc "Watch Nginx and Unicorn Workers with GOD"
|
127
|
+
task :setup_god, :roles => :app do
|
128
|
+
god.upload nginx_unicorn_god_path, "#{nginx_unicorn_init_d}.god"
|
129
|
+
# disable init from automatically starting and stopping these init controlled apps
|
130
|
+
# god will be started by init, and in turn start these god controlled apps.
|
131
|
+
# but leave the init script in place to be called manually
|
132
|
+
sudo "update-rc.d -f nginx_unicorn remove; true"
|
133
|
+
#if you simply remove lsb driven links an apt-get can later reinstall them
|
134
|
+
#so we explicitly define the kill scripts.
|
135
|
+
sudo "update-rc.d nginx_unicorn stop 20 2 3 4 5 .; true"
|
136
|
+
end
|
137
|
+
|
138
|
+
desc "Setup sd-agent to collect metrics for nginx"
|
139
|
+
task :setup_sdagent, :roles => :app do
|
140
|
+
# block executing this task if :sdagent isn't present on any :app servers.
|
141
|
+
if (find_servers(:roles => :app).map{|d| d.host} & find_servers(:roles => :sdagent).map{|d| d.host}).any?
|
142
|
+
sudo "sed -i 's/^.*nginx_status_url.*$/nginx_status_url: http:\\/\\/127.0.0.1\\/nginx_status/g' #{sdagent_root}/config.cfg"
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
desc "Write the application conf"
|
147
|
+
task :configure, :roles => :app do
|
148
|
+
utilities.sudo_upload_template nginx_unicorn_app_conf_path, "#{nginx_unicorn_conf_dir}/sites-available/#{application}.conf"
|
149
|
+
enable
|
150
|
+
end
|
151
|
+
|
152
|
+
desc "remove the application conf"
|
153
|
+
task :deconfigure, :roles => :app do
|
154
|
+
disable
|
155
|
+
sudo "rm -rf #{nginx_unicorn_conf_dir}/sites-available/#{application}.conf"
|
156
|
+
end
|
157
|
+
|
158
|
+
desc "Enable the application conf"
|
159
|
+
task :enable, :roles => :app do
|
160
|
+
sudo "ln -sf #{nginx_unicorn_conf_dir}/sites-available/#{application}.conf #{nginx_unicorn_conf_dir}/sites-enabled/#{application}.conf"
|
161
|
+
end
|
162
|
+
|
163
|
+
desc "Disable the application conf"
|
164
|
+
task :disable, :roles => :app do
|
165
|
+
sudo "rm -f #{nginx_unicorn_conf_dir}/sites-enabled/#{application}.conf"
|
166
|
+
end
|
167
|
+
|
168
|
+
%w(start stop restart).each do |t|
|
169
|
+
desc "#{t} nginx_unicorn via init"
|
170
|
+
task t.to_sym, :roles => :app do
|
171
|
+
sudo "/etc/init.d/#{nginx_unicorn_init_d} #{t}" unless nginx_unicorn_suppress_runner
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
end
|
176
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
# no longer required, all methods moved to install.rb
|
@@ -0,0 +1,79 @@
|
|
1
|
+
types {
|
2
|
+
text/html html htm shtml;
|
3
|
+
text/css css;
|
4
|
+
text/xml xml;
|
5
|
+
image/gif gif;
|
6
|
+
image/jpeg jpeg jpg;
|
7
|
+
application/x-javascript js;
|
8
|
+
application/atom+xml atom;
|
9
|
+
application/rss+xml rss;
|
10
|
+
|
11
|
+
text/mathml mml;
|
12
|
+
text/plain txt;
|
13
|
+
text/vnd.sun.j2me.app-descriptor jad;
|
14
|
+
text/vnd.wap.wml wml;
|
15
|
+
text/x-component htc;
|
16
|
+
|
17
|
+
image/png png;
|
18
|
+
image/tiff tif tiff;
|
19
|
+
image/vnd.wap.wbmp wbmp;
|
20
|
+
image/x-icon ico;
|
21
|
+
image/x-jng jng;
|
22
|
+
image/x-ms-bmp bmp;
|
23
|
+
image/svg+xml svg svgz;
|
24
|
+
image/webp webp;
|
25
|
+
|
26
|
+
application/java-archive jar war ear;
|
27
|
+
application/mac-binhex40 hqx;
|
28
|
+
application/msword doc;
|
29
|
+
application/pdf pdf;
|
30
|
+
application/postscript ps eps ai;
|
31
|
+
application/rtf rtf;
|
32
|
+
application/vnd.ms-excel xls;
|
33
|
+
application/vnd.ms-powerpoint ppt;
|
34
|
+
application/vnd.wap.wmlc wmlc;
|
35
|
+
application/vnd.google-earth.kml+xml kml;
|
36
|
+
application/vnd.google-earth.kmz kmz;
|
37
|
+
application/x-7z-compressed 7z;
|
38
|
+
application/x-cocoa cco;
|
39
|
+
application/x-java-archive-diff jardiff;
|
40
|
+
application/x-java-jnlp-file jnlp;
|
41
|
+
application/x-makeself run;
|
42
|
+
application/x-perl pl pm;
|
43
|
+
application/x-pilot prc pdb;
|
44
|
+
application/x-rar-compressed rar;
|
45
|
+
application/x-redhat-package-manager rpm;
|
46
|
+
application/x-sea sea;
|
47
|
+
application/x-shockwave-flash swf;
|
48
|
+
application/x-stuffit sit;
|
49
|
+
application/x-tcl tcl tk;
|
50
|
+
application/x-x509-ca-cert der pem crt;
|
51
|
+
application/x-xpinstall xpi;
|
52
|
+
application/xhtml+xml xhtml;
|
53
|
+
application/zip zip;
|
54
|
+
|
55
|
+
application/octet-stream bin exe dll;
|
56
|
+
application/octet-stream deb;
|
57
|
+
application/octet-stream dmg;
|
58
|
+
application/octet-stream eot;
|
59
|
+
application/octet-stream iso img;
|
60
|
+
application/octet-stream msi msp msm;
|
61
|
+
|
62
|
+
audio/midi mid midi kar;
|
63
|
+
audio/mpeg mp3;
|
64
|
+
audio/ogg ogg;
|
65
|
+
audio/x-m4a m4a;
|
66
|
+
audio/x-realaudio ra;
|
67
|
+
|
68
|
+
video/3gpp 3gpp 3gp;
|
69
|
+
video/mp4 mp4;
|
70
|
+
video/mpeg mpeg mpg;
|
71
|
+
video/quicktime mov;
|
72
|
+
video/webm webm;
|
73
|
+
video/x-flv flv;
|
74
|
+
video/x-m4v m4v;
|
75
|
+
video/x-mng mng;
|
76
|
+
video/x-ms-asf asx asf;
|
77
|
+
video/x-ms-wmv wmv;
|
78
|
+
video/x-msvideo avi;
|
79
|
+
}
|
@@ -0,0 +1,138 @@
|
|
1
|
+
#user <%=nginx_unicorn_user%>;
|
2
|
+
worker_processes <%=nginx_unicorn_worker_processes%>;
|
3
|
+
|
4
|
+
# nginx file limits.
|
5
|
+
worker_rlimit_nofile 40000;
|
6
|
+
|
7
|
+
# worker_connections specifies how many network connections a worker is
|
8
|
+
# allowed to maintain. worker_rlimit_nofile specifies how many open file
|
9
|
+
# handles are allowed per worker. Since all tcp connections are file
|
10
|
+
# handles (descriptors) on *nix systems, worker_rlimit_nofile must be
|
11
|
+
# greater than worker_connections.
|
12
|
+
|
13
|
+
<% if nginx_unicorn_syslog_patch %>
|
14
|
+
syslog local6 <%=nginx_unicorn_init_d%>;
|
15
|
+
error_log syslog:info|<%=nginx_unicorn_log_dir%>/error.log;
|
16
|
+
<% else %>
|
17
|
+
error_log <%=nginx_unicorn_log_dir%>/error.log;
|
18
|
+
<% end %>
|
19
|
+
|
20
|
+
# pid <%=nginx_unicorn_pid_file%>;
|
21
|
+
|
22
|
+
events {
|
23
|
+
worker_connections 30000;
|
24
|
+
use epoll;
|
25
|
+
}
|
26
|
+
|
27
|
+
http {
|
28
|
+
include mime.types;
|
29
|
+
types {
|
30
|
+
audio/x-wav wav;
|
31
|
+
}
|
32
|
+
default_type application/octet-stream;
|
33
|
+
|
34
|
+
# hide the server version
|
35
|
+
server_tokens off;
|
36
|
+
|
37
|
+
# ssl_certificate <%=nginx_unicorn_root%>/wildcard.homerun.com.crt;
|
38
|
+
# ssl_certificate_key <%=nginx_unicorn_root%>/wildcard.homerun.com.key;
|
39
|
+
ssl_protocols SSLv3 TLSv1;
|
40
|
+
|
41
|
+
# http://matt.io/technobabble/hivemind_devops_alert:_nginx_does_not_suck_at_ssl/ur
|
42
|
+
# http://news.ycombinator.com/item?id=2759596
|
43
|
+
# You can force nginx to not enable the expensive cipher by excluding all DHE ciphers.
|
44
|
+
# Add "!kEDH" to your cipher list. It disables (the ! disables) any cipher using
|
45
|
+
# Ephemeral Diffie-Hellman.
|
46
|
+
ssl_ciphers HIGH:!ADH:!MD5:!kEDH;
|
47
|
+
|
48
|
+
server_names_hash_bucket_size 128;
|
49
|
+
|
50
|
+
# The proxy_read_timeout directive sets the read timeout for the response of the proxied server,
|
51
|
+
# in seconds by default. It determines how long nginx will wait to get the response to a request.
|
52
|
+
# The timeout is established not for entire response, but only between two operations of reading.
|
53
|
+
proxy_read_timeout 121s;
|
54
|
+
|
55
|
+
# $proxy_add_x_forwarded_for
|
56
|
+
# Contains client request-header "X-Forwarded-For" with separated by comma $remote_addr.
|
57
|
+
# If there is no X-Forwarded-For request-header, than $proxy_add_x_forwarded_for is equal to $remote_addr.
|
58
|
+
|
59
|
+
<% if nginx_unicorn_rid_header_patch -%>
|
60
|
+
# For nginx_unicorn we should use the X-Request-Id header passed in on the connection
|
61
|
+
# On your backend, you can pull the request header x-exampledotcom-rid, and log it or tie it to whatever you may like.
|
62
|
+
# This makes it really easy to correlate backend exceptions or instrumentation with frontend http request logs.
|
63
|
+
# Goes well with the new Rails 3.2/master support for X-Request-Id.
|
64
|
+
proxy_set_header X-Request-Id $request_id;
|
65
|
+
|
66
|
+
log_format timing '$remote_addr - $remote_user [$time_local] "$http_user_agent" $scheme $http_host "$request" $status - request_time $request_time upstream_response_time $upstream_response_time upstream_cache_status $upstream_cache_status request_id "$request_id"';
|
67
|
+
|
68
|
+
log_format main '$remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent" "$http_x_forwarded_for" - $connection $request_time $upstream_cache_status "$request_id"';
|
69
|
+
<% else -%>
|
70
|
+
log_format timing '$remote_addr - $remote_user [$time_local] "$http_user_agent" $scheme $http_host "$request" $status - request_time $request_time upstream_response_time $upstream_response_time upstream_cache_status $upstream_cache_status';
|
71
|
+
|
72
|
+
log_format main '$remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent" "$http_x_forwarded_for" - $connection $request_time $upstream_cache_status';
|
73
|
+
<% end -%>
|
74
|
+
|
75
|
+
|
76
|
+
client_body_temp_path '/dev/shm';
|
77
|
+
server_name_in_redirect on;
|
78
|
+
ignore_invalid_headers on;
|
79
|
+
|
80
|
+
#default: keepalive_timeout 75
|
81
|
+
keepalive_timeout 75 20;
|
82
|
+
|
83
|
+
#default: keepalive_requests 100
|
84
|
+
keepalive_requests 20;
|
85
|
+
sendfile on;
|
86
|
+
tcp_nodelay on;
|
87
|
+
tcp_nopush on;
|
88
|
+
<% if nginx_unicorn_gzip %>
|
89
|
+
gzip on;
|
90
|
+
gzip_http_version 1.0;
|
91
|
+
gzip_min_length 0;
|
92
|
+
gzip_buffers 16 8k;
|
93
|
+
gzip_comp_level 6;
|
94
|
+
gzip_static on;
|
95
|
+
gzip_proxied any;
|
96
|
+
gzip_vary on;
|
97
|
+
gzip_types text/plain text/javascript text/css application/x-javascript text/xml;
|
98
|
+
<% end %>
|
99
|
+
##
|
100
|
+
# Optimizations: http://www.typemiss.net/blog/kounoike/20060227-75
|
101
|
+
client_header_timeout 10m;
|
102
|
+
client_body_timeout 10m;
|
103
|
+
send_timeout 10m;
|
104
|
+
|
105
|
+
connection_pool_size 256;
|
106
|
+
client_header_buffer_size 12k;
|
107
|
+
large_client_header_buffers 4 8k;
|
108
|
+
request_pool_size 4k;
|
109
|
+
|
110
|
+
output_buffers 1 32k;
|
111
|
+
postpone_output 1460;
|
112
|
+
|
113
|
+
# proxy_buffers
|
114
|
+
# syntax: proxy_buffers the_number is_size;
|
115
|
+
# default: proxy_buffers 8 4k/8k;
|
116
|
+
# context: http, server, location
|
117
|
+
# This directive sets the number and the size of buffers, into which will be read the answer, obtained from the proxied server.
|
118
|
+
# By default, the size of one buffer is equal to the size of page. Depending on platform this is either 4K or 8K.
|
119
|
+
|
120
|
+
proxy_buffers 16 32k;
|
121
|
+
|
122
|
+
# proxy_buffer_size
|
123
|
+
# syntax: proxy_buffer_size the_size;
|
124
|
+
# default: proxy_buffer_size 4k/8k;
|
125
|
+
# context: http, server, location
|
126
|
+
# This directive set the buffer size, into which will be read the first part of the response, obtained from the proxied server.
|
127
|
+
# In this part of response the small response-header is located, as a rule.
|
128
|
+
# By default, the buffer size is equal to the size of one buffer in directive proxy_buffers; however, it is possible to set it to less.
|
129
|
+
|
130
|
+
# proxy_busy_buffers_size
|
131
|
+
# syntax: proxy_busy_buffers_size size;
|
132
|
+
# default: proxy_busy_buffers_size proxy_buffer_size * 2;
|
133
|
+
# context: http, server, location, if
|
134
|
+
# TODO: Description.
|
135
|
+
|
136
|
+
include <%=nginx_unicorn_conf_dir%>/sites-enabled/*;
|
137
|
+
|
138
|
+
}
|
@@ -0,0 +1,47 @@
|
|
1
|
+
God.watch do |w|
|
2
|
+
w.name = "<%=nginx_unicorn_init_d%>"
|
3
|
+
w.group = "nginx"
|
4
|
+
w.interval = 5.seconds # default
|
5
|
+
w.start = "/etc/init.d/<%=nginx_unicorn_init_d%> start"
|
6
|
+
w.stop = "/etc/init.d/<%=nginx_unicorn_init_d%> stop"
|
7
|
+
w.restart = "/etc/init.d/<%=nginx_unicorn_init_d%> restart"
|
8
|
+
w.pid_file = "<%=nginx_unicorn_pid_file%>"
|
9
|
+
|
10
|
+
# clean pid files before start if necessary
|
11
|
+
w.behavior(:clean_pid_file)
|
12
|
+
|
13
|
+
# determine the state on startup
|
14
|
+
w.transition(:init, { true => :up, false => :start }) do |on|
|
15
|
+
on.condition(:process_running) do |c|
|
16
|
+
c.running = true
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
# determine when process has finished starting
|
21
|
+
w.transition([:start, :restart], :up) do |on|
|
22
|
+
on.condition(:process_running) do |c|
|
23
|
+
c.running = true
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
# start if process is not running
|
28
|
+
w.transition(:up, :start) do |on|
|
29
|
+
on.condition(:process_exits) do |c|
|
30
|
+
c.notify = %w[ <%=god_notify_list%> ]
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
# lifecycle
|
35
|
+
w.lifecycle do |on|
|
36
|
+
on.condition(:flapping) do |c|
|
37
|
+
c.to_state = [:start, :restart]
|
38
|
+
c.times = 5
|
39
|
+
c.within = 5.minute
|
40
|
+
c.transition = :unmonitored
|
41
|
+
c.retry_in = 10.minutes
|
42
|
+
c.retry_times = 5
|
43
|
+
c.retry_within = 2.hours
|
44
|
+
c.notify = %w[ <%=god_notify_list%> ]
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|