Skip to content

Commit

Permalink
Merge pull request voxpupuli#526 from asgoodasnu/rewrites_in_fastcgi
Browse files Browse the repository at this point in the history
moves rewrite_rules to location_header
  • Loading branch information
jfryman committed Dec 11, 2014
2 parents a455638 + d550c9b commit a8ab09e
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 52 deletions.
60 changes: 20 additions & 40 deletions spec/defines/resource_location_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,26 @@
],
: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
Expand Down Expand Up @@ -304,26 +324,6 @@
: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',
Expand Down Expand Up @@ -596,26 +596,6 @@
: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
Expand Down
6 changes: 6 additions & 0 deletions templates/vhost/location_header.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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 -%>
6 changes: 0 additions & 6 deletions templates/vhost/locations/directory.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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 -%>
Expand Down
6 changes: 0 additions & 6 deletions templates/vhost/locations/proxy.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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 -%>
Expand Down

0 comments on commit a8ab09e

Please sign in to comment.