Commit baae975d7e1c0153fd712c7cdd189aace595a634

Authored by nollieheel
Committed by Earth Ugat
1 parent b17c192a

Bump to v0.4.4. Add more customization to Nginx templates.

  1 +## 0.4.4 - 2016-11-09
  2 +### Added
  3 +- Nginx recipe: Add template file customization for the main site config and for all site types.
  4 +
1 5 ## 0.4.3 - 2016-10-06
2 6 ### Fixed
3 7 - Missing ssl key and cert clauses in the "catch_all" blocks in the nginx config causes an error during SSL handshake if HTTPS is used.
... ...
... ... @@ -146,6 +146,12 @@ default['cfe-nginx-php-fpm']['nginx']['sites'] = [
146 146 #
147 147 #:server_statements_2 => [],
148 148
  149 + # The cookbook name and source file where the main
  150 + # config file template will be taken from.
  151 + #
  152 + #:main_config_cookbook => 'cfe-nginx-php-fpm',
  153 + #:main_config_source => 'nginx_site.conf.erb',
  154 +
149 155 # Enumerates the different site types this server supports.
150 156 # Each type element of this array is a hash containing different attributes.
151 157 #
... ... @@ -179,6 +185,14 @@ default['cfe-nginx-php-fpm']['nginx']['sites'] = [
179 185 # }
180 186 # :log_static => Whether to log accesses to the above static files
181 187 # or not. Default: false
  188 + # :source => The name of the config template.
  189 + # Default depends on :type attribute.
  190 + # :cookbook => The name of the cookbook where the template
  191 + # will be taken from. Default is this cookbook.
  192 + # :custom_params => A hash that will be passed into the template
  193 + # (along with the optional attributes mentioned
  194 + # above) as the variable called cparams.
  195 + # Default: {}
182 196 #
183 197 # Unique attributes for each type are indicated below:
184 198 # Basic PHP Site (:type => 'basic_php'):
... ... @@ -191,18 +205,7 @@ default['cfe-nginx-php-fpm']['nginx']['sites'] = [
191 205 # Proxy Websocket Webserver (:type => 'webserver_ws'):
192 206 # (none)
193 207 # Proxy Generic Webserver (:type => 'webserver_basic'):
194   - # :source => The name of the config template.
195   - # Default is 'inc_type_webserver_basic.erb'.
196   - # :cookbook => The name of the cookbook where the template
197   - # will be taken from. Default is this cookbook.
198   - # In combination with the :source attribute above,
199   - # any custom template in a wrapper cookbook can be
200   - # used. A template file 'inc_type_webserver_basic.erb'
201   - # exists as an example.
202   - # :custom_params => A hash that will be passed into the template
203   - # (along with the optional attributes mentioned
204   - # above) as the variable called cparams.
205   - # Default: {}
  208 + # (none)
206 209 #
207 210 #:types => []
208 211 #}
... ...
... ... @@ -4,7 +4,7 @@ maintainer_email 'sysadmin@chromedia.com'
4 4 license 'Apache License'
5 5 description 'Simplifies setup of Nginx+PHP-FPM in Chromedia.'
6 6 long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
7   -version '0.4.3'
  7 +version '0.4.4'
8 8
9 9 {
10 10 'openssl' => '4.4.0',
... ...
... ... @@ -65,6 +65,8 @@ node[cb]['nginx']['sites'].each do |site|
65 65 site_ins = site[:init_statements] || []
66 66 site_ss1 = site[:server_statements_1] || []
67 67 site_ss2 = site[:server_statements_2] || []
  68 + site_cb = site[:main_config_cookbook] || cb
  69 + site_source = site[:main_config_source] || 'nginx_site.conf.erb'
68 70
69 71 site_bl_robots = site.has_key?(:block_robots) ? site[:block_robots] : true
70 72 site_bl_fav = site.has_key?(:block_fav) ? site[:block_fav] : true
... ... @@ -82,9 +84,9 @@ node[cb]['nginx']['sites'].each do |site|
82 84 'X-Permitted-Cross-Domain-Policies' => 'none'
83 85 }
84 86
85   - path_crt = ''
86   - path_key = ''
87   - path_pass = ''
  87 + path_crt = ''
  88 + path_key = ''
  89 + path_pass = ''
88 90
89 91 # If TLS/SSL is enabled, configure it:
90 92 if site_ssl
... ... @@ -176,7 +178,8 @@ node[cb]['nginx']['sites'].each do |site|
176 178 :upstream_name => stype_ups,
177 179 :add_statements => stype_ads,
178 180 :static_types => stype_statics,
179   - :log_static => stype_logstatic
  181 + :log_static => stype_logstatic,
  182 + :cparams => stype[:custom_params] || {}
180 183 }
181 184
182 185 if stype[:upstream_servers] && stype[:upstream_servers].length > 0
... ... @@ -195,8 +198,9 @@ node[cb]['nginx']['sites'].each do |site|
195 198 stype[:fastcgi_intercept_errors] : false
196 199
197 200 template "#{inc_dir}/type_basic_php_#{site_sname}" do
198   - source 'inc_type_basic.erb'
199   - mode 0644
  201 + source stype[:source] || 'inc_type_basic.erb'
  202 + cookbook stype[:cookbook] || cb
  203 + mode 0644
200 204 variables vars
201 205 end
202 206 site_includes.push("#{inc_dir}/type_basic_php_#{site_sname}")
... ... @@ -210,8 +214,9 @@ node[cb]['nginx']['sites'].each do |site|
210 214 stype[:fastcgi_intercept_errors] : false
211 215
212 216 template "#{inc_dir}/inc_type_wordpress_#{site_sname}" do
213   - source 'inc_type_wordpress.erb'
214   - mode 0644
  217 + source stype[:source] || 'inc_type_wordpress.erb'
  218 + cookbook stype[:cookbook] || cb
  219 + mode 0644
215 220 variables vars
216 221 end
217 222 site_includes.push("#{inc_dir}/inc_type_wordpress_#{site_sname}")
... ... @@ -219,8 +224,9 @@ node[cb]['nginx']['sites'].each do |site|
219 224 # REVERSE PROXY WEBSERVER WITH WEBSOCKET
220 225 when 'webserver', 'webserver_ws'
221 226 template "#{inc_dir}/inc_type_webserver_ws_#{site_sname}" do
222   - source 'inc_type_webserver.erb'
223   - mode 0644
  227 + source stype[:source] || 'inc_type_webserver.erb'
  228 + cookbook stype[:cookbook] || cb
  229 + mode 0644
224 230 variables vars
225 231 end
226 232 site_ins.push("map $http_upgrade $connection_upgrade {\n"\
... ... @@ -231,11 +237,9 @@ node[cb]['nginx']['sites'].each do |site|
231 237
232 238 # GENERIC REVERSE PROXY WEBSERVER
233 239 when 'webserver_basic'
234   - vars[:cparams] = stype[:custom_params] || {}
235   -
236 240 template "#{inc_dir}/inc_type_webserver_basic_#{site_sname}" do
237 241 source stype[:source] || 'inc_type_webserver_basic.erb'
238   - cookbook stype[:cookbook] || cookbook_name
  242 + cookbook stype[:cookbook] || cb
239 243 mode 0644
240 244 variables vars
241 245 end
... ... @@ -249,7 +253,8 @@ node[cb]['nginx']['sites'].each do |site|
249 253
250 254 # Create the main config file for this site
251 255 template "#{node['nginx']['dir']}/sites-available/#{site_sname}" do
252   - source 'nginx_site.conf.erb'
  256 + source site_source
  257 + cookbook site_cb
253 258 mode 0644
254 259 notifies :restart, 'service[nginx]', :delayed
255 260 variables(
... ...