recipiez 0.9.2 → 0.9.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,3 @@
1
1
  module Recipiez
2
- VERSION = '0.9.2'
2
+ VERSION = '0.9.3'
3
3
  end
data/recipes/go.rb CHANGED
@@ -10,6 +10,7 @@ Capistrano::Configuration.instance(true).load do
10
10
  go::generate_upstart
11
11
  monit::go
12
12
  logrotate::configure
13
+ nginx::golang
13
14
  end
14
15
 
15
16
  task :generate_upstart do
data/recipes/nginx.rb CHANGED
@@ -52,6 +52,36 @@ Capistrano::Configuration.instance(true).load do
52
52
  end
53
53
  end
54
54
 
55
+
56
+ desc "Generates a simple proxy configuration for a golang application"
57
+ task :golang do
58
+
59
+ _cset :go_port, 3000
60
+ _cset :ssl_enabled, false
61
+
62
+
63
+ put render("nginx_golang", binding), "#{application}.conf"
64
+ sudo "mv #{application}.conf /etc/nginx/sites-available/#{application}.conf"
65
+ begin
66
+ sudo "ln -s /etc/nginx/sites-available/#{application}.conf /etc/nginx/sites-enabled/#{application}.conf"
67
+ rescue
68
+ # do nothing
69
+ end
70
+
71
+ begin
72
+ stop
73
+ rescue
74
+ # do nothing
75
+ end
76
+
77
+ begin
78
+ start
79
+ rescue
80
+ # do nothing
81
+ end
82
+ end
83
+
84
+
55
85
  desc "Starts Nginx webserver"
56
86
  task :start, :roles => :web do
57
87
  sudo "/etc/init.d/nginx start"
@@ -63,4 +93,4 @@ Capistrano::Configuration.instance(true).load do
63
93
  end
64
94
 
65
95
  end
66
- end
96
+ end
@@ -0,0 +1,52 @@
1
+ # Generated by capistrano and the recipiez gem.
2
+
3
+ upstream <%= application %> {
4
+ server 127.0.0.1:<%= go_port %>;
5
+ }
6
+
7
+ # the nginx server instance
8
+ server {
9
+ listen 0.0.0.0:80;
10
+ server_name <%= app_domain %>;
11
+
12
+ access_log /var/log/nginx/<%= application %>.log;
13
+ error_log /var/log/nginx/<%= application %>_error.log;
14
+
15
+ # pass the request to the node.js server with the correct headers and much more can be added, see nginx config options
16
+ location / {
17
+ proxy_set_header X-Real-IP $remote_addr;
18
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
19
+ proxy_set_header Host $http_host;
20
+ proxy_set_header X-NginX-Proxy true;
21
+
22
+ proxy_pass http://<%= application %>/;
23
+ proxy_redirect off;
24
+ }
25
+ }
26
+
27
+
28
+ <% if ssl_enabled == 'on' %>
29
+ # https server definition, remember only one https site per IP
30
+
31
+ server {
32
+ listen 443;
33
+ ssl on;
34
+
35
+ ssl_certificate <%= ssl_cert %>;
36
+ ssl_certificate_key <%= ssl_key %>;
37
+
38
+ access_log /var/log/nginx/<%= application %>.log;
39
+ error_log /var/log/nginx/<%= application %>.log;
40
+
41
+ location / {
42
+ proxy_set_header X-Real-IP $remote_addr;
43
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
44
+ proxy_set_header Host $http_host;
45
+ proxy_redirect off;
46
+ proxy_set_header X-FORWARDED_PROTO https;
47
+ proxy_max_temp_file_size 0;
48
+ proxy_pass http://<%= application %>;
49
+ }
50
+ }
51
+ <% end %>
52
+
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 9
8
- - 2
9
- version: 0.9.2
8
+ - 3
9
+ version: 0.9.3
10
10
  platform: ruby
11
11
  authors:
12
12
  - Alastair Brunton
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2016-02-03 00:00:00 +01:00
17
+ date: 2016-02-04 00:00:00 +01:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -63,6 +63,7 @@ files:
63
63
  - recipes/templates/mongo_ini.erb
64
64
  - recipes/templates/monit_config.erb
65
65
  - recipes/templates/mysql_monit.erb
66
+ - recipes/templates/nginx_golang.erb
66
67
  - recipes/templates/nginx_monit.erb
67
68
  - recipes/templates/nginx_node.erb
68
69
  - recipes/templates/nginx_vhost.erb