Fix bug.
This commit is contained in:
parent
dfa1935bd4
commit
731138f556
|
@ -106,7 +106,8 @@ class SiteConstruct
|
|||
else
|
||||
port = port.to_s
|
||||
end
|
||||
redirect_default_text = get_redirect_default_text(port)
|
||||
default_domain = get_default_domain
|
||||
redirect_default_text = get_redirect_default_text(port, default_domain)
|
||||
port_text = port
|
||||
if port.to_i == 443
|
||||
if self.site_cert.nil?
|
||||
|
@ -114,10 +115,13 @@ class SiteConstruct
|
|||
end
|
||||
port_text += " ssl"
|
||||
end
|
||||
domain_name_str = self.domain_name
|
||||
if default_domain.present?
|
||||
domain_name_str = ([default_domain] + (domain_name_str.split(/\s+/) - [default_domain])).join(" ")
|
||||
end
|
||||
if old_server_block.present?
|
||||
new_server_block = old_server_block.gsub(/(listen\s+)[^;]+/){|ff| "#{$1}#{port_text}"}
|
||||
domain_name = self.domain_name
|
||||
new_server_block = new_server_block.gsub(/(server_name\s+)[^;]+/m){|ff| "#{$1}#{domain_name}"}
|
||||
new_server_block = new_server_block.gsub(/(server_name\s+)[^;]+/m){|ff| "#{$1}#{domain_name_str}"}
|
||||
new_server_block = new_server_block.gsub(/\s*ssl_certificate[^;]+;/,'')
|
||||
level_2_block = parse_nginx_text_to_server_blocks(old_server_block,true,2)
|
||||
get_redirect_block = level_2_block.select{|t| t.match(/\s*return\s+30[12]\s+https:\/\/\$host\$request_uri\s*;/)}
|
||||
|
@ -167,7 +171,7 @@ class SiteConstruct
|
|||
"}\n" : '') : '')+
|
||||
redirect_default_text +
|
||||
' root '+self.full_site_path+'/public;\n\n'+
|
||||
' server_name '+self.domain_name+';\n\n'+
|
||||
' server_name '+domain_name_str+';\n\n'+
|
||||
' client_max_body_size 500m;\n\n'+
|
||||
' location / {\n'+
|
||||
' try_files \$uri \$uri/index.html \$uri.html @app;\n'+
|
||||
|
@ -186,9 +190,6 @@ class SiteConstruct
|
|||
def display_port
|
||||
self.port.map{|port| "<a href=\"#{get_domain_name(port)}\" title=\"#{port}\" target=\"_blank\">#{port}</a>"}.join("<br>").html_safe
|
||||
end
|
||||
def get_host_with_port(port)
|
||||
self.domain_name.split().first
|
||||
end
|
||||
def get_port(idx=0)
|
||||
self.port[idx] rescue "80"
|
||||
end
|
||||
|
@ -246,14 +247,14 @@ class SiteConstruct
|
|||
def default_enable_redirect_default_domain
|
||||
site_server.enable_redirect_default_domain rescue false
|
||||
end
|
||||
def get_redirect_default_text(port=80)
|
||||
def get_redirect_default_text(port=80,default_domain=nil)
|
||||
port = port.to_i
|
||||
is_enable = get_enable_redirect_default_domain
|
||||
scheme = (port == 443 ? "https" : "http")
|
||||
port_text = ((port == 80 || port == 443 || port.blank?) ? "" : ":#{port}")
|
||||
text = ""
|
||||
if is_enable
|
||||
default_domain = get_default_domain
|
||||
default_domain = get_default_domain if default_domain.nil?
|
||||
if default_domain.present?
|
||||
text = "\n\n if ($host !~* (^#{default_domain.gsub('.','\.')}$) ) {\n"+
|
||||
" return 302 #{scheme}://#{default_domain}#{port_text}$request_uri;\n"+
|
||||
|
|
Loading…
Reference in New Issue