Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use 'return' over 'rewrite' #349

Merged
merged 1 commit into from
Jun 23, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions spec/defines/resource_vhost_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -232,19 +232,19 @@
:attr => 'rewrite_www_to_non_www',
:value => true,
:match => [
' listen *:80;',
' server_name www.rspec.example.com;',
' rewrite ^ http://rspec.example.com$uri permanent;',
' listen *:80;',
' server_name www.rspec.example.com;',
' return 301 http://rspec.example.com$uri;',
],
},
{
:title => 'should not contain www to non-www rewrite',
:attr => 'rewrite_www_to_non_www',
:value => false,
:notmatch => [
/ listen \*:80;/,
/ server_name www\.rspec\.example\.com;/,
/ rewrite \^ http:\/\/rspec\.example\.com\$uri permanent;/,
%r| listen \*:80;|,
%r| server_name www\.rspec\.example\.com;|,
%r| return 301 http://rspec\.example\.com\$uri;|
],
},
].each do |param|
Expand Down Expand Up @@ -476,19 +476,19 @@
:attr => 'rewrite_www_to_non_www',
:value => true,
:match => [
' listen *:443 ssl;',
' server_name www.rspec.example.com;',
' rewrite ^ https://rspec.example.com$uri permanent;',
' listen *:443 ssl;',
' server_name www.rspec.example.com;',
' return 301 https://rspec.example.com$uri;',
],
},
{
:title => 'should not contain www to non-www rewrite',
:attr => 'rewrite_www_to_non_www',
:value => false,
:notmatch => [
/ listen \*:443 ssl;/,
/ server_name www\.rspec\.example\.com;/,
/ rewrite \^ https:\/\/rspec\.example\.com\$uri permanent;/,
%r| listen \*:443 ssl;|,
%r| server_name www\.rspec\.example\.com;|,
%r| return 301 https://rspec\.example\.com\$uri;|
],
},
].each do |param|
Expand Down
6 changes: 3 additions & 3 deletions templates/vhost/vhost_footer.erb
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ include <%= file %>;
}
<% if @rewrite_www_to_non_www -%>
server {
listen <%= @listen_ip %>:<%= @listen_port %>;
server_name www.<%= @name.gsub(/^www\./, '') %>;
rewrite ^ http://<%= @name.gsub(/^www\./, '') %>$uri permanent;
listen <%= @listen_ip %>:<%= @listen_port %>;
server_name www.<%= @name.gsub(/^www\./, '') %>;
return 301 http://<%= @name.gsub(/^www\./, '') %>$uri;
}
<% end -%>
6 changes: 3 additions & 3 deletions templates/vhost/vhost_ssl_footer.erb
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ include <%= file %>;
}
<% if @rewrite_www_to_non_www -%>
server {
listen <%= @listen_ip %>:<%= @ssl_port %> ssl;
server_name www.<%= @name.gsub(/^www\./, '') %>;
rewrite ^ https://<%= @name.gsub(/^www\./, '') %>$uri permanent;
listen <%= @listen_ip %>:<%= @ssl_port %> ssl;
server_name www.<%= @name.gsub(/^www\./, '') %>;
return 301 https://<%= @name.gsub(/^www\./, '') %>$uri;
}
<% end %>