rails_pwnerer 0.6.107 → 0.6.108
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.
- data/CHANGELOG +2 -0
- data/lib/rails_pwnerer/app/nginx_config.rb +18 -18
- data/rails_pwnerer.gemspec +1 -1
- metadata +1 -1
data/CHANGELOG
CHANGED
@@ -2,24 +2,24 @@
|
|
2
2
|
|
3
3
|
class RailsPwnerer::App::NginxConfig
|
4
4
|
include RailsPwnerer::Base
|
5
|
-
|
5
|
+
|
6
6
|
# writes the nginx configuration for this server
|
7
7
|
def config_nginx(app_name, instance_name)
|
8
8
|
app_config = RailsPwnerer::Config[app_name, instance_name]
|
9
9
|
first_port = app_config[:port0]
|
10
|
-
|
10
|
+
|
11
11
|
# Can be specified as comma-separated string or array.
|
12
12
|
if app_config[:dns_name].respond_to? :to_str
|
13
13
|
dns_names = app_config[:dns_name].split(',')
|
14
14
|
else
|
15
15
|
dns_names = app_config[:dns_name]
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
18
|
default_app_port = app_config[:ssl_key] ? 443 : 80
|
19
19
|
app_port = app_config[:port] || default_app_port
|
20
|
-
|
20
|
+
|
21
21
|
nginx_config = File.join(RailsPwnerer::Config.path_to(:nginx_configs),
|
22
|
-
app_name + '.' + instance_name)
|
22
|
+
app_name + '.' + instance_name)
|
23
23
|
File.open(nginx_config, 'w') do |f|
|
24
24
|
# link to the frontends
|
25
25
|
f << " upstream #{app_name}_#{instance_name} {\n"
|
@@ -27,7 +27,7 @@ class RailsPwnerer::App::NginxConfig
|
|
27
27
|
f << " server 127.0.0.1:#{first_port + instance};\n"
|
28
28
|
end
|
29
29
|
f << " }\n\n"
|
30
|
-
|
30
|
+
|
31
31
|
# server configuration -- big and ugly
|
32
32
|
f << <<NGINX_CONFIG
|
33
33
|
server {
|
@@ -44,7 +44,7 @@ class RailsPwnerer::App::NginxConfig
|
|
44
44
|
expires max;
|
45
45
|
add_header Cache-Control public;
|
46
46
|
break;
|
47
|
-
}
|
47
|
+
}
|
48
48
|
error_page 404 /404.html;
|
49
49
|
error_page 500 502 503 504 /500.html;
|
50
50
|
location / {
|
@@ -64,7 +64,7 @@ class RailsPwnerer::App::NginxConfig
|
|
64
64
|
|
65
65
|
proxy_set_header X-Real-IP $remote_addr;
|
66
66
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
67
|
-
|
67
|
+
proxy_set_header X-Forwarded-Proto $scheme;
|
68
68
|
proxy_set_header Host $host;
|
69
69
|
proxy_redirect off;
|
70
70
|
proxy_connect_timeout 2;
|
@@ -74,38 +74,38 @@ class RailsPwnerer::App::NginxConfig
|
|
74
74
|
break;
|
75
75
|
}
|
76
76
|
}
|
77
|
-
}
|
77
|
+
}
|
78
78
|
NGINX_CONFIG
|
79
|
-
end
|
79
|
+
end
|
80
80
|
end
|
81
|
-
|
81
|
+
|
82
82
|
def remove_nginx_config(app_name, instance_name)
|
83
|
-
nginx_config = File.join(RailsPwnerer::Config.path_to(:nginx_configs), app_name + '.' + instance_name)
|
84
|
-
File.delete nginx_config if File.exists? nginx_config
|
83
|
+
nginx_config = File.join(RailsPwnerer::Config.path_to(:nginx_configs), app_name + '.' + instance_name)
|
84
|
+
File.delete nginx_config if File.exists? nginx_config
|
85
85
|
end
|
86
|
-
|
86
|
+
|
87
87
|
# removes the default configuration stub (so nginx doesn't stumble upon it)
|
88
88
|
def remove_nginx_stub
|
89
89
|
stub_file = File.join(RailsPwnerer::Config.path_to(:nginx_configs), 'default')
|
90
90
|
File.delete stub_file if File.exists?(stub_file)
|
91
91
|
end
|
92
|
-
|
92
|
+
|
93
93
|
def setup(app_name, instance_name)
|
94
94
|
config_nginx app_name, instance_name
|
95
95
|
remove_nginx_stub
|
96
96
|
control_boot_script('nginx', :reload)
|
97
97
|
end
|
98
|
-
|
98
|
+
|
99
99
|
def update(app_name, instance_name)
|
100
100
|
config_nginx app_name, instance_name
|
101
101
|
control_boot_script('nginx', :reload)
|
102
102
|
end
|
103
|
-
|
103
|
+
|
104
104
|
def remove(app_name, instance_name)
|
105
105
|
remove_nginx_config app_name, instance_name
|
106
106
|
control_boot_script('nginx', :reload)
|
107
107
|
end
|
108
|
-
|
108
|
+
|
109
109
|
def control_all(action)
|
110
110
|
case action
|
111
111
|
when :start
|
data/rails_pwnerer.gemspec
CHANGED