diff --git a/spec/defines/resource_location_spec.rb b/spec/defines/resource_location_spec.rb index 82de85714..893a5d788 100644 --- a/spec/defines/resource_location_spec.rb +++ b/spec/defines/resource_location_spec.rb @@ -44,11 +44,17 @@ { :title => 'should contain ordered prepended directives', :attr => 'location_cfg_prepend', - :value => { 'test1' => 'test value 1', 'test2' => 'test value 2', 'allow' => 'test value 3' }, + :value => { 'test1' => 'test value 1', 'test2' => ['test value 2a', 'test value 2b'], 'allow' => 'test value 3', + 'test4' => { 'subtest1' => ['"sub test value1a"', '"sub test value 1b"'], + 'subtest2' => '"sub test value2"' } }, :match => [ - ' allow test value 3;', - ' test1 test value 1;', - ' test2 test value 2;', + ' allow test value 3;', + ' test1 test value 1;', + ' test2 test value 2a;', + ' test2 test value 2b;', + ' test4 subtest1 "sub test value1a";', + ' test4 subtest1 "sub test value1b";', + ' test4 subtest2 "sub test value2";', ], }, { @@ -90,11 +96,17 @@ { :title => 'should contain ordered appended directives', :attr => 'location_cfg_append', - :value => { 'test1' => 'test value 1', 'test2' => 'test value 2', 'allow' => 'test value 3' }, + :value => { 'test1' => ['test value 1a', 'test value 1b'], 'test2' => 'test value 2', 'allow' => 'test value 3', + 'test4' => { 'subtest1' => ['"sub test value1a"', '"sub test value 1b"'], + 'subtest2' => '"sub test value2"' } }, :match => [ ' allow test value 3;', - ' test1 test value 1;', + ' test1 test value 1a;', + ' test1 test value 1b;', ' test2 test value 2;', + ' test4 subtest1 "sub test value1a";', + ' test4 subtest1 "sub test value1b";', + ' test4 subtest2 "sub test value2";', ], }, { @@ -157,11 +169,17 @@ { :title => 'should contain ordered prepended directives', :attr => 'location_cfg_prepend', - :value => { 'test1' => 'test value 1', 'test2' => 'test value 2', 'allow' => 'test value 3' }, + :value => { 'test1' => ['test value 1a', 'test value 1b'], 'test2' => 'test value 2', 'allow' => 'test value 3', + 'test4' => { 'subtest1' => ['"sub test value1a"', '"sub test value 1b"'], + 'subtest2' => '"sub test value2"' } }, :match => [ ' allow test value 3;', - ' test1 test value 1;', + ' test1 test value 1a;', + ' test1 test value 1b;', ' test2 test value 2;', + ' test4 subtest1 "sub test value1a";', + ' test4 subtest1 "sub test value1b";', + ' test4 subtest2 "sub test value2";', ], }, { @@ -173,11 +191,18 @@ { :title => 'should contain ordered appended directives', :attr => 'location_cfg_append', - :value => { 'test1' => 'test value 1', 'test2' => 'test value 2', 'allow' => 'test value 3' }, + :value => { 'test1' => 'test value 1', 'test2' => 'test value 2', 'allow' => ['test value 3a', 'test value 3b', 'test value 3c'], + 'test4' => { 'subtest1' => ['"sub test value1a"', '"sub test value 1b"'], + 'subtest2' => '"sub test value2"' } }, :match => [ - ' allow test value 3;', + ' allow test value 3a;', + ' allow test value 3b;', + ' allow test value 3c;', ' test1 test value 1;', ' test2 test value 2;', + ' test4 subtest1 "sub test value1a";', + ' test4 subtest1 "sub test value1b";', + ' test4 subtest2 "sub test value2";', ], }, ].each do |param| @@ -208,21 +233,33 @@ { :title => 'should contain ordered prepended directives', :attr => 'location_cfg_prepend', - :value => { 'test1' => 'test value 1', 'test2' => 'test value 2', 'allow' => 'test value 3' }, + :value => { 'test1' => 'test value 1', 'test2' => ['test value 2a', 'test value 2b'], 'allow' => 'test value 3', + 'test4' => { 'subtest1' => ['"sub test value1a"', '"sub test value 1b"'], + 'subtest2' => '"sub test value2"' } }, :match => [ - ' allow test value 3;', - ' test1 test value 1;', - ' test2 test value 2;', + ' allow test value 3;', + ' test1 test value 1;', + ' test2 test value 2a;', + ' test2 test value 2b;', + ' test4 subtest1 "sub test value1a";', + ' test4 subtest1 "sub test value1b";', + ' test4 subtest2 "sub test value2";', ], }, { :title => 'should contain ordered appended directives', :attr => 'location_cfg_append', - :value => { 'test1' => 'test value 1', 'test2' => 'test value 2', 'allow' => 'test value 3' }, + :value => { 'test1' => 'test value 1', 'test2' => ['test value 2a', 'test value 2b'], 'allow' => 'test value 3', + 'test4' => { 'subtest1' => ['"sub test value1a"', '"sub test value 1b"'], + 'subtest2' => '"sub test value2"' } }, :match => [ - ' allow test value 3;', - ' test1 test value 1;', - ' test2 test value 2;', + ' allow test value 3;', + ' test1 test value 1;', + ' test2 test value 2a;', + ' test2 test value 2b;', + ' test4 subtest1 "sub test value1a";', + ' test4 subtest1 "sub test value1b";', + ' test4 subtest2 "sub test value2";', ], }, ].each do |param| @@ -253,11 +290,17 @@ { :title => 'should contain ordered prepended directives', :attr => 'location_cfg_prepend', - :value => { 'test1' => 'test value 1', 'test2' => 'test value 2', 'allow' => 'test value 3' }, + :value => { 'test1' => ['test value 1a', 'test value 1b'], 'test2' => 'test value 2', 'allow' => 'test value 3', + 'test4' => { 'subtest1' => ['"sub test value1a"', '"sub test value 1b"'], + 'subtest2' => '"sub test value2"' } }, :match => [ - ' allow test value 3;', - ' test1 test value 1;', - ' test2 test value 2;', + ' allow test value 3;', + ' test1 test value 1a;', + ' test1 test value 1b;', + ' test2 test value 2;', + ' test4 subtest1 "sub test value1a";', + ' test4 subtest1 "sub test value1b";', + ' test4 subtest2 "sub test value2";', ], }, { @@ -299,11 +342,17 @@ { :title => 'should contain ordered appended directives', :attr => 'location_cfg_append', - :value => { 'test1' => 'test value 1', 'test2' => 'test value 2', 'allow' => 'test value 3' }, + :value => { 'test1' => 'test value 1', 'test2' => ['test value 2a', 'test value 2b'], 'allow' => 'test value 3', + 'test4' => { 'subtest1' => ['"sub test value1a"', '"sub test value 1b"'], + 'subtest2' => '"sub test value2"' } }, :match => [ ' allow test value 3;', ' test1 test value 1;', - ' test2 test value 2;', + ' test2 test value 2a;', + ' test2 test value 2b;', + ' test4 subtest1 "sub test value1a";', + ' test4 subtest1 "sub test value1b";', + ' test4 subtest2 "sub test value2";', ], }, ].each do |param| @@ -346,11 +395,17 @@ { :title => 'should contain ordered prepended directives', :attr => 'location_cfg_prepend', - :value => { 'test1' => 'test value 1', 'test2' => 'test value 2', 'allow' => 'test value 3' }, + :value => { 'test1' => 'test value 1', 'test2' => ['test value 2a', 'test value 2b'], 'allow' => 'test value 3', + 'test4' => { 'subtest1' => ['"sub test value1a"', '"sub test value 1b"'], + 'subtest2' => '"sub test value2"' } }, :match => [ ' allow test value 3;', ' test1 test value 1;', - ' test2 test value 2;', + ' test2 test value 2a;', + ' test2 test value 2b;', + ' test4 subtest1 "sub test value1a";', + ' test4 subtest1 "sub test value1b";', + ' test4 subtest2 "sub test value2";', ], }, { @@ -386,11 +441,17 @@ { :title => 'should contain ordered appended directives', :attr => 'location_cfg_append', - :value => { 'test1' => 'test value 1', 'test2' => 'test value 2', 'allow' => 'test value 3' }, + :value => { 'test1' => ['test value 1a', 'test value 1b'], 'test2' => 'test value 2', 'allow' => 'test value 3', + 'test4' => { 'subtest1' => ['"sub test value1a"', '"sub test value 1b"'], + 'subtest2' => '"sub test value2"' } }, :match => [ ' allow test value 3;', - ' test1 test value 1;', + ' test1 test value 1a;', + ' test1 test value 1b;', ' test2 test value 2;', + ' test4 subtest1 "sub test value1a";', + ' test4 subtest1 "sub test value1b";', + ' test4 subtest2 "sub test value2";', ], }, { @@ -441,11 +502,17 @@ { :title => 'should contain ordered config directives', :attr => 'location_custom_cfg', - :value => { 'test1' => 'test value 1', 'test2' => 'test value 2', 'allow' => 'test value 3' }, + :value => { 'test1' => ['test value 1a', 'test value 1b'], 'test2' => 'test value 2', 'allow' => 'test value 3', + 'test4' => { 'subtest1' => ['"sub test value1a"', '"sub test value 1b"'], + 'subtest2' => '"sub test value2"' } }, :match => [ ' allow test value 3;', - ' test1 test value 1;', + ' test1 test value 1a;', + ' test1 test value 1b;', ' test2 test value 2;', + ' test4 subtest1 "sub test value1a";', + ' test4 subtest1 "sub test value1b";', + ' test4 subtest2 "sub test value2";', ], }, ].each do |param| diff --git a/spec/defines/resource_upstream_spec.rb b/spec/defines/resource_upstream_spec.rb index a2290e3d7..8423eb437 100644 --- a/spec/defines/resource_upstream_spec.rb +++ b/spec/defines/resource_upstream_spec.rb @@ -36,11 +36,19 @@ 'test3' => 'test value 3', 'test1' => 'test value 1', 'test2' => 'test value 2', + 'test4' => ['test value 1', 'test value 2'], + 'test5' => {'subkey1' => 'subvalue1'}, + 'test6' => {'subkey1' => ['subvalue1', 'subvalue2']}, }, :match => [ ' test1 test value 1;', ' test2 test value 2;', ' test3 test value 3;', + ' test4 test value 1;', + ' test4 test value 2;', + ' test5 subkey1 subvalue1;', + ' test6 subkey1 subvalue1;', + ' test6 subkey1 subvalue2;', ], }, { diff --git a/spec/defines/resource_vhost_spec.rb b/spec/defines/resource_vhost_spec.rb index fe1d564c2..9d4ef3d90 100644 --- a/spec/defines/resource_vhost_spec.rb +++ b/spec/defines/resource_vhost_spec.rb @@ -130,10 +130,11 @@ { :title => 'should contain ordered prepended directives', :attr => 'vhost_cfg_prepend', - :value => { 'test1' => 'test value 1', 'test2' => 'test value 2', 'allow' => 'test value 3' }, + :value => { 'test1' => ['test value 1a', 'test value 1b'], 'test2' => 'test value 2', 'allow' => 'test value 3' }, :match => [ ' allow test value 3;', - ' test1 test value 1;', + ' test1 test value 1a;', + ' test1 test value 1b;', ' test2 test value 2;', ], }, @@ -218,11 +219,12 @@ { :title => 'should contain ordered appended directives', :attr => 'vhost_cfg_append', - :value => { 'test1' => 'test value 1', 'test2' => 'test value 2', 'allow' => 'test value 3' }, + :value => { 'test1' => 'test value 1', 'test2' => ['test value 2a', 'test value 2b'], 'allow' => 'test value 3' }, :match => [ ' allow test value 3;', ' test1 test value 1;', - ' test2 test value 2;', + ' test2 test value 2a;', + ' test2 test value 2b;', ], }, { @@ -383,6 +385,28 @@ :value => '/path/to/error.log', :match => ' error_log /path/to/error.log;', }, + { + :title => 'should contain ordered prepend directives', + :attr => 'vhost_cfg_prepend', + :value => { 'test1' => 'test value 1', 'test2' => ['test value 2a', 'test value 2b'], 'allow' => 'test value 3' }, + :match => [ + ' allow test value 3;', + ' test1 test value 1;', + ' test2 test value 2a;', + ' test2 test value 2b;', + ] + }, + { + :title => 'should contain ordered ssl prepend directives', + :attr => 'vhost_cfg_ssl_prepend', + :value => { 'test1' => 'test value 1', 'test2' => ['test value 2a', 'test value 2b'], 'allow' => 'test value 3' }, + :match => [ + ' allow test value 3;', + ' test1 test value 1;', + ' test2 test value 2a;', + ' test2 test value 2b;', + ] + }, { :title => 'should set root', :attr => 'use_default_location', @@ -436,6 +460,17 @@ ' test2 test value 2;', ] }, + { + :title => 'should contain ordered ssl appended directives', + :attr => 'vhost_cfg_ssl_append', + :value => { 'test1' => 'test value 1', 'test2' => ['test value 2a', 'test value 2b'], 'allow' => 'test value 3' }, + :match => [ + ' allow test value 3;', + ' test1 test value 1;', + ' test2 test value 2a;', + ' test2 test value 2b;', + ] + }, { :title => 'should contain www to non-www rewrite', :attr => 'rewrite_www_to_non_www', diff --git a/templates/conf.d/upstream.erb b/templates/conf.d/upstream.erb index 5da66ab20..a96121ab2 100644 --- a/templates/conf.d/upstream.erb +++ b/templates/conf.d/upstream.erb @@ -1,6 +1,14 @@ upstream <%= @name %> { <% if @upstream_cfg_prepend -%><% @upstream_cfg_prepend.sort_by{|k,v| k}.each do |key,value| %> - <%= key %> <%= value %>; +<% if value.is_a?(Hash) -%><% value.each do |subkey,subvalue| -%> +<% Array(subvalue).each do |asubvalue| -%> + <%= key %> <%= subkey %> <%= asubvalue %>; +<% end -%> +<% end -%><% else -%> +<% Array(value).each do |asubvalue| -%> + <%= key %> <%= asubvalue %>; +<% end -%> +<% end -%> <% end -%><% end -%> <% @members.each do |i| %> server <%= i %> fail_timeout=<%= @upstream_fail_timeout %>;<% end %> diff --git a/templates/vhost/vhost_footer.erb b/templates/vhost/vhost_footer.erb index 3181d4bf5..b4a4d7eb6 100644 --- a/templates/vhost/vhost_footer.erb +++ b/templates/vhost/vhost_footer.erb @@ -5,9 +5,16 @@ include <%= file %>; <%# exists) to be first in the output order. The hash keys also need to be -%> <%# sorted so that the ordering is stable. -%> <% if @vhost_cfg_append -%><% @vhost_cfg_append.sort_by{ |k, v| k.to_s == 'allow' ? '' : k.to_s }.each do |key,value| -%> - <%= key %> <%= value %>; +<% if value.is_a?(Hash) -%><% value.each do |subkey,subvalue| -%> +<% Array(subvalue).each do |asubvalue| -%> + <%= key %> <%= subkey %> <%= asubvalue %>; <% end -%> +<% end -%><% else -%> +<% Array(value).each do |asubvalue| -%> + <%= key %> <%= asubvalue %>; <% end -%> +<% end -%> +<% end -%><% end -%> } <% if @rewrite_www_to_non_www -%> server { @@ -15,4 +22,4 @@ server { server_name www.<%= @name.gsub(/^www\./, '') %>; rewrite ^ http://<%= @name.gsub(/^www\./, '') %>$uri permanent; } -<% end %> +<% end -%> diff --git a/templates/vhost/vhost_header.erb b/templates/vhost/vhost_header.erb index ca74f65d5..8fd7615ae 100644 --- a/templates/vhost/vhost_header.erb +++ b/templates/vhost/vhost_header.erb @@ -18,7 +18,15 @@ server { <%# exists) to be first in the output order. The hash keys also need to be -%> <%# sorted so that the ordering is stable. -%> <% if @vhost_cfg_prepend -%><% @vhost_cfg_prepend.sort_by{ |k, v| k.to_s == 'allow' ? '' : k.to_s }.each do |key,value| -%> - <%= key %> <%= value %>; +<% if value.is_a?(Hash) -%><% value.each do |subkey,subvalue| -%> +<% Array(subvalue).each do |asubvalue| -%> + <%= key %> <%= subkey %> <%= asubvalue %>; +<% end -%> +<% end -%><% else -%> +<% Array(value).each do |asubvalue| -%> + <%= key %> <%= asubvalue %>; +<% end -%> +<% end -%> <% end -%><% end -%> <% if @root -%> root <%= @root %>; diff --git a/templates/vhost/vhost_location_alias.erb b/templates/vhost/vhost_location_alias.erb index 23d102ba0..ccd47f8df 100644 --- a/templates/vhost/vhost_location_alias.erb +++ b/templates/vhost/vhost_location_alias.erb @@ -1,10 +1,47 @@ location <%= @location %> { +<% if @location_custom_cfg_prepend -%><% @location_custom_cfg_prepend.each do |key,value| -%> +<% if value.is_a?(Hash) -%><% value.each do |subkey,subvalue| -%> +<% Array(subvalue).each do |asubvalue| -%> + <%= key %> <%= subkey %> <%= asubvalue %>; +<% end -%> +<% end -%><% else -%> +<% Array(value).each do |asubvalue| -%> + <%= key %> <%= asubvalue %>; +<% end -%> +<% end -%> +<% end -%><% end -%> <% if @location_cfg_prepend -%><% @location_cfg_prepend.sort_by {|k,v| k}.each do |key,value| -%> - <%= key %> <%= value %>; +<% if value.is_a?(Hash) -%><% value.each do |subkey,subvalue| -%> +<% Array(subvalue).each do |asubvalue| -%> + <%= key %> <%= subkey %> <%= asubvalue %>; +<% end -%> +<% end -%><% else -%> +<% Array(value).each do |asubvalue| -%> + <%= key %> <%= asubvalue %>; +<% end -%> +<% end -%> <% end -%><% end -%> alias <%= @location_alias %>; <% if @location_cfg_append -%><% @location_cfg_append.sort_by {|k,v| k}.each do |key,value| -%> - <%= key %> <%= value %>; +<% if value.is_a?(Hash) -%><% value.each do |subkey,subvalue| -%> +<% Array(subvalue).each do |asubvalue| -%> + <%= key %> <%= subkey %> <%= asubvalue %>; +<% end -%> +<% end -%><% else -%> +<% Array(value).each do |asubvalue| -%> + <%= key %> <%= asubvalue %>; +<% end -%> +<% end -%> +<% end -%><% end -%> +<% if @location_custom_cfg_append -%><% @location_custom_cfg_append.each do |key,value| -%> +<% if value.is_a?(Hash) -%><% value.each do |subkey,subvalue| -%> +<% Array(subvalue).each do |asubvalue| -%> + <%= key %> <%= subkey %> <%= asubvalue %>; +<% end -%> +<% end -%><% else -%> +<% Array(value).each do |asubvalue| -%> + <%= key %> <%= asubvalue %>; +<% end -%> +<% end -%> <% end -%><% end -%> } - diff --git a/templates/vhost/vhost_location_directory.erb b/templates/vhost/vhost_location_directory.erb index 36874abbf..1e9382c9e 100644 --- a/templates/vhost/vhost_location_directory.erb +++ b/templates/vhost/vhost_location_directory.erb @@ -9,7 +9,15 @@ <%= value %> <% end -%><% end -%> <% if @location_cfg_prepend -%><% @location_cfg_prepend.sort_by {|k,v| k}.each do |key,value| -%> - <%= key %> <%= value %>; +<% if value.is_a?(Hash) -%><% value.each do |subkey,subvalue| -%> +<% Array(subvalue).each do |asubvalue| -%> + <%= key %> <%= subkey %> <%= asubvalue %>; +<% end -%> +<% end -%><% else -%> +<% Array(value).each do |asubvalue| -%> + <%= key %> <%= asubvalue %>; +<% end -%> +<% end -%> <% end -%><% end -%> <% if defined? @www_root -%> root <%= @www_root %>; @@ -33,9 +41,25 @@ auth_basic_user_file <%= @auth_basic_user_file %>; <% end -%> <% if @location_cfg_append -%><% @location_cfg_append.sort_by {|k,v| k}.each do |key,value| -%> - <%= key %> <%= value %>; +<% if value.is_a?(Hash) -%><% value.each do |subkey,subvalue| -%> +<% Array(subvalue).each do |asubvalue| -%> + <%= key %> <%= subkey %> <%= asubvalue %>; +<% end -%> +<% end -%><% else -%> +<% Array(value).each do |asubvalue| -%> + <%= key %> <%= asubvalue %>; +<% end -%> +<% end -%> <% end -%><% end -%> -<% if @location_custom_cfg_append -%><% @location_custom_cfg_append.each do |value| -%> - <%= value %> +<% if @location_custom_cfg_append -%><% @location_custom_cfg_append.each do |key,value| -%> +<% if value.is_a?(Hash) -%><% value.each do |subkey,subvalue| -%> +<% Array(subvalue).each do |asubvalue| -%> + <%= key %> <%= subkey %> <%= asubvalue %>; +<% end -%> +<% end -%><% else -%> +<% Array(value).each do |asubvalue| -%> + <%= key %> <%= asubvalue %>; +<% end -%> +<% end -%> <% end -%><% end -%> } diff --git a/templates/vhost/vhost_location_empty.erb b/templates/vhost/vhost_location_empty.erb index aea023cb6..10f0d3c6c 100644 --- a/templates/vhost/vhost_location_empty.erb +++ b/templates/vhost/vhost_location_empty.erb @@ -1,6 +1,13 @@ location <%= @location %> { <% if @location_custom_cfg -%><% @location_custom_cfg.sort_by {|k,v| k}.each do |key,value| -%> - <%= key %> <%= value %>; +<% if value.is_a?(Hash) -%><% value.each do |subkey,subvalue| -%> +<% Array(subvalue).each do |asubvalue| -%> + <%= key %> <%= subkey %> <%= asubvalue %>; +<% end -%> +<% end -%><% else -%> +<% Array(value).each do |asubvalue| -%> + <%= key %> <%= asubvalue %>; +<% end -%> +<% end -%> <% end -%><% end -%> } - diff --git a/templates/vhost/vhost_location_fastcgi.erb b/templates/vhost/vhost_location_fastcgi.erb index 05d15fbf2..e93a91033 100644 --- a/templates/vhost/vhost_location_fastcgi.erb +++ b/templates/vhost/vhost_location_fastcgi.erb @@ -1,9 +1,25 @@ location <%= @location %> { -<% if @location_cfg_prepend -%><% @location_cfg_prepend.sort_by {|k,v| k}.each do |key,value| -%> - <%= key %> <%= value %>; +<% if @location_custom_cfg_prepend -%><% @location_custom_cfg_prepend.each do |key,value| -%> +<% if value.is_a?(Hash) -%><% value.each do |subkey,subvalue| -%> +<% Array(subvalue).each do |asubvalue| -%> + <%= key %> <%= subkey %> <%= asubvalue %>; +<% end -%> +<% end -%><% else -%> +<% Array(value).each do |asubvalue| -%> + <%= key %> <%= asubvalue %>; +<% end -%> +<% end -%> <% end -%><% end -%> -<% if @location_custom_cfg_prepend -%><% @location_custom_cfg_prepend.each do |value| -%> - <%= value %> +<% if @location_cfg_prepend -%><% @location_cfg_prepend.sort_by {|k,v| k}.each do |key,value| -%> +<% if value.is_a?(Hash) -%><% value.each do |subkey,subvalue| -%> +<% Array(subvalue).each do |asubvalue| -%> + <%= key %> <%= subkey %> <%= asubvalue %>; +<% end -%> +<% end -%><% else -%> +<% Array(value).each do |asubvalue| -%> + <%= key %> <%= asubvalue %>; +<% end -%> +<% end -%> <% end -%><% end -%> <% if defined? @www_root -%> root <%= @www_root %>; @@ -20,10 +36,25 @@ fastcgi_param SCRIPT_FILENAME <%= @fastcgi_script %>; <% end -%> <% if @location_cfg_append -%><% @location_cfg_append.sort_by {|k,v| k}.each do |key,value| -%> - <%= key %> <%= value %>; +<% if value.is_a?(Hash) -%><% value.each do |subkey,subvalue| -%> +<% Array(subvalue).each do |asubvalue| -%> + <%= key %> <%= subkey %> <%= asubvalue %>; +<% end -%> +<% end -%><% else -%> +<% Array(value).each do |asubvalue| -%> + <%= key %> <%= asubvalue %>; +<% end -%> +<% end -%> <% end -%><% end -%> -<% if @location_custom_cfg_append -%><% @location_custom_cfg_append.each do |value| -%> - <%= value %> +<% if @location_custom_cfg_append -%><% @location_custom_cfg_append.each do |key,value| -%> +<% if value.is_a?(Hash) -%><% value.each do |subkey,subvalue| -%> +<% Array(subvalue).each do |asubvalue| -%> + <%= key %> <%= subkey %> <%= asubvalue %>; +<% end -%> +<% end -%><% else -%> +<% Array(value).each do |asubvalue| -%> + <%= key %> <%= asubvalue %>; +<% end -%> +<% end -%> <% end -%><% end -%> } - diff --git a/templates/vhost/vhost_location_proxy.erb b/templates/vhost/vhost_location_proxy.erb index d6420c3f4..6b8acc2db 100644 --- a/templates/vhost/vhost_location_proxy.erb +++ b/templates/vhost/vhost_location_proxy.erb @@ -5,11 +5,27 @@ <% if @location_deny -%><% @location_deny.each do |deny_rule| -%> deny <%= deny_rule %>; <% end -%><% end -%> -<% if @location_custom_cfg_prepend -%><% @location_custom_cfg_prepend.each do |value| -%> - <%= value %> +<% if @location_custom_cfg_prepend -%><% @location_custom_cfg_prepend.each do |key,value| -%> +<% if value.is_a?(Hash) -%><% value.each do |subkey,subvalue| -%> +<% Array(subvalue).each do |asubvalue| -%> + <%= key %> <%= subkey %> <%= asubvalue %>; +<% end -%> +<% end -%><% else -%> +<% Array(value).each do |asubvalue| -%> + <%= key %> <%= asubvalue %>; +<% end -%> +<% end -%> <% end -%><% end -%> <% if @location_cfg_prepend -%><% @location_cfg_prepend.sort_by {|k,v| k}.each do |key,value| -%> - <%= key %> <%= value %>; +<% if value.is_a?(Hash) -%><% value.each do |subkey,subvalue| -%> +<% Array(subvalue).each do |asubvalue| -%> + <%= key %> <%=subkey %> <%= asubvalue %>; +<% end -%> +<% end -%><% else -%> +<% Array(value).each do |asubvalue| -%> + <%= key %> <%= asubvalue %>; +<% end -%> +<% end -%> <% end -%><% end -%> <% if @proxy_cache -%> proxy_cache <%= @proxy_cache %>; @@ -27,10 +43,25 @@ rewrite <%= rewrite_rule %>; <% end -%> <% if @location_cfg_append -%><% @location_cfg_append.sort_by {|k,v| k}.each do |key,value| -%> - <%= key %> <%= value %>; +<% if value.is_a?(Hash) -%><% value.each do |subkey,subvalue| -%> +<% Array(subvalue).each do |asubvalue| -%> + <%= key %> <%= subkey %> <%= asubvalue %>; +<% end -%> +<% end -%><% else -%> +<% Array(value).each do |asubvalue| -%> + <%= key %> <%= asubvalue %>; +<% end -%> +<% end -%> <% end -%><% end -%> -<% if @location_custom_cfg_append -%><% @location_custom_cfg_append.each do |value| -%> - <%= value %> +<% if @location_custom_cfg_append -%><% @location_custom_cfg_append.each do |key,value| -%> +<% if value.is_a?(Hash) -%><% value.each do |subkey,subvalue| -%> +<% Array(subvalue).each do |asubvalue| -%> + <%= key %> <%= subkey %> <%= asubvalue %>; +<% end -%> +<% end -%><% else -%> +<% Array(value).each do |asubvalue| -%> + <%= key %> <%= asubvalue %>; +<% end -%> +<% end -%> <% end -%><% end -%> } - diff --git a/templates/vhost/vhost_location_stub_status.erb b/templates/vhost/vhost_location_stub_status.erb index 29e93dfaa..c560933e8 100644 --- a/templates/vhost/vhost_location_stub_status.erb +++ b/templates/vhost/vhost_location_stub_status.erb @@ -1,10 +1,47 @@ location <%= @location %> { +<% if @location_custom_cfg_prepend -%><% @location_custom_cfg_prepend.each do |key,value| -%> +<% if value.is_a?(Hash) -%><% value.each do |subkey,subvalue| -%> +<% Array(subvalue).each do |asubvalue| -%> + <%= key %> <%= subkey %> <%= asubvalue %>; +<% end -%> +<% end -%><% else -%> +<% Array(value).each do |asubvalue| -%> + <%= key %> <%= asubvalue %>; +<% end -%> +<% end -%> +<% end -%><% end -%> <% if @location_cfg_prepend -%><% @location_cfg_prepend.sort_by {|k,v| k}.each do |key,value| -%> - <%= key %> <%= value %>; +<% if value.is_a?(Hash) -%><% value.each do |subkey,subvalue| -%> +<% Array(subvalue).each do |asubvalue| -%> + <%= key %> <%= subkey %> <%= asubvalue %>; +<% end -%> +<% end -%><% else -%> +<% Array(value).each do |asubvalue| -%> + <%= key %> <%= asubvalue %>; +<% end -%> +<% end -%> <% end -%><% end -%> stub_status on; <% if @location_cfg_append -%><% @location_cfg_append.sort_by {|k,v| k}.each do |key,value| -%> - <%= key %> <%= value %>; +<% if value.is_a?(Hash) -%><% value.each do |subkey,subvalue| -%> +<% Array(subvalue).each do |asubvalue| -%> + <%= key %> <%= subkey %> <%= asubvalue %>; +<% end -%> +<% end -%><% else -%> +<% Array(value).each do |asubvalue| -%> + <%= key %> <%= asubvalue %>; +<% end -%> +<% end -%> +<% end -%><% end -%> +<% if @location_custom_cfg_append -%><% @location_custom_cfg_append.each do |key,value| -%> +<% if value.is_a?(Hash) -%><% value.each do |subkey,subvalue| -%> +<% Array(subvalue).each do |asubvalue| -%> + <%= key %> <%= subkey %> <%= asubvalue %>; +<% end -%> +<% end -%><% else -%> +<% Array(value).each do |asubvalue| -%> + <%= key %> <%= asubvalue %>; +<% end -%> +<% end -%> <% end -%><% end -%> } - diff --git a/templates/vhost/vhost_ssl_footer.erb b/templates/vhost/vhost_ssl_footer.erb index 217660d2f..86419a232 100644 --- a/templates/vhost/vhost_ssl_footer.erb +++ b/templates/vhost/vhost_ssl_footer.erb @@ -2,13 +2,27 @@ include <%= file %>; <% end -%><% end -%> <% if @vhost_cfg_append -%><% @vhost_cfg_append.sort_by{ |k, v| k.to_s == 'allow' ? '' : k.to_s }.each do |key,value| -%> - <%= key %> <%= value %>; +<% if value.is_a?(Hash) -%><% value.each do |subkey,subvalue| -%> +<% Array(subvalue).each do |asubvalue| -%> + <%= key %> <%= subkey %> <%= asubvalue %>; <% end -%> +<% end -%><% else -%> +<% Array(value).each do |asubvalue| -%> + <%= key %> <%= asubvalue %>; <% end -%> +<% end -%> +<% end -%><% end -%> <% if @vhost_cfg_ssl_append -%><% @vhost_cfg_ssl_append.sort_by{ |k, v| k.to_s == 'allow' ? '' : k.to_s }.each do |key,value| -%> - <%= key %> <%= value %>; +<% if value.is_a?(Hash) -%><% value.each do |subkey,subvalue| -%> +<% Array(subvalue).each do |asubvalue| -%> + <%= key %> <%= subkey %> <%= asubvalue %>; <% end -%> +<% end -%><% else -%> +<% Array(value).each do |asubvalue| -%> + <%= key %> <%= asubvalue %>; <% end -%> +<% end -%> +<% end -%><% end -%> } <% if @rewrite_www_to_non_www -%> server { diff --git a/templates/vhost/vhost_ssl_header.erb b/templates/vhost/vhost_ssl_header.erb index f5992baaa..e165b7123 100644 --- a/templates/vhost/vhost_ssl_header.erb +++ b/templates/vhost/vhost_ssl_header.erb @@ -49,10 +49,26 @@ server { error_log <%= @ssl_error_log %>; <% if @vhost_cfg_prepend -%><% @vhost_cfg_prepend.sort_by{ |k, v| k.to_s == 'allow' ? '' : k.to_s }.each do |key,value| -%> - <%= key %> <%= value %>; +<% if value.is_a?(Hash) -%><% value.each do |subkey,subvalue| -%> +<% Array(subvalue).each do |asubvalue| -%> + <%= key %> <%= subkey %> <%= asubvalue %>; +<% end -%> +<% end -%><% else -%> +<% Array(value).each do |asubvalue| -%> + <%= key %> <%= asubvalue %>; +<% end -%> +<% end -%> <% end -%><% end -%> <% if @vhost_cfg_ssl_prepend -%><% @vhost_cfg_ssl_prepend.sort_by{ |k, v| k.to_s == 'allow' ? '' : k.to_s }.each do |key,value| -%> - <%= key %> <%= value %>; +<% if value.is_a?(Hash) -%><% value.each do |subkey,subvalue| -%> +<% Array(subvalue).each do |asubvalue| -%> + <%= key %> <%= subkey %> <%= asubvalue %>; +<% end -%> +<% end -%><% else -%> +<% Array(value).each do |asubvalue| -%> + <%= key %> <%= asubvalue %>; +<% end -%> +<% end -%> <% end -%><% end -%> <% if @root -%> root <%= @root %>;