From 1566daa60f1b04bb53b92bda13e72a6bd4b01ebf Mon Sep 17 00:00:00 2001 From: Omar Tamer Date: Thu, 2 Jan 2014 18:13:59 +0000 Subject: [PATCH] added rewrite to location/proxy & vhost --- manifests/resource/location.pp | 3 ++- manifests/resource/vhost.pp | 2 ++ templates/vhost/vhost_location_directory.erb | 4 +++- templates/vhost/vhost_location_proxy.erb | 3 +++ 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/manifests/resource/location.pp b/manifests/resource/location.pp index d2751a23f..58d422d37 100644 --- a/manifests/resource/location.pp +++ b/manifests/resource/location.pp @@ -121,7 +121,8 @@ $proxy_set_body = undef, $auth_basic = undef, $auth_basic_user_file = undef, - $priority = 500 + $priority = 500, + $rewrite_rules = undef, ) { File { owner => 'root', diff --git a/manifests/resource/vhost.pp b/manifests/resource/vhost.pp index c3934bc0f..4aa2f12c9 100644 --- a/manifests/resource/vhost.pp +++ b/manifests/resource/vhost.pp @@ -172,6 +172,7 @@ $error_log = undef, $passenger_cgi_param = undef, $use_default_location = true, + $rewrite_rules = undef, ) { validate_array($location_allow) @@ -282,6 +283,7 @@ index_files => [], location_custom_cfg => $location_custom_cfg, notify => Class['nginx::service'], + rewrite_rules => $rewrite_rules, } } else { $root = $www_root diff --git a/templates/vhost/vhost_location_directory.erb b/templates/vhost/vhost_location_directory.erb index 9b8a6b511..19d65b5cd 100644 --- a/templates/vhost/vhost_location_directory.erb +++ b/templates/vhost/vhost_location_directory.erb @@ -20,6 +20,9 @@ <% if @index_files.count > 0 -%> index <% Array(index_files).each do |i| %> <%= i %><% end %>; <% end -%> +<% if @rewrite_rules -%><% Array(@rewrite_rules).each do |rewrite_rule| -%> + rewrite <%= rewrite_rule %>; +<% end -%><% end -%> <% if defined? @auth_basic -%> auth_basic "<%= @auth_basic %>"; <% end -%> @@ -30,4 +33,3 @@ <%= key %> <%= value %>; <% end -%><% end -%> } - diff --git a/templates/vhost/vhost_location_proxy.erb b/templates/vhost/vhost_location_proxy.erb index 1b7eb4c67..e087e1e70 100644 --- a/templates/vhost/vhost_location_proxy.erb +++ b/templates/vhost/vhost_location_proxy.erb @@ -14,6 +14,9 @@ <% if @proxy_set_body -%> proxy_set_body <%= @proxy_set_body %>; <% end -%> +<% if @rewrite_rules -%><% Array(@rewrite_rules).each do |rewrite_rule| -%> + rewrite <%= rewrite_rule %>; +<% end -%><% end -%> <% if @location_cfg_append -%><% @location_cfg_append.sort_by {|k,v| k}.each do |key,value| -%> <%= key %> <%= value %>; <% end -%><% end -%>