deploify 0.2.9 → 0.2.10
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/deploify/recipes/nginx.rb +8 -1
- data/lib/deploify/recipes/passenger.rb +3 -3
- data/lib/deploify/recipes/rails.rb +6 -0
- data/lib/deploify/recipes/thin.rb +3 -3
- data/lib/deploify/templates/nginx/vhost_http_force_ssl.conf.erb +14 -15
- data/lib/deploify/templates/nginx/vhost_http_only.conf.erb +13 -14
- data/lib/deploify/templates/nginx/vhost_http_with_ssl.conf.erb +23 -25
- data/lib/deploify/version.rb +1 -1
- metadata +3 -3
@@ -7,7 +7,7 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
7
7
|
set :nginx_enabled_vhost_dir, "/etc/nginx/sites-enabled"
|
8
8
|
set :nginx_client_max_body_size, "100M"
|
9
9
|
set :nginx_vhost_type, :http_only
|
10
|
-
set :nginx_vhost_listen_ip,
|
10
|
+
set :nginx_vhost_listen_ip, nil
|
11
11
|
set :nginx_upstream_servers, []
|
12
12
|
# secured sites stuff
|
13
13
|
set :nginx_secured_site, false
|
@@ -64,6 +64,13 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
64
64
|
task :config_project, :roles => :web do
|
65
65
|
_deploify.push_configs(:nginx, project_config_files)
|
66
66
|
if [:http_with_ssl, :http_force_ssl].include?(nginx_vhost_type)
|
67
|
+
set(:nginx_vhost_listen_ip) do
|
68
|
+
require "resolv"
|
69
|
+
server_ip = Resolv.getaddress(find_servers(roles: :web).first.host)
|
70
|
+
Capistrano::CLI.ui.ask "Enter IP for Nginx zone (needed for scenarios with SSL support) [#{server_ip}]" do |q|
|
71
|
+
q.default = server_ip
|
72
|
+
end
|
73
|
+
end
|
67
74
|
# SSL is demanded, push certificates
|
68
75
|
target_path = "#{deploy_to}/nginx/#{rails_env}"
|
69
76
|
std.su_put(File.read("#{ssl_certs_source_dir}/#{rails_env}.crt"), "#{target_path}.crt", "/tmp", :mode => 0600)
|
@@ -104,10 +104,10 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
104
104
|
|
105
105
|
task :symlink_and_activate_passengerctl, :roles => :app do
|
106
106
|
run "#{try_sudo} ln -sf #{deploy_to}/passenger/passengerctl /etc/init.d/passenger-#{application}"
|
107
|
-
if
|
108
|
-
run "#{try_sudo} update-rc.d -f passenger-#{application} remove"
|
109
|
-
else
|
107
|
+
if app_server_autostart
|
110
108
|
run "#{try_sudo} update-rc.d passenger-#{application} defaults"
|
109
|
+
else
|
110
|
+
run "#{try_sudo} update-rc.d -f passenger-#{application} remove"
|
111
111
|
end
|
112
112
|
end
|
113
113
|
|
@@ -15,6 +15,12 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
15
15
|
set :rails_env, "production"
|
16
16
|
set :shared_dirs, [] # Array of directories that should be created under shared/
|
17
17
|
# and linked to in the project
|
18
|
+
set(:app_server_autostart) do
|
19
|
+
# true if:
|
20
|
+
# - stage not defined (non-multistaging scenario)
|
21
|
+
# - stage is defined, but stage is not :staging
|
22
|
+
!exists?(:stage) || (exists?(:stage) && !fetch(:stage).eql?(:staging))
|
23
|
+
end
|
18
24
|
|
19
25
|
# hook into the default capistrano deploy tasks
|
20
26
|
before "deploy:setup", :except => { :no_release => true } do
|
@@ -85,10 +85,10 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
85
85
|
|
86
86
|
task :symlink_and_activate_thinctl, :roles => :app do
|
87
87
|
run "#{try_sudo} ln -sf #{deploy_to}/thin/thinctl /etc/init.d/thin-#{application}"
|
88
|
-
if
|
89
|
-
run "#{try_sudo} update-rc.d
|
88
|
+
if app_server_autostart
|
89
|
+
run "#{try_sudo} update-rc.d passenger-#{application} defaults"
|
90
90
|
else
|
91
|
-
run "#{try_sudo} update-rc.d
|
91
|
+
run "#{try_sudo} update-rc.d -f passenger-#{application} remove"
|
92
92
|
end
|
93
93
|
end
|
94
94
|
|
@@ -9,7 +9,7 @@ server {
|
|
9
9
|
server_name <%= domain %> <%= Array(web_server_aliases).join(' ') %>;
|
10
10
|
|
11
11
|
location / {
|
12
|
-
rewrite ^ https://<%= domain %>$request_uri? permanent;
|
12
|
+
rewrite ^ https://<%= force_domain_with_www ? "www.#{domain}" : domain %>$request_uri? permanent;
|
13
13
|
}
|
14
14
|
}
|
15
15
|
|
@@ -25,18 +25,18 @@ server {
|
|
25
25
|
ssl_certificate <%= deploy_to %>/nginx/<%= rails_env %>.crt;
|
26
26
|
ssl_certificate_key <%= deploy_to %>/nginx/<%= rails_env %>.key;
|
27
27
|
|
28
|
-
|
28
|
+
<%- if force_domain_with_www -%>
|
29
29
|
if ($host !~* ^www.<%= domain %>$) {
|
30
30
|
rewrite ^(.*) https://www.<%= domain %>$1 permanent;
|
31
31
|
}
|
32
|
-
|
32
|
+
<%- end -%>
|
33
33
|
|
34
34
|
location / {
|
35
|
-
|
35
|
+
<%- if nginx_secured_site -%>
|
36
36
|
auth_basic "Limited access";
|
37
37
|
auth_basic_user_file <%= "#{deploy_to}/nginx/.htaccess" %>;
|
38
|
-
|
39
|
-
try_files $uri @upstream;
|
38
|
+
<%- end -%>
|
39
|
+
try_files $uri/index.html $uri @upstream;
|
40
40
|
}
|
41
41
|
|
42
42
|
location @upstream {
|
@@ -48,32 +48,31 @@ server {
|
|
48
48
|
proxy_set_header X-Forwarded-Proto https;
|
49
49
|
}
|
50
50
|
|
51
|
-
#
|
51
|
+
# this allows people to use images and css in their maintenance.html file
|
52
52
|
if ($request_filename ~* \.(css|jpg|gif|png)$) {
|
53
53
|
break;
|
54
54
|
}
|
55
55
|
|
56
|
-
#
|
56
|
+
# rewrite all the requests to the maintenance.html page if it exists
|
57
57
|
if (-f $document_root/system/maintenance.html) {
|
58
58
|
return 503;
|
59
59
|
}
|
60
60
|
|
61
|
-
# set Expire header on assets
|
61
|
+
# set Expire header on assets
|
62
62
|
location ~ ^/(images|javascripts|stylesheets)/ {
|
63
|
-
|
64
|
-
|
63
|
+
if ($request_method = GET) {
|
64
|
+
expires 1y;
|
65
|
+
}
|
65
66
|
}
|
66
|
-
|
67
67
|
location ~ ^/assets/ {
|
68
|
-
expires
|
68
|
+
expires 1y;
|
69
69
|
add_header Cache-Control public;
|
70
70
|
add_header ETag "";
|
71
|
-
|
71
|
+
break;
|
72
72
|
}
|
73
73
|
|
74
74
|
error_page 404 /404.html;
|
75
75
|
error_page 500 502 504 /500.html;
|
76
|
-
|
77
76
|
error_page 503 @503;
|
78
77
|
location @503 {
|
79
78
|
rewrite ^(.*)$ /system/maintenance.html break;
|
@@ -5,25 +5,25 @@ upstream <%= nginx_upstream_name %> {
|
|
5
5
|
}
|
6
6
|
|
7
7
|
server {
|
8
|
-
listen <%= nginx_vhost_listen_ip
|
8
|
+
listen <%= nginx_vhost_listen_ip %><%= ':' unless nginx_vhost_listen_ip.nil? %>80;
|
9
9
|
server_name <%= domain %> <%= Array(web_server_aliases).join(' ') %>;
|
10
10
|
root <%= deploy_to %>/current/public;
|
11
11
|
client_max_body_size <%= nginx_client_max_body_size %>;
|
12
12
|
access_log <%= shared_path %>/log/access.log;
|
13
13
|
error_log <%= shared_path %>/log/error.log;
|
14
14
|
|
15
|
-
|
15
|
+
<%- if force_domain_with_www -%>
|
16
16
|
if ($host !~* ^www.<%= domain %>$) {
|
17
17
|
rewrite ^(.*) http://www.<%= domain %>$1 permanent;
|
18
18
|
}
|
19
|
-
|
19
|
+
<%- end -%>
|
20
20
|
|
21
21
|
location / {
|
22
|
-
|
22
|
+
<%- if nginx_secured_site -%>
|
23
23
|
auth_basic "Limited access";
|
24
24
|
auth_basic_user_file <%= "#{deploy_to}/nginx/.htaccess" %>;
|
25
|
-
|
26
|
-
try_files $uri @upstream;
|
25
|
+
<%- end -%>
|
26
|
+
try_files $uri/index.html $uri @upstream;
|
27
27
|
}
|
28
28
|
|
29
29
|
location @upstream {
|
@@ -35,32 +35,31 @@ server {
|
|
35
35
|
proxy_set_header X-Forwarded-Proto http;
|
36
36
|
}
|
37
37
|
|
38
|
-
#
|
38
|
+
# this allows people to use images and css in their maintenance.html file
|
39
39
|
if ($request_filename ~* \.(css|jpg|gif|png)$) {
|
40
40
|
break;
|
41
41
|
}
|
42
42
|
|
43
|
-
#
|
43
|
+
# rewrite all the requests to the maintenance.html page if it exists
|
44
44
|
if (-f $document_root/system/maintenance.html) {
|
45
45
|
return 503;
|
46
46
|
}
|
47
47
|
|
48
|
-
# set Expire header on assets
|
48
|
+
# set Expire header on assets
|
49
49
|
location ~ ^/(images|javascripts|stylesheets)/ {
|
50
|
-
|
51
|
-
|
50
|
+
if ($request_method = GET) {
|
51
|
+
expires 1y;
|
52
|
+
}
|
52
53
|
}
|
53
|
-
|
54
54
|
location ~ ^/assets/ {
|
55
55
|
expires max;
|
56
56
|
add_header Cache-Control public;
|
57
57
|
add_header ETag "";
|
58
|
-
|
58
|
+
break;
|
59
59
|
}
|
60
60
|
|
61
61
|
error_page 404 /404.html;
|
62
62
|
error_page 500 502 504 /500.html;
|
63
|
-
|
64
63
|
error_page 503 @503;
|
65
64
|
location @503 {
|
66
65
|
rewrite ^(.*)$ /system/maintenance.html break;
|
@@ -12,18 +12,18 @@ server {
|
|
12
12
|
access_log <%= shared_path %>/log/access.log;
|
13
13
|
error_log <%= shared_path %>/log/error.log;
|
14
14
|
|
15
|
-
|
15
|
+
<%- if force_domain_with_www -%>
|
16
16
|
if ($host !~* ^www.<%= domain %>$) {
|
17
17
|
rewrite ^(.*) http://www.<%= domain %>$1 permanent;
|
18
18
|
}
|
19
|
-
|
19
|
+
<%- end -%>
|
20
20
|
|
21
21
|
location / {
|
22
|
-
|
22
|
+
<%- if nginx_secured_site -%>
|
23
23
|
auth_basic "Limited access";
|
24
24
|
auth_basic_user_file <%= "#{deploy_to}/nginx/.htaccess" %>;
|
25
|
-
|
26
|
-
try_files $uri @upstream;
|
25
|
+
<%- end -%>
|
26
|
+
try_files $uri/index.html $uri @upstream;
|
27
27
|
}
|
28
28
|
|
29
29
|
location @upstream {
|
@@ -35,32 +35,31 @@ server {
|
|
35
35
|
proxy_set_header X-Forwarded-Proto http;
|
36
36
|
}
|
37
37
|
|
38
|
-
#
|
38
|
+
# this allows people to use images and css in their maintenance.html file
|
39
39
|
if ($request_filename ~* \.(css|jpg|gif|png)$) {
|
40
40
|
break;
|
41
41
|
}
|
42
42
|
|
43
|
-
#
|
43
|
+
# rewrite all the requests to the maintenance.html page if it exists
|
44
44
|
if (-f $document_root/system/maintenance.html) {
|
45
45
|
return 503;
|
46
46
|
}
|
47
47
|
|
48
|
-
# set Expire header on assets
|
48
|
+
# set Expire header on assets
|
49
49
|
location ~ ^/(images|javascripts|stylesheets)/ {
|
50
|
-
|
51
|
-
|
50
|
+
if ($request_method = GET) {
|
51
|
+
expires 1y;
|
52
|
+
}
|
52
53
|
}
|
53
|
-
|
54
54
|
location ~ ^/assets/ {
|
55
55
|
expires max;
|
56
56
|
add_header Cache-Control public;
|
57
57
|
add_header ETag "";
|
58
|
-
|
58
|
+
break;
|
59
59
|
}
|
60
60
|
|
61
61
|
error_page 404 /404.html;
|
62
62
|
error_page 500 502 504 /500.html;
|
63
|
-
|
64
63
|
error_page 503 @503;
|
65
64
|
location @503 {
|
66
65
|
rewrite ^(.*)$ /system/maintenance.html break;
|
@@ -79,17 +78,17 @@ server {
|
|
79
78
|
ssl_certificate <%= deploy_to %>/nginx/<%= rails_env %>.crt;
|
80
79
|
ssl_certificate_key <%= deploy_to %>/nginx/<%= rails_env %>.key;
|
81
80
|
|
82
|
-
|
81
|
+
<%- if force_domain_with_www -%>
|
83
82
|
if ($host !~* ^www.<%= domain %>$) {
|
84
83
|
rewrite ^(.*) https://www.<%= domain %>$1 permanent;
|
85
84
|
}
|
86
|
-
|
85
|
+
<%- end -%>
|
87
86
|
|
88
87
|
location / {
|
89
|
-
|
88
|
+
<%- if nginx_secured_site -%>
|
90
89
|
auth_basic "Limited access";
|
91
90
|
auth_basic_user_file <%= "#{deploy_to}/nginx/.htaccess" %>;
|
92
|
-
|
91
|
+
<%- end -%>
|
93
92
|
try_files $uri @upstream;
|
94
93
|
}
|
95
94
|
|
@@ -102,32 +101,31 @@ server {
|
|
102
101
|
proxy_set_header X-Forwarded-Proto https;
|
103
102
|
}
|
104
103
|
|
105
|
-
#
|
104
|
+
# this allows people to use images and css in their maintenance.html file
|
106
105
|
if ($request_filename ~* \.(css|jpg|gif|png)$) {
|
107
106
|
break;
|
108
107
|
}
|
109
108
|
|
110
|
-
#
|
109
|
+
# rewrite all the requests to the maintenance.html page if it exists
|
111
110
|
if (-f $document_root/system/maintenance.html) {
|
112
111
|
return 503;
|
113
112
|
}
|
114
113
|
|
115
|
-
# set Expire header on assets
|
114
|
+
# set Expire header on assets
|
116
115
|
location ~ ^/(images|javascripts|stylesheets)/ {
|
117
|
-
|
118
|
-
|
116
|
+
if ($request_method = GET) {
|
117
|
+
expires 1y;
|
118
|
+
}
|
119
119
|
}
|
120
|
-
|
121
120
|
location ~ ^/assets/ {
|
122
121
|
expires max;
|
123
122
|
add_header Cache-Control public;
|
124
123
|
add_header ETag "";
|
125
|
-
|
124
|
+
break;
|
126
125
|
}
|
127
126
|
|
128
127
|
error_page 404 /404.html;
|
129
128
|
error_page 500 502 504 /500.html;
|
130
|
-
|
131
129
|
error_page 503 @503;
|
132
130
|
location @503 {
|
133
131
|
rewrite ^(.*)$ /system/maintenance.html break;
|
data/lib/deploify/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: deploify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 3
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 10
|
10
|
+
version: 0.2.10
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Richard Riman
|