Use first server name for non-www redirects to prevent issues with naming of vhosts within defined types.

Signed-off-by: Kalman Olah <kalman@inuits.eu>
This commit is contained in:
Kalman Olah 2014-05-13 10:04:46 +02:00
parent 400e58a505
commit 12d515f7f7
4 changed files with 6 additions and 6 deletions

View file

@ -19,7 +19,7 @@ include <%= file %>;
<% if @rewrite_www_to_non_www -%>
server {
listen <%= @listen_ip %>:<%= @listen_port %>;
server_name www.<%= @name.gsub(/^www\./, '') %>;
return 301 http://<%= @name.gsub(/^www\./, '') %>$uri;
server_name www.<%= @server_name[0].gsub(/^www\./, '') %>;
return 301 http://<%= @server_name[0].gsub(/^www\./, '') %>$uri;
}
<% end -%>

View file

@ -4,7 +4,7 @@ server {
<% if @ipv6_enable && (defined? @ipaddress6) %>
listen [<%= @ipv6_listen_ip %>]:<%= @ipv6_listen_port %> <% if @ipv6_listen_options %><%= @ipv6_listen_options %><% end %>;
<% end %>
server_name <%= @rewrite_www_to_non_www ? @name.gsub(/^www\./, '') : @server_name.join(" ") %>;
server_name <%= @rewrite_www_to_non_www ? @server_name[0].gsub(/^www\./, '') : @server_name.join(" ") %>;
<% if defined? @auth_basic -%>
auth_basic "<%= @auth_basic %>";
<% end -%>

View file

@ -27,7 +27,7 @@ include <%= file %>;
<% if @rewrite_www_to_non_www -%>
server {
listen <%= @listen_ip %>:<%= @ssl_port %> ssl;
server_name www.<%= @name.gsub(/^www\./, '') %>;
return 301 https://<%= @name.gsub(/^www\./, '') %>$uri;
server_name www.<%= @server_name[0].gsub(/^www\./, '') %>;
return 301 https://<%= @server_name[0].gsub(/^www\./, '') %>$uri;
}
<% end %>

View file

@ -3,7 +3,7 @@ server {
<% if @ipv6_enable && (defined? @ipaddress6) %>
listen [<%= @ipv6_listen_ip %>]:<%= @ssl_port %> ssl<% if @spdy == 'on' %> spdy<% end %><% if @ipv6_listen_options %> <%= @ipv6_listen_options %><% end %>;
<% end %>
server_name <%= @rewrite_www_to_non_www ? @name.gsub(/^www\./, '') : @server_name.join(" ") %>;
server_name <%= @rewrite_www_to_non_www ? @server_name[0].gsub(/^www\./, '') : @server_name.join(" ") %>;
ssl on;