Merge pull request #526 from asgoodasnu/rewrites_in_fastcgi
moves rewrite_rules to location_header
This commit is contained in:
commit
10d5f196d7
4 changed files with 26 additions and 52 deletions
|
@ -134,6 +134,26 @@ describe 'nginx::resource::location' do
|
||||||
],
|
],
|
||||||
:match => /^\s+if \(a\) {\n\s++b;\n\s+\}/,
|
: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|
|
].each do |param|
|
||||||
context "when #{param[:attr]} is #{param[:value]}" do
|
context "when #{param[:attr]} is #{param[:value]}" do
|
||||||
let :default_params do { :location => 'location', :proxy => 'proxy_value', :vhost => 'vhost1' } end
|
let :default_params do { :location => 'location', :proxy => 'proxy_value', :vhost => 'vhost1' } end
|
||||||
|
@ -304,26 +324,6 @@ describe 'nginx::resource::location' do
|
||||||
:value => ['name1','name2'],
|
:value => ['name1','name2'],
|
||||||
:match => ' index 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',
|
:title => 'should set auth_basic',
|
||||||
:attr => 'auth_basic',
|
:attr => 'auth_basic',
|
||||||
|
@ -596,26 +596,6 @@ describe 'nginx::resource::location' do
|
||||||
:value => 'value',
|
:value => 'value',
|
||||||
:match => %r'\s+proxy_set_body\s+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|
|
].each do |param|
|
||||||
context "when #{param[:attr]} is #{param[:value]}" do
|
context "when #{param[:attr]} is #{param[:value]}" do
|
||||||
let :default_params do { :location => 'location', :proxy => 'proxy_value', :vhost => 'vhost1' } end
|
let :default_params do { :location => 'location', :proxy => 'proxy_value', :vhost => 'vhost1' } end
|
||||||
|
|
|
@ -54,3 +54,9 @@
|
||||||
<%= line %>
|
<%= line %>
|
||||||
<%- end -%>
|
<%- end -%>
|
||||||
<% end -%>
|
<% end -%>
|
||||||
|
<%- unless @rewrite_rules.nil? || @rewrite_rules.empty? -%>
|
||||||
|
|
||||||
|
<%- @rewrite_rules.each do |rewrite_rule| -%>
|
||||||
|
rewrite <%= rewrite_rule %>;
|
||||||
|
<%- end -%>
|
||||||
|
<% end -%>
|
||||||
|
|
|
@ -11,12 +11,6 @@
|
||||||
<% if @try_files -%>
|
<% if @try_files -%>
|
||||||
try_files<% @try_files.each do |try| -%> <%= try %><% end -%>;
|
try_files<% @try_files.each do |try| -%> <%= try %><% end -%>;
|
||||||
<% 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 instance_variables.any? { |iv| iv.to_s.include? 'auth_basic' } -%>
|
||||||
|
|
||||||
<%- if @auth_basic -%>
|
<%- if @auth_basic -%>
|
||||||
|
|
|
@ -21,12 +21,6 @@
|
||||||
<% if @proxy_cache_valid -%>
|
<% if @proxy_cache_valid -%>
|
||||||
proxy_cache_valid <%= @proxy_cache_valid %>;
|
proxy_cache_valid <%= @proxy_cache_valid %>;
|
||||||
<% 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 instance_variables.any? { |iv| iv.to_s.include? 'auth_basic' } -%>
|
||||||
|
|
||||||
<%- if @auth_basic -%>
|
<%- if @auth_basic -%>
|
||||||
|
|
Loading…
Reference in a new issue