iterate server_name when rewrite_www_to_non_www is used
This commit is contained in:
parent
d4d55c309b
commit
2fcc2306ad
2 changed files with 10 additions and 6 deletions
|
@ -1,4 +1,5 @@
|
||||||
<% if @rewrite_www_to_non_www -%>
|
<% if @rewrite_www_to_non_www -%>
|
||||||
|
<%- @server_name.each do |s| -%>
|
||||||
server {
|
server {
|
||||||
<%- if @listen_ip.is_a?(Array) then -%>
|
<%- if @listen_ip.is_a?(Array) then -%>
|
||||||
<%- @listen_ip.each do |ip| -%>
|
<%- @listen_ip.each do |ip| -%>
|
||||||
|
@ -17,10 +18,11 @@ server {
|
||||||
listen [<%= @ipv6_listen_ip %>]:<%= @ipv6_listen_port %> <% if @ipv6_listen_options %><%= @ipv6_listen_options %><% end %>;
|
listen [<%= @ipv6_listen_ip %>]:<%= @ipv6_listen_port %> <% if @ipv6_listen_options %><%= @ipv6_listen_options %><% end %>;
|
||||||
<%- end -%>
|
<%- end -%>
|
||||||
<%- end -%>
|
<%- end -%>
|
||||||
server_name www.<%= @server_name[0].gsub(/^www\./, '') %>;
|
server_name www.<%= s.gsub(/^www\./, '') %>;
|
||||||
return 301 http://<%= @server_name[0].gsub(/^www\./, '') %>$request_uri;
|
return 301 http://<%= s.gsub(/^www\./, '') %>$request_uri;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
<% end -%>
|
||||||
<% end -%>
|
<% end -%>
|
||||||
server {
|
server {
|
||||||
<%- if @listen_ip.is_a?(Array) then -%>
|
<%- if @listen_ip.is_a?(Array) then -%>
|
||||||
|
@ -40,7 +42,7 @@ server {
|
||||||
listen [<%= @ipv6_listen_ip %>]:<%= @ipv6_listen_port %> <% if @ipv6_listen_options %><%= @ipv6_listen_options %><% end %>;
|
listen [<%= @ipv6_listen_ip %>]:<%= @ipv6_listen_port %> <% if @ipv6_listen_options %><%= @ipv6_listen_options %><% end %>;
|
||||||
<%- end -%>
|
<%- end -%>
|
||||||
<%- end -%>
|
<%- end -%>
|
||||||
server_name <%= @rewrite_www_to_non_www ? @server_name[0].gsub(/^www\./, '') : @server_name.join(" ") %>;
|
server_name <%= @rewrite_www_to_non_www ? @server_name.join(" ").gsub(/(^| )(www\.)?(?=[a-z0-9])/, '') : @server_name.join(" ") %>;
|
||||||
<%- if instance_variables.any? { |iv| iv.to_s.include? 'auth_basic' } -%>
|
<%- if instance_variables.any? { |iv| iv.to_s.include? 'auth_basic' } -%>
|
||||||
<%- if defined? @auth_basic -%>
|
<%- if defined? @auth_basic -%>
|
||||||
auth_basic "<%= @auth_basic %>";
|
auth_basic "<%= @auth_basic %>";
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<% if @rewrite_www_to_non_www -%>
|
<% if @rewrite_www_to_non_www -%>
|
||||||
|
<%- @server_name.each do |s| -%>
|
||||||
server {
|
server {
|
||||||
<%- if @listen_ip.is_a?(Array) then -%>
|
<%- if @listen_ip.is_a?(Array) then -%>
|
||||||
<%- @listen_ip.each do |ip| -%>
|
<%- @listen_ip.each do |ip| -%>
|
||||||
|
@ -17,13 +18,14 @@ server {
|
||||||
listen [<%= @ipv6_listen_ip %>]:<%= @ssl_port %> ssl<% if @spdy == 'on' %> spdy<% end %><% if @ipv6_listen_options %> <%= @ipv6_listen_options %><% end %>;
|
listen [<%= @ipv6_listen_ip %>]:<%= @ssl_port %> ssl<% if @spdy == 'on' %> spdy<% end %><% if @ipv6_listen_options %> <%= @ipv6_listen_options %><% end %>;
|
||||||
<%- end -%>
|
<%- end -%>
|
||||||
<%- end -%>
|
<%- end -%>
|
||||||
server_name www.<%= @server_name[0].gsub(/^www\./, '') %>;
|
server_name www.<%= s.gsub(/^www\./, '') %>;
|
||||||
return 301 https://<%= @server_name[0].gsub(/^www\./, '') %>$request_uri;
|
return 301 https://<%= s.gsub(/^www\./, '') %>$request_uri;
|
||||||
|
|
||||||
<%= scope.function_template(["nginx/vhost/vhost_ssl_settings.erb"]) %>
|
<%= scope.function_template(["nginx/vhost/vhost_ssl_settings.erb"]) %>
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
<% end -%>
|
||||||
<% end -%>
|
<% end -%>
|
||||||
server {
|
server {
|
||||||
<%- if @listen_ip.is_a?(Array) then -%>
|
<%- if @listen_ip.is_a?(Array) then -%>
|
||||||
|
@ -43,7 +45,7 @@ server {
|
||||||
listen [<%= @ipv6_listen_ip %>]:<%= @ssl_port %> ssl<% if @spdy == 'on' %> spdy<% end %><% if @ipv6_listen_options %> <%= @ipv6_listen_options %><% end %>;
|
listen [<%= @ipv6_listen_ip %>]:<%= @ssl_port %> ssl<% if @spdy == 'on' %> spdy<% end %><% if @ipv6_listen_options %> <%= @ipv6_listen_options %><% end %>;
|
||||||
<%- end -%>
|
<%- end -%>
|
||||||
<%- end -%>
|
<%- end -%>
|
||||||
server_name <%= @rewrite_www_to_non_www ? @server_name[0].gsub(/^www\./, '') : @server_name.join(" ") %>;
|
server_name <%= @rewrite_www_to_non_www ? @server_name.join(" ").gsub(/(^| )(www\.)?(?=[a-z0-9])/, '') : @server_name.join(" ") %>;
|
||||||
|
|
||||||
<%= scope.function_template(["nginx/vhost/vhost_ssl_settings.erb"]) %>
|
<%= scope.function_template(["nginx/vhost/vhost_ssl_settings.erb"]) %>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue