fix: 解决默认网站开启 https 443 端口没有设置 default_server 的问题 (#1034)

This commit is contained in:
zhengkunwang223 2023-05-14 09:04:31 +08:00 committed by GitHub
parent 2ae1db4730
commit 25c2246782
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -371,8 +371,8 @@ func applySSL(website model.Website, websiteSSL model.WebsiteSSL, req request.We
}
config := nginxFull.SiteConfig.Config
server := config.FindServers()[0]
server.UpdateListen("443", false, "ssl")
server.UpdateListen("[::]:443", false, "ssl")
server.UpdateListen("443", website.DefaultServer, "ssl")
server.UpdateListen("[::]:443", website.DefaultServer, "ssl")
switch req.HttpConfig {
case constant.HTTPSOnly:
@ -381,11 +381,11 @@ func applySSL(website model.Website, websiteSSL model.WebsiteSSL, req request.We
server.RemoveDirective("if", []string{"($scheme"})
case constant.HTTPToHTTPS:
server.UpdateListen("80", website.DefaultServer)
server.UpdateListen("[::]:80", false)
server.UpdateListen("[::]:80", website.DefaultServer)
server.AddHTTP2HTTPS()
case constant.HTTPAlso:
server.UpdateListen("80", website.DefaultServer)
server.UpdateListen("[::]:80", false)
server.UpdateListen("[::]:80", website.DefaultServer)
server.RemoveDirective("if", []string{"($scheme"})
}