Extend hash based host_cfg_{ssl_,}{prepend,append} to vhost_{ssl_,}{header,footer}. fix vhost_location_alias/vhost_location_directory. Add {location_custom_cfg_prepend,append} to vhost_location_fastcgi, vhost_location_proxy and vhost_location_stub_status.

This commit is contained in:
Daniel Black 2014-03-08 12:16:07 +11:00
parent fdc05942f5
commit 4f8096c52c
9 changed files with 77 additions and 22 deletions

View file

@ -5,9 +5,17 @@ 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| -%>
<% if value.is_a?(Hash) -%><% value.each do |subkey,subvalue| -%>
<% Array(subkey).each do |asubkey| -%>
<% Array(subvalue).each do |asubvalue| -%>
<%= key %> <%= asubkey %> <%= asubvalue %>;
<% end %>
<% end %>
<% end -%><% else -%>
<% Array(value).each do |sub| -%>
<%= key %> <%= sub %>;
<% end %>
<% end -%>
<% end -%><% end -%>
}
<% if @rewrite_www_to_non_www -%>

View file

@ -18,9 +18,16 @@ 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| -%>
<% if value.is_a?(Hash) -%><% value.each do |subkey,subvalue| -%>
<% Array(subkey).each do |asubkey| -%>
<% Array(subvalue).each do |asubvalue| -%>
<%= key %> <%= asubkey %> <%= asubvalue %>;
<% end %>
<% end -%><% else -%>
<% Array(value).each do |sub| -%>
<%= key %> <%= sub %>;
<% end %>
<% end -%>
<% end -%><% end -%>
<% if @root -%>
root <%= @root %>;

View file

@ -1,9 +1,15 @@
location <%= @location %> {
<% if @location_cfg_prepend -%><% @location_cfg_prepend.sort_by {|k,v| k}.each do |key,value| -%>
<<<<<<< HEAD
<% if value.is_a?(Hash) -%><% value.each do |subkey,subvalue| -%>
<% Array(subkey).each do |asubkey| -%>
<% Array(subvalue).each do |asubvalue| -%>
<%= key %> <%= asubkey %> <%= asubvalue %>;
<% end %>
<% end -%><% else -%>
<% Array(value).each do |sub| -%>
<%= key %> <%= sub %>;
<% end %>
<% end -%>
<% end -%><% end -%>
alias <%= @location_alias %>;
<% if @location_cfg_append -%><% @location_cfg_append.sort_by {|k,v| k}.each do |key,value| -%>

View file

@ -5,12 +5,8 @@
<% 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 |key,value| -%>
<% if value.is_a?(Hash) -%><% value.each do |subkey,subvalue| -%>
<%= key %> <%= subkey %> <%= subvalue %>;
<% end -%><% else -%>
<%= key %> <%= value %>;
<% end -%>
<% if @location_custom_cfg_prepend -%><% @location_custom_cfg_prepend.each do |value| -%>
<%= value %>;
<% end -%><% end -%>
<% 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| -%>
@ -58,18 +54,7 @@
<% 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(subkey).each do |asubkey| -%>
<% Array(subvalue).each do |asubvalue| -%>
<%= key %> <%= asubkey %> <%= asubvalue %>;
<% end %>
<% end %>
<% end -%><% else -%>
<% Array(value).each do |sub| -%>
<%= key %> <%= sub %>;
<% end %>
<% end -%>
<% if @location_custom_cfg_append -%><% @location_custom_cfg_append.each do |value| -%>
<%= value %>;
<% end -%><% end -%>
}

View file

@ -1,4 +1,7 @@
location <%= @location %> {
<% if @location_custom_cfg_prepend -%><% @location_custom_cfg_prepend.each do |value| -%>
<%= value %>;
<% end -%><% end -%>
<% 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(subkey).each do |asubkey| -%>
@ -38,6 +41,9 @@
<%= key %> <%= sub %>;
<% end %>
<% end -%>
<% end -%><% end -%>
<% if @location_custom_cfg_append -%><% @location_custom_cfg_append.each do |value| -%>
<%= value %>;
<% end -%><% end -%>
}

View file

@ -5,7 +5,10 @@
<% 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 |key,value| -%>
<% if @location_custom_cfg_prepend -%><% @location_custom_cfg_prepend.each do |value| -%>
<%= value %>;
<% end -%><% end -%>
<% if @location_cfg_prepend -%><% @location_cfg_prepend.each do |key,value| -%>
<% if value.is_a?(Hash) -%><% value.each do |subkey,subvalue| -%>
<% Array(subkey).each do |asubkey| -%>
<% Array(subvalue).each do |asubvalue| -%>
@ -18,7 +21,6 @@
<% end %>
<% end -%>
<% end -%><% end -%>
<% end -%><% end -%>
<% if @proxy_cache -%>
proxy_cache <%= @proxy_cache %>;
proxy_cache_valid <%= @proxy_cache_valid %>;
@ -45,6 +47,9 @@
<% Array(value).each do |sub| -%>
<%= key %> <%= sub %>;
<% end %>
<% end -%><% end -%>
<% if @location_custom_cfg_append -%><% @location_custom_cfg_append.each do |value| -%>
<%= value %>;
<% end -%><% end -%>
}

View file

@ -1,4 +1,7 @@
location <%= @location %> {
<% if @location_custom_cfg_prepend -%><% @location_custom_cfg_prepend.each do |value| -%>
<%= value %>;
<% end -%><% end -%>
<% 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(subkey).each do |asubkey| -%>
@ -26,5 +29,9 @@
<% end %>
<% end -%>
<% end -%><% end -%>
<% if @location_custom_cfg_append -%><% @location_custom_cfg_append.each do |value| -%>
<%= value %>;
<% end -%><% end -%>
}

View file

@ -2,14 +2,29 @@
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| -%>
<% if value.is_a?(Hash) -%><% value.each do |subkey,subvalue| -%>
<% Array(subkey).each do |asubkey| -%>
<% Array(subvalue).each do |asubvalue| -%>
<%= key %> <%= asubkey %> <%= asubvalue %>;
<% end %>
<% end %>
<% end -%><% else -%>
<% Array(value).each do |sub| -%>
<%= key %> <%= sub %>;
<% 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| -%>
<% Array(subkey).each do |asubkey| -%>
<% Array(subvalue).each do |asubvalue| -%>
<%= key %> <%= asubkey %> <%= asubvalue %>;
<% end %>
<% end %>
<% end -%><% else -%>
<% Array(value).each do |sub| -%>
<%= key %> <%= sub %>;
<% end %>
<% end -%>
<% end -%><% end -%>
}
<% if @rewrite_www_to_non_www -%>

View file

@ -49,14 +49,30 @@ 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| -%>
<% if value.is_a?(Hash) -%><% value.each do |subkey,subvalue| -%>
<% Array(subkey).each do |asubkey| -%>
<% Array(subvalue).each do |asubvalue| -%>
<%= key %> <%= asubkey %> <%= asubvalue %>;
<% end %>
<% end %>
<% end -%><% else -%>
<% Array(value).each do |sub| -%>
<%= key %> <%= sub %>;
<% 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| -%>
<% if value.is_a?(Hash) -%><% value.each do |subkey,subvalue| -%>
<% Array(subkey).each do |asubkey| -%>
<% Array(subvalue).each do |asubvalue| -%>
<%= key %> <%= asubkey %> <%= asubvalue %>;
<% end %>
<% end %>
<% end -%><% else -%>
<% Array(value).each do |sub| -%>
<%= key %> <%= sub %>;
<% end %>
<% end -%>
<% end -%><% end -%>
<% if @root -%>
root <%= @root %>;