Merge pull request #352 from rabbitt/refactor-location
refactor locations to remove a bit of redundancy
This commit is contained in:
commit
4f38050148
15 changed files with 169 additions and 339 deletions
|
@ -258,17 +258,17 @@ define nginx::resource::location (
|
|||
|
||||
# Use proxy or fastcgi template if $proxy is defined, otherwise use directory template.
|
||||
if ($proxy != undef) {
|
||||
$content_real = template('nginx/vhost/vhost_location_proxy.erb')
|
||||
$content_real = template('nginx/vhost/locations/proxy.erb')
|
||||
} elsif ($location_alias != undef) {
|
||||
$content_real = template('nginx/vhost/vhost_location_alias.erb')
|
||||
$content_real = template('nginx/vhost/locations/alias.erb')
|
||||
} elsif ($stub_status != undef) {
|
||||
$content_real = template('nginx/vhost/vhost_location_stub_status.erb')
|
||||
$content_real = template('nginx/vhost/locations/stub_status.erb')
|
||||
} elsif ($fastcgi != undef) {
|
||||
$content_real = template('nginx/vhost/vhost_location_fastcgi.erb')
|
||||
$content_real = template('nginx/vhost/locations/fastcgi.erb')
|
||||
} elsif ($www_root != undef) {
|
||||
$content_real = template('nginx/vhost/vhost_location_directory.erb')
|
||||
$content_real = template('nginx/vhost/locations/directory.erb')
|
||||
} else {
|
||||
$content_real = template('nginx/vhost/vhost_location_empty.erb')
|
||||
$content_real = template('nginx/vhost/locations/empty.erb')
|
||||
}
|
||||
|
||||
if $fastcgi != undef and !defined(File[$fastcgi_params]) {
|
||||
|
@ -286,7 +286,11 @@ define nginx::resource::location (
|
|||
concat::fragment { "${tmpFile}":
|
||||
ensure => present,
|
||||
target => $config_file,
|
||||
content => $content_real,
|
||||
content => join([
|
||||
template('nginx/vhost/location_header.erb'),
|
||||
$content_real,
|
||||
template('nginx/vhost/location_footer.erb')
|
||||
], ''),
|
||||
order => "${priority}",
|
||||
}
|
||||
}
|
||||
|
@ -299,7 +303,11 @@ define nginx::resource::location (
|
|||
concat::fragment {"${sslTmpFile}":
|
||||
ensure => present,
|
||||
target => $config_file,
|
||||
content => $content_real,
|
||||
content => join([
|
||||
template('nginx/vhost/location_header.erb'),
|
||||
$content_real,
|
||||
template('nginx/vhost/location_footer.erb')
|
||||
], ''),
|
||||
order => "${ssl_priority}",
|
||||
}
|
||||
}
|
||||
|
|
31
templates/vhost/location_footer.erb
Normal file
31
templates/vhost/location_footer.erb
Normal file
|
@ -0,0 +1,31 @@
|
|||
<% if @location_cfg_append -%>
|
||||
<%- @location_cfg_append.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 @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 -%>
|
||||
}
|
41
templates/vhost/location_header.erb
Normal file
41
templates/vhost/location_header.erb
Normal file
|
@ -0,0 +1,41 @@
|
|||
location <%= @location %> {
|
||||
<% if @location_allow -%>
|
||||
<%- @location_allow.each do |allow_rule| -%>
|
||||
allow <%= allow_rule %>;
|
||||
<%- end -%>
|
||||
<% end -%>
|
||||
<% 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| -%>
|
||||
<%- 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| -%>
|
||||
<%- 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 -%>
|
4
templates/vhost/locations/alias.erb
Normal file
4
templates/vhost/locations/alias.erb
Normal file
|
@ -0,0 +1,4 @@
|
|||
alias <%= @location_alias %>;
|
||||
<% if defined? @autoindex -%>
|
||||
autoindex <%= @autoindex %>;
|
||||
<% end -%>
|
21
templates/vhost/locations/directory.erb
Normal file
21
templates/vhost/locations/directory.erb
Normal file
|
@ -0,0 +1,21 @@
|
|||
<% if defined? @www_root -%>
|
||||
root <%= @www_root %>;
|
||||
<% end -%>
|
||||
<% if @try_files -%>
|
||||
try_files<% @try_files.each do |try| -%> <%= try %><% end -%>;
|
||||
<% end -%>
|
||||
<% if defined? @autoindex -%>
|
||||
autoindex <%= @autoindex %>;
|
||||
<% end -%>
|
||||
<% if @index_files.count > 0 -%>
|
||||
index <% Array(@index_files).each do |i| %> <%= i %><% end %>;
|
||||
<% end -%>
|
||||
<% @rewrite_rules.each do |rewrite_rule| -%>
|
||||
rewrite <%= rewrite_rule %>;
|
||||
<% end -%>
|
||||
<% if defined? @auth_basic -%>
|
||||
auth_basic "<%= @auth_basic %>";
|
||||
<% end -%>
|
||||
<% if defined? @auth_basic_user_file -%>
|
||||
auth_basic_user_file <%= @auth_basic_user_file %>;
|
||||
<% end -%>
|
15
templates/vhost/locations/empty.erb
Normal file
15
templates/vhost/locations/empty.erb
Normal file
|
@ -0,0 +1,15 @@
|
|||
<% if @location_custom_cfg -%>
|
||||
<%- @location_custom_cfg.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 -%>
|
14
templates/vhost/locations/fastcgi.erb
Normal file
14
templates/vhost/locations/fastcgi.erb
Normal file
|
@ -0,0 +1,14 @@
|
|||
<% if defined? @www_root -%>
|
||||
root <%= @www_root %>;
|
||||
<% end -%>
|
||||
<% if @fastcgi_split_path -%>
|
||||
fastcgi_split_path_info <%= @fastcgi_split_path %>;
|
||||
<% end -%>
|
||||
<% if @try_files -%>
|
||||
try_files<% @try_files.each do |try| -%> <%= try %><% end -%>;
|
||||
<% end -%>
|
||||
include <%= @fastcgi_params %>;
|
||||
fastcgi_pass <%= @fastcgi %>;
|
||||
<% if defined? @fastcgi_script %>
|
||||
fastcgi_param SCRIPT_FILENAME <%= @fastcgi_script %>;
|
||||
<% end -%>
|
26
templates/vhost/locations/proxy.erb
Normal file
26
templates/vhost/locations/proxy.erb
Normal file
|
@ -0,0 +1,26 @@
|
|||
<% if @proxy_cache -%>
|
||||
proxy_cache <%= @proxy_cache %>;
|
||||
proxy_cache_valid <%= @proxy_cache_valid %>;
|
||||
<% end -%>
|
||||
proxy_pass <%= @proxy %>;
|
||||
proxy_read_timeout <%= @proxy_read_timeout %>;
|
||||
proxy_connect_timeout <%= @proxy_connect_timeout %>;
|
||||
proxy_redirect <%= @proxy_redirect %>;
|
||||
<% @proxy_set_header.each do |header| -%>
|
||||
proxy_set_header <%= header %>;
|
||||
<% end -%>
|
||||
<% if @proxy_method -%>
|
||||
proxy_method <%= @proxy_method %>;
|
||||
<% end -%>
|
||||
<% if @proxy_set_body -%>
|
||||
proxy_set_body <%= @proxy_set_body %>;
|
||||
<% end -%>
|
||||
<% @rewrite_rules.each do |rewrite_rule| -%>
|
||||
rewrite <%= rewrite_rule %>;
|
||||
<% end -%>
|
||||
<% if defined? @auth_basic -%>
|
||||
auth_basic "<%= @auth_basic %>";
|
||||
<% end -%>
|
||||
<% if defined? @auth_basic_user_file -%>
|
||||
auth_basic_user_file <%= @auth_basic_user_file %>;
|
||||
<% end -%>
|
1
templates/vhost/locations/stub_status.erb
Normal file
1
templates/vhost/locations/stub_status.erb
Normal file
|
@ -0,0 +1 @@
|
|||
stub_status on;
|
|
@ -1,56 +0,0 @@
|
|||
location <%= @location %> {
|
||||
<% if @location_allow -%><% @location_allow.each do |allow_rule| -%>
|
||||
allow <%= allow_rule %>;
|
||||
<% end -%><% end -%>
|
||||
<% 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| -%>
|
||||
<% 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| -%>
|
||||
<% 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 defined? @autoindex -%>
|
||||
autoindex <%= @autoindex %>;
|
||||
<% end -%>
|
||||
<% if @location_cfg_append -%><% @location_cfg_append.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 @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 -%>
|
||||
}
|
|
@ -1,65 +0,0 @@
|
|||
location <%= @location %> {
|
||||
<% if @location_allow -%><% @location_allow.each do |allow_rule| -%>
|
||||
allow <%= allow_rule %>;
|
||||
<% end -%><% end -%>
|
||||
<% 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 %>
|
||||
<% 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(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 %>;
|
||||
<% end -%>
|
||||
<% if @try_files -%>
|
||||
try_files<% @try_files.each do |try| -%> <%= try %><% end -%>;
|
||||
<% end -%>
|
||||
<% if defined? @autoindex -%>
|
||||
autoindex <%= @autoindex %>;
|
||||
<% end -%>
|
||||
<% if @index_files.count > 0 -%>
|
||||
index <% Array(@index_files).each do |i| %> <%= i %><% end %>;
|
||||
<% end -%>
|
||||
<% @rewrite_rules.each do |rewrite_rule| -%>
|
||||
rewrite <%= rewrite_rule %>;
|
||||
<% end -%>
|
||||
<% if defined? @auth_basic -%>
|
||||
auth_basic "<%= @auth_basic %>";
|
||||
<% end -%>
|
||||
<% if defined? @auth_basic_user_file -%>
|
||||
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| -%>
|
||||
<% 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 -%>
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
location <%= @location %> {
|
||||
<% if @location_custom_cfg -%><% @location_custom_cfg.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 -%>
|
||||
}
|
|
@ -1,66 +0,0 @@
|
|||
location <%= @location %> {
|
||||
<% if @location_allow -%><% @location_allow.each do |allow_rule| -%>
|
||||
allow <%= allow_rule %>;
|
||||
<% end -%><% end -%>
|
||||
<% 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| -%>
|
||||
<% 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| -%>
|
||||
<% 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 %>;
|
||||
<% end -%>
|
||||
<% if @fastcgi_split_path -%>
|
||||
fastcgi_split_path_info <%= @fastcgi_split_path %>;
|
||||
<% end -%>
|
||||
<% if @try_files -%>
|
||||
try_files<% @try_files.each do |try| -%> <%= try %><% end -%>;
|
||||
<% end -%>
|
||||
include <%= @fastcgi_params %>;
|
||||
fastcgi_pass <%= @fastcgi %>;
|
||||
<% if defined? @fastcgi_script %>
|
||||
fastcgi_param SCRIPT_FILENAME <%= @fastcgi_script %>;
|
||||
<% end -%>
|
||||
<% if @location_cfg_append -%><% @location_cfg_append.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 @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 -%>
|
||||
}
|
|
@ -1,78 +0,0 @@
|
|||
location <%= @location %> {
|
||||
<% if @location_allow -%><% @location_allow.each do |allow_rule| -%>
|
||||
allow <%= allow_rule %>;
|
||||
<% end -%><% end -%>
|
||||
<% 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| -%>
|
||||
<% 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| -%>
|
||||
<% 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 %>;
|
||||
proxy_cache_valid <%= @proxy_cache_valid %>;
|
||||
<% end -%>
|
||||
proxy_pass <%= @proxy %>;
|
||||
proxy_read_timeout <%= @proxy_read_timeout %>;
|
||||
proxy_connect_timeout <%= @proxy_connect_timeout %>;
|
||||
proxy_redirect <%= @proxy_redirect %>;
|
||||
<% @proxy_set_header.each do |header| -%>
|
||||
proxy_set_header <%= header %>;
|
||||
<% end -%>
|
||||
<% if @proxy_method -%>
|
||||
proxy_method <%= @proxy_method %>;
|
||||
<% end -%>
|
||||
<% if @proxy_set_body -%>
|
||||
proxy_set_body <%= @proxy_set_body %>;
|
||||
<% end -%>
|
||||
<% @rewrite_rules.each do |rewrite_rule| -%>
|
||||
rewrite <%= rewrite_rule %>;
|
||||
<% end -%>
|
||||
<% if defined? @auth_basic -%>
|
||||
auth_basic "<%= @auth_basic %>";
|
||||
<% end -%>
|
||||
<% if defined? @auth_basic_user_file -%>
|
||||
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| -%>
|
||||
<% 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 -%>
|
||||
}
|
|
@ -1,53 +0,0 @@
|
|||
location <%= @location %> {
|
||||
<% if @location_allow -%><% @location_allow.each do |allow_rule| -%>
|
||||
allow <%= allow_rule %>;
|
||||
<% end -%><% end -%>
|
||||
<% 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| -%>
|
||||
<% 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| -%>
|
||||
<% 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| -%>
|
||||
<% 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 -%>
|
||||
}
|
Loading…
Reference in a new issue