capistrano-nginx-unicorn 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
data/README.md
CHANGED
@@ -84,41 +84,70 @@ you can run any of these tasks to update configuration.
|
|
84
84
|
|
85
85
|
You can customize nginx and unicorn configs using capistrano variables:
|
86
86
|
|
87
|
-
# path to customized templates (see below for details)
|
88
|
-
# default value: "config/deploy/templates"
|
89
|
-
set :templates_path, "config/deploy/templates"
|
90
87
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
88
|
+
```ruby
|
89
|
+
# path to customized templates (see below for details)
|
90
|
+
# default value: "config/deploy/templates"
|
91
|
+
set :templates_path, "config/deploy/templates"
|
92
|
+
|
93
|
+
# server name for nginx, default value: no (will be prompted if not set)
|
94
|
+
# set this to your site name as it is visible from outside
|
95
|
+
# this will allow 1 nginx to serve several sites with different `server_name`
|
96
|
+
set :nginx_server_name, "example.com"
|
97
|
+
|
98
|
+
# path, where unicorn pid file will be stored
|
99
|
+
# default value: `"#{current_path}/tmp/pids/unicorn.pid"`
|
100
|
+
set :unicorn_pid, "#{current_path}/tmp/pids/unicorn.pid"
|
101
|
+
|
102
|
+
# path, where unicorn config file will be stored
|
103
|
+
# default value: `"#{shared_path}/config/unicorn.rb"`
|
104
|
+
set :unicorn_config, "#{shared_path}/config/unicorn.rb"
|
105
|
+
|
106
|
+
# path, where unicorn log file will be stored
|
107
|
+
# default value: `"#{shared_path}/config/unicorn.rb"`
|
108
|
+
set :unicorn_log, "#{shared_path}/config/unicorn.rb"
|
109
|
+
|
110
|
+
# user name to run unicorn
|
111
|
+
# default value: `user` (user varibale defined in your `deploy.rb`)
|
112
|
+
set :unicorn_user, "user"
|
113
|
+
|
114
|
+
# number of unicorn workers
|
115
|
+
# default value: no (will be prompted if not set)
|
116
|
+
set :unicorn_workers, 4
|
117
|
+
|
118
|
+
# if set, nginx will be configured to 443 port and port 80 will be auto rewritten to 443
|
119
|
+
# also, on `nginx:setup`, paths to ssl certificate and key will be configured
|
120
|
+
# and certificate file and key will be copied to `/etc/ssl/certs` and `/etc/ssl/private/` directories
|
121
|
+
# default value: false
|
122
|
+
set :nginx_use_ssl, false
|
123
|
+
|
124
|
+
# remote file name of the certificate, only makes sense if `nginx_use_ssl` is set
|
125
|
+
# default value: `nginx_server_name + ".crt"`
|
126
|
+
set :nginx_ssl_certificate, "#{nginx_server_name}.crt"
|
127
|
+
|
128
|
+
# remote file name of the certificate, only makes sense if `nginx_use_ssl` is set
|
129
|
+
# default value: `nginx_server_name + ".key"`
|
130
|
+
set :nginx_ssl_certificate_key, "#{nginx_server_name}.key"
|
131
|
+
|
132
|
+
# local path to file with certificate, only makes sense if `nginx_use_ssl` is set
|
133
|
+
# this file will be copied to remote server
|
134
|
+
# default value: none (will be prompted if not set)
|
135
|
+
set :nginx_ssl_certificate_local_path, "/home/ivalkeen/ssl/myssl.cert"
|
136
|
+
|
137
|
+
# local path to file with certificate key, only makes sense if `nginx_use_ssl` is set
|
138
|
+
# this file will be copied to remote server
|
139
|
+
# default value: none (will be prompted if not set)
|
140
|
+
set :nginx_ssl_certificate_key_local_path, "/home/ivalkeen/ssl/myssl.key"
|
141
|
+
```
|
115
142
|
|
116
143
|
For example, of you site name is `example.com` and you want to use 8 unicorn workers,
|
117
144
|
your `deploy.rb` will look like this:
|
118
145
|
|
119
|
-
|
120
|
-
|
121
|
-
|
146
|
+
```ruby
|
147
|
+
set :server_name, "example.com"
|
148
|
+
set :unicorn_workers, 4
|
149
|
+
require 'capistrano-nginx-unicorn'
|
150
|
+
```
|
122
151
|
|
123
152
|
### Template Customization
|
124
153
|
|
@@ -4,6 +4,11 @@ Capistrano::Configuration.instance.load do
|
|
4
4
|
set_default(:templates_path, "config/deploy/templates")
|
5
5
|
|
6
6
|
set_default(:nginx_server_name) { Capistrano::CLI.ui.ask "Nginx server name: " }
|
7
|
+
set_default(:nginx_use_ssl, false)
|
8
|
+
set_default(:nginx_ssl_certificate, "#{nginx_server_name}.crt")
|
9
|
+
set_default(:nginx_ssl_certificate_key, "#{nginx_server_name}.key")
|
10
|
+
set_default(:nginx_ssl_certificate_local_path) {Capistrano::CLI.ui.ask "Local path to ssl certificate: "}
|
11
|
+
set_default(:nginx_ssl_certificate_key_local_path) {Capistrano::CLI.ui.ask "Local path to ssl certificate key: "}
|
7
12
|
|
8
13
|
set_default(:unicorn_pid, "#{current_path}/tmp/pids/unicorn.pid")
|
9
14
|
set_default(:unicorn_config, "#{shared_path}/config/unicorn.rb")
|
@@ -17,6 +22,17 @@ Capistrano::Configuration.instance.load do
|
|
17
22
|
template("nginx_conf.erb", "/tmp/#{application}")
|
18
23
|
run "#{sudo} mv /tmp/#{application} /etc/nginx/sites-available/#{application}"
|
19
24
|
run "#{sudo} ln -fs /etc/nginx/sites-available/#{application} /etc/nginx/sites-enabled/#{application}"
|
25
|
+
|
26
|
+
if nginx_use_ssl
|
27
|
+
put File.read(nginx_ssl_certificate_local_path), "/tmp/#{nginx_ssl_certificate}"
|
28
|
+
put File.read(nginx_ssl_certificate_key_local_path), "/tmp/#{nginx_ssl_certificate_key}"
|
29
|
+
|
30
|
+
run "#{sudo} mv /tmp/#{nginx_ssl_certificate} /etc/ssl/certs/#{nginx_ssl_certificate}"
|
31
|
+
run "#{sudo} mv /tmp/#{nginx_ssl_certificate_key} /etc/ssl/private/#{nginx_ssl_certificate_key}"
|
32
|
+
|
33
|
+
run "#{sudo} chown root:root /etc/ssl/certs/#{nginx_ssl_certificate}"
|
34
|
+
run "#{sudo} chown root:root /etc/ssl/private/#{nginx_ssl_certificate_key}"
|
35
|
+
end
|
20
36
|
end
|
21
37
|
|
22
38
|
after "deploy:setup", "nginx:setup"
|
@@ -2,8 +2,23 @@ upstream unicorn_<%= application %> {
|
|
2
2
|
server unix:/tmp/unicorn.<%= application %>.sock fail_timeout=0;
|
3
3
|
}
|
4
4
|
|
5
|
+
<% if nginx_use_ssl %>
|
5
6
|
server {
|
6
7
|
listen 80;
|
8
|
+
rewrite ^(.*) https://$host$1 permanent;
|
9
|
+
}
|
10
|
+
<% end %>
|
11
|
+
|
12
|
+
server {
|
13
|
+
<% if nginx_use_ssl %>
|
14
|
+
listen 443;
|
15
|
+
ssl on;
|
16
|
+
ssl_certificate /etc/ssl/certs/<%= nginx_ssl_certificate %>;
|
17
|
+
ssl_certificate_key /etc/ssl/private/<%= nginx_ssl_certificate_key %>;
|
18
|
+
<% else %>
|
19
|
+
listen 80;
|
20
|
+
<% end %>
|
21
|
+
|
7
22
|
server_name <%= nginx_server_name %>;
|
8
23
|
root <%= current_path %>/public;
|
9
24
|
try_files $uri/index.html $uri @unicorn_<%= application %>;
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano-nginx-unicorn
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-11-
|
12
|
+
date: 2012-11-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
prerelease: false
|
@@ -79,7 +79,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
79
79
|
version: '0'
|
80
80
|
segments:
|
81
81
|
- 0
|
82
|
-
hash:
|
82
|
+
hash: 3183296654064294828
|
83
83
|
none: false
|
84
84
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
85
85
|
requirements:
|
@@ -88,7 +88,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
88
88
|
version: '0'
|
89
89
|
segments:
|
90
90
|
- 0
|
91
|
-
hash:
|
91
|
+
hash: 3183296654064294828
|
92
92
|
none: false
|
93
93
|
requirements: []
|
94
94
|
rubyforge_project:
|