Commit 1d737d6374832869c13342080f49c826d68356eb
Committed by
Earth Ugat

1 parent
32e1d36b
Bump to v0.3.5
Showing
5 changed files
with
37 additions
and
19 deletions
@@ -24,6 +24,12 @@ Ubuntu 14.04 | @@ -24,6 +24,12 @@ Ubuntu 14.04 | ||
24 | <td><tt>''</tt></td> | 24 | <td><tt>''</tt></td> |
25 | </tr> | 25 | </tr> |
26 | <tr> | 26 | <tr> |
27 | + <td><tt>['cfe-nginx-php-fpm']['openssl']['dh_modulus']</tt></td> | ||
28 | + <td>Integer</td> | ||
29 | + <td>Used if at least one virtual site uses TLS.</td> | ||
30 | + <td><tt>4096</tt></td> | ||
31 | + </tr> | ||
32 | + <tr> | ||
27 | <td><tt>['cfe-nginx-php-fpm']['nginx']['sites']</tt></td> | 33 | <td><tt>['cfe-nginx-php-fpm']['nginx']['sites']</tt></td> |
28 | <td>Array/Hash</td> | 34 | <td>Array/Hash</td> |
29 | <td>Values that define the virtual servers to be hosted by Nginx.</td> | 35 | <td>Values that define the virtual servers to be hosted by Nginx.</td> |
@@ -27,6 +27,8 @@ default['cfe-nginx-php-fpm']['postfix']['email_domain'] = 'example.com' | @@ -27,6 +27,8 @@ default['cfe-nginx-php-fpm']['postfix']['email_domain'] = 'example.com' | ||
27 | # the default one ('www'), which is automatically installed by php-fpm | 27 | # the default one ('www'), which is automatically installed by php-fpm |
28 | default['cfe-nginx-php-fpm']['php-fpm']['delete_pool_www'] = true | 28 | default['cfe-nginx-php-fpm']['php-fpm']['delete_pool_www'] = true |
29 | 29 | ||
30 | +default['cfe-nginx-php-fpm']['openssl']['dh_modulus'] = 4096 | ||
31 | + | ||
30 | # Uncomment to set custom locations | 32 | # Uncomment to set custom locations |
31 | #default['cfe-nginx-php-fpm']['nginx']['inc_dir'] = | 33 | #default['cfe-nginx-php-fpm']['nginx']['inc_dir'] = |
32 | # "#{node['nginx']['dir']}/sites-available/include" | 34 | # "#{node['nginx']['dir']}/sites-available/include" |
@@ -92,7 +94,6 @@ default['cfe-nginx-php-fpm']['nginx']['sites'] = [ | @@ -92,7 +94,6 @@ default['cfe-nginx-php-fpm']['nginx']['sites'] = [ | ||
92 | # | 94 | # |
93 | # :self_signed => false, | 95 | # :self_signed => false, |
94 | # :cipher_suite => 'medium', # or 'modern' | 96 | # :cipher_suite => 'medium', # or 'modern' |
95 | - # :dh_modulus => 4096, | ||
96 | # :hsts_max_age => '15758000', | 97 | # :hsts_max_age => '15758000', |
97 | # :hsts_subdomains => true | 98 | # :hsts_subdomains => true |
98 | #}, | 99 | #}, |
@@ -4,9 +4,10 @@ maintainer_email 'sysadmin@chromedia.com' | @@ -4,9 +4,10 @@ maintainer_email 'sysadmin@chromedia.com' | ||
4 | license 'Apache License' | 4 | license 'Apache License' |
5 | description 'Simplifies setup of Nginx+PHP-FPM in Chromedia.' | 5 | description 'Simplifies setup of Nginx+PHP-FPM in Chromedia.' |
6 | long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) | 6 | long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) |
7 | -version '0.3.4' | 7 | +version '0.3.5' |
8 | 8 | ||
9 | { | 9 | { |
10 | + 'openssl' => '4.4.0', | ||
10 | 'php-fpm' => '0.7.5', | 11 | 'php-fpm' => '0.7.5', |
11 | 'mariadb' => '0.3.1', | 12 | 'mariadb' => '0.3.1', |
12 | 'postfix' => '3.6.2', | 13 | 'postfix' => '3.6.2', |
@@ -18,9 +18,13 @@ | @@ -18,9 +18,13 @@ | ||
18 | # limitations under the License. | 18 | # limitations under the License. |
19 | # | 19 | # |
20 | 20 | ||
21 | +include_recipe 'openssl::upgrade' | ||
22 | + | ||
23 | +cb = 'cfe-nginx-php-fpm' | ||
24 | + | ||
21 | # Create necessary directories | 25 | # Create necessary directories |
22 | -inc_dir = node['cfe-nginx-php-fpm']['nginx']['inc_dir'] | ||
23 | -priv_dir = node['cfe-nginx-php-fpm']['nginx']['priv_dir'] | 26 | +inc_dir = node[cb]['nginx']['inc_dir'] |
27 | +priv_dir = node[cb]['nginx']['priv_dir'] | ||
24 | 28 | ||
25 | [ inc_dir, priv_dir ].each do |ndir| | 29 | [ inc_dir, priv_dir ].each do |ndir| |
26 | directory ndir do | 30 | directory ndir do |
@@ -29,9 +33,18 @@ priv_dir = node['cfe-nginx-php-fpm']['nginx']['priv_dir'] | @@ -29,9 +33,18 @@ priv_dir = node['cfe-nginx-php-fpm']['nginx']['priv_dir'] | ||
29 | end | 33 | end |
30 | 34 | ||
31 | # Generate config files for each virtual server. | 35 | # Generate config files for each virtual server. |
32 | -catch_all_def_false = node['cfe-nginx-php-fpm']['nginx']['sites'].length > 1 | 36 | +catch_all_def_false = node[cb]['nginx']['sites'].length > 1 |
37 | + | ||
38 | +# If at least one site is using TLS, configure a high modulus DH param | ||
39 | +path_dhparam = "#{priv_dir}/dhparam.pem" | ||
40 | +if node[cb]['nginx']['sites'].any? { |site| site[:ssl] } | ||
41 | + openssl_dhparam path_dhparam do | ||
42 | + key_length node[cb]['openssl']['dh_modulus'] | ||
43 | + generator 2 | ||
44 | + end | ||
45 | +end | ||
33 | 46 | ||
34 | -node['cfe-nginx-php-fpm']['nginx']['sites'].each do |site| | 47 | +node[cb]['nginx']['sites'].each do |site| |
35 | 48 | ||
36 | if site.is_a?(Array) | 49 | if site.is_a?(Array) |
37 | site_sname = site[0] | 50 | site_sname = site[0] |
@@ -41,12 +54,12 @@ node['cfe-nginx-php-fpm']['nginx']['sites'].each do |site| | @@ -41,12 +54,12 @@ node['cfe-nginx-php-fpm']['nginx']['sites'].each do |site| | ||
41 | end | 54 | end |
42 | 55 | ||
43 | # Assign default values to attributes | 56 | # Assign default values to attributes |
44 | - site_index = site[:index] || nil | 57 | + site_index = site[:index] |
45 | site_aliases = site[:aliases] || [] | 58 | site_aliases = site[:aliases] || [] |
46 | - site_doc_root = site[:doc_root] || nil | ||
47 | - site_alo = site[:access_log_options] || nil | ||
48 | - site_ssl = site[:ssl] || nil | ||
49 | - site_auth = site[:auth] || nil | 59 | + site_doc_root = site[:doc_root] |
60 | + site_alo = site[:access_log_options] | ||
61 | + site_ssl = site[:ssl] | ||
62 | + site_auth = site[:auth] | ||
50 | site_ins = site[:init_statements] || [] | 63 | site_ins = site[:init_statements] || [] |
51 | site_ss1 = site[:server_statements_1] || [] | 64 | site_ss1 = site[:server_statements_1] || [] |
52 | site_ss2 = site[:server_statements_2] || [] | 65 | site_ss2 = site[:server_statements_2] || [] |
@@ -66,7 +79,6 @@ node['cfe-nginx-php-fpm']['nginx']['sites'].each do |site| | @@ -66,7 +79,6 @@ node['cfe-nginx-php-fpm']['nginx']['sites'].each do |site| | ||
66 | 79 | ||
67 | path_crt = '' | 80 | path_crt = '' |
68 | path_key = '' | 81 | path_key = '' |
69 | - path_dhparam = '' | ||
70 | path_pass = '' | 82 | path_pass = '' |
71 | 83 | ||
72 | # If TLS/SSL is enabled, configure it: | 84 | # If TLS/SSL is enabled, configure it: |
@@ -105,13 +117,6 @@ node['cfe-nginx-php-fpm']['nginx']['sites'].each do |site| | @@ -105,13 +117,6 @@ node['cfe-nginx-php-fpm']['nginx']['sites'].each do |site| | ||
105 | action :create_if_missing | 117 | action :create_if_missing |
106 | end | 118 | end |
107 | end | 119 | end |
108 | - | ||
109 | - # Configure a high modulus DH param | ||
110 | - path_dhparam = "#{priv_dir}/#{site_sname}.dhparam" | ||
111 | - dh_modulus = site_ssl[:dh_modulus] || 4096 | ||
112 | - execute "openssl dhparam -out #{path_dhparam} #{dh_modulus}" do | ||
113 | - not_if { ::File.exist?(path_dhparam) } | ||
114 | - end | ||
115 | end | 120 | end |
116 | 121 | ||
117 | # If basic auth is enabled, create htpasswd file | 122 | # If basic auth is enabled, create htpasswd file |