Merge pull request #526 from asgoodasnu/rewrites_in_fastcgi

moves rewrite_rules to location_header
This commit is contained in:
James Fryman 2014-12-11 09:52:24 -08:00
commit 10d5f196d7
4 changed files with 26 additions and 52 deletions

View file

@ -134,6 +134,26 @@ describe 'nginx::resource::location' do
],
:match => /^\s+if \(a\) {\n\s++b;\n\s+\}/,
},
{
:title => 'should contain rewrite rules',
:attr => 'rewrite_rules',
:value => [
'^(/download/.*)/media/(.*)\..*$ $1/mp3/$2.mp3 last',
'^(/download/.*)/media/(.*)\..*$ $1/mp3/$2.ra last',
'^/users/(.*)$ /show?user=$1? last',
],
:match => [
/rewrite \^\(\/download\/\.\*\)\/media\/\(\.\*\)\\\.\.\*\$ \$1\/mp3\/\$2\.mp3 last/,
/rewrite \^\(\/download\/\.\*\)\/media\/\(\.\*\)\\\.\.\*\$ \$1\/mp3\/\$2\.ra last/,
/rewrite \^\/users\/\(\.\*\)\$ \/show\?user=\$1\? last/,
],
},
{
:title => 'should not set rewrite_rules',
:attr => 'rewrite_rules',
:value => [],
:notmatch => /rewrite/
},
].each do |param|
context "when #{param[:attr]} is #{param[:value]}" do
let :default_params do { :location => 'location', :proxy => 'proxy_value', :vhost => 'vhost1' } end
@ -304,26 +324,6 @@ describe 'nginx::resource::location' do
:value => ['name1','name2'],
:match => ' index name1 name2;',
},
{
:title => 'should contain rewrite rules',
:attr => 'rewrite_rules',
:value => [
'^(/download/.*)/media/(.*)\..*$ $1/mp3/$2.mp3 last',
'^(/download/.*)/audio/(.*)\..*$ $1/mp3/$2.ra last',
'^/users/(.*)$ /show?user=$1? last',
],
:match => [
' rewrite ^(/download/.*)/media/(.*)\..*$ $1/mp3/$2.mp3 last;',
' rewrite ^(/download/.*)/audio/(.*)\..*$ $1/mp3/$2.ra last;',
' rewrite ^/users/(.*)$ /show?user=$1? last;',
],
},
{
:title => 'should not set rewrite_rules',
:attr => 'rewrite_rules',
:value => [],
:notmatch => /rewrite/
},
{
:title => 'should set auth_basic',
:attr => 'auth_basic',
@ -596,26 +596,6 @@ describe 'nginx::resource::location' do
:value => 'value',
:match => %r'\s+proxy_set_body\s+value;',
},
{
:title => 'should contain rewrite rules',
:attr => 'rewrite_rules',
:value => [
'^(/download/.*)/media/(.*)\..*$ $1/mp3/$2.mp3 last',
'^(/download/.*)/audio/(.*)\..*$ $1/mp3/$2.ra last',
'^/users/(.*)$ /show?user=$1? last',
],
:match => [
' rewrite ^(/download/.*)/media/(.*)\..*$ $1/mp3/$2.mp3 last;',
' rewrite ^(/download/.*)/audio/(.*)\..*$ $1/mp3/$2.ra last;',
' rewrite ^/users/(.*)$ /show?user=$1? last;',
],
},
{
:title => 'should not set rewrite_rules',
:attr => 'rewrite_rules',
:value => [],
:notmatch => /rewrite/
},
].each do |param|
context "when #{param[:attr]} is #{param[:value]}" do
let :default_params do { :location => 'location', :proxy => 'proxy_value', :vhost => 'vhost1' } end

View file

@ -54,3 +54,9 @@
<%= line %>
<%- end -%>
<% end -%>
<%- unless @rewrite_rules.nil? || @rewrite_rules.empty? -%>
<%- @rewrite_rules.each do |rewrite_rule| -%>
rewrite <%= rewrite_rule %>;
<%- end -%>
<% end -%>

View file

@ -11,12 +11,6 @@
<% if @try_files -%>
try_files<% @try_files.each do |try| -%> <%= try %><% end -%>;
<% end -%>
<%- unless @rewrite_rules.nil? || @rewrite_rules.empty? -%>
<%- @rewrite_rules.each do |rewrite_rule| -%>
rewrite <%= rewrite_rule %>;
<%- end -%>
<% end -%>
<% if instance_variables.any? { |iv| iv.to_s.include? 'auth_basic' } -%>
<%- if @auth_basic -%>

View file

@ -21,12 +21,6 @@
<% if @proxy_cache_valid -%>
proxy_cache_valid <%= @proxy_cache_valid %>;
<% end -%>
<%- unless @rewrite_rules.nil? || @rewrite_rules.empty? -%>
<%- @rewrite_rules.each do |rewrite_rule| -%>
rewrite <%= rewrite_rule %>;
<%- end -%>
<% end -%>
<% if instance_variables.any? { |iv| iv.to_s.include? 'auth_basic' } -%>
<%- if @auth_basic -%>