mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-10-17 02:46:49 +08:00
feat: fix issue with error domain match (#8677)
Refs https://github.com/1Panel-dev/1Panel/issues/8671
This commit is contained in:
parent
c72bbaa5f7
commit
7210cd15f2
6 changed files with 80 additions and 49 deletions
|
@ -1855,7 +1855,7 @@ func handleOpenrestyFile(appInstall *model.AppInstall) error {
|
|||
break
|
||||
}
|
||||
}
|
||||
if err := handleSSLConfig(appInstall); err != nil {
|
||||
if err := handleSSLConfig(appInstall, hasDefaultWebsite); err != nil {
|
||||
return err
|
||||
}
|
||||
if len(websites) == 0 {
|
||||
|
@ -1884,7 +1884,7 @@ func handleDefaultServer(appInstall *model.AppInstall) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func handleSSLConfig(appInstall *model.AppInstall) error {
|
||||
func handleSSLConfig(appInstall *model.AppInstall, hasDefaultWebsite bool) error {
|
||||
sslDir := path.Join(appInstall.GetPath(), "conf", "ssl")
|
||||
fileOp := files.NewFileOp()
|
||||
if !fileOp.Stat(sslDir) {
|
||||
|
@ -1923,9 +1923,11 @@ func handleSSLConfig(appInstall *model.AppInstall) error {
|
|||
}
|
||||
defaultConfig.FilePath = defaultConfigPath
|
||||
defaultServer := defaultConfig.FindServers()[0]
|
||||
defaultServer.UpdateListen(fmt.Sprintf("%d", appInstall.HttpsPort), false, "ssl")
|
||||
defaultServer.UpdateListen(fmt.Sprintf("%d", appInstall.HttpPort), !hasDefaultWebsite)
|
||||
defaultServer.UpdateListen(fmt.Sprintf("[::]:%d", appInstall.HttpPort), !hasDefaultWebsite)
|
||||
defaultServer.UpdateListen(fmt.Sprintf("%d", appInstall.HttpsPort), !hasDefaultWebsite, "ssl")
|
||||
defaultServer.UpdateListen(fmt.Sprintf("[::]:%d", appInstall.HttpsPort), !hasDefaultWebsite, "ssl")
|
||||
defaultServer.UpdateListen(fmt.Sprintf("%d", appInstall.HttpsPort), false, "quic", "reuseport")
|
||||
defaultServer.UpdateListen(fmt.Sprintf("[::]:%d", appInstall.HttpsPort), false, "ssl")
|
||||
defaultServer.UpdateListen(fmt.Sprintf("[::]:%d", appInstall.HttpsPort), false, "quic", "reuseport")
|
||||
defaultServer.UpdateDirective("include", []string{"/usr/local/openresty/nginx/conf/ssl/root_ssl.conf"})
|
||||
defaultServer.UpdateDirective("http2", []string{"on"})
|
||||
|
|
|
@ -103,6 +103,32 @@ func getNginxParamsByKeys(scope string, keys []string, website *model.Website) (
|
|||
return res, nil
|
||||
}
|
||||
|
||||
func updateDefaultServerConfig(enable bool) error {
|
||||
nginxInstall, err := getAppInstallByKey("openresty")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defaultConfigPath := path.Join(nginxInstall.GetPath(), "conf", "default", "00.default.conf")
|
||||
content, err := os.ReadFile(defaultConfigPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defaultConfig, err := parser.NewStringParser(string(content)).Parse()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defaultConfig.FilePath = defaultConfigPath
|
||||
defaultServer := defaultConfig.FindServers()[0]
|
||||
defaultServer.UpdateListen(fmt.Sprintf("%d", nginxInstall.HttpPort), enable)
|
||||
defaultServer.UpdateListen(fmt.Sprintf("[::]:%d", nginxInstall.HttpPort), enable)
|
||||
defaultServer.UpdateListen(fmt.Sprintf("%d", nginxInstall.HttpsPort), enable, "ssl")
|
||||
defaultServer.UpdateListen(fmt.Sprintf("[::]:%d", nginxInstall.HttpsPort), enable, "ssl")
|
||||
if err = nginx.WriteConfig(defaultConfig, nginx.IndentedStyle); err != nil {
|
||||
return err
|
||||
}
|
||||
return nginxCheckAndReload(string(content), defaultConfigPath, nginxInstall.ContainerName)
|
||||
}
|
||||
|
||||
func updateNginxConfig(scope string, params []dto.NginxParam, website *model.Website) error {
|
||||
nginxFull, err := getNginxFull(website)
|
||||
if err != nil {
|
||||
|
|
|
@ -1296,44 +1296,36 @@ func (w WebsiteService) ChangeDefaultServer(id uint) error {
|
|||
return err
|
||||
}
|
||||
}
|
||||
if id > 0 {
|
||||
website, err := websiteRepo.GetFirst(repo.WithByID(id))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
params, err := getNginxParamsByKeys(constant.NginxScopeServer, []string{"listen"}, &website)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
httpPort, httpsPort, err := getAppInstallPort(constant.AppOpenresty)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var changeParams []dto.NginxParam
|
||||
for _, param := range params {
|
||||
paramLen := len(param.Params)
|
||||
bind := param.Params[0]
|
||||
var newParam []string
|
||||
if bind == strconv.Itoa(httpPort) || bind == strconv.Itoa(httpsPort) || bind == "[::]:"+strconv.Itoa(httpPort) || bind == "[::]:"+strconv.Itoa(httpsPort) {
|
||||
if param.Params[paramLen-1] == components.DefaultServer {
|
||||
newParam = param.Params
|
||||
} else {
|
||||
newParam = append(param.Params, components.DefaultServer)
|
||||
}
|
||||
}
|
||||
changeParams = append(changeParams, dto.NginxParam{
|
||||
Name: param.Name,
|
||||
Params: newParam,
|
||||
})
|
||||
}
|
||||
if err := updateNginxConfig(constant.NginxScopeServer, changeParams, &website); err != nil {
|
||||
return err
|
||||
}
|
||||
website.DefaultServer = true
|
||||
return websiteRepo.Save(context.Background(), &website)
|
||||
if err := updateDefaultServerConfig(!(id > 0)); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
if id == 0 {
|
||||
return nil
|
||||
}
|
||||
website, err := websiteRepo.GetFirst(repo.WithByID(id))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
params, err := getNginxParamsByKeys(constant.NginxScopeServer, []string{"listen"}, &website)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
var changeParams []dto.NginxParam
|
||||
for _, param := range params {
|
||||
if hasHttp3(param.Params) || hasDefaultServer(param.Params) {
|
||||
continue
|
||||
}
|
||||
newParam := append(param.Params, components.DefaultServer)
|
||||
changeParams = append(changeParams, dto.NginxParam{
|
||||
Name: param.Name,
|
||||
Params: newParam,
|
||||
})
|
||||
}
|
||||
if err := updateNginxConfig(constant.NginxScopeServer, changeParams, &website); err != nil {
|
||||
return err
|
||||
}
|
||||
website.DefaultServer = true
|
||||
return websiteRepo.Save(context.Background(), &website)
|
||||
}
|
||||
|
||||
func (w WebsiteService) ChangePHPVersion(req request.WebsitePHPVersionReq) error {
|
||||
|
|
|
@ -1395,3 +1395,21 @@ func getSystemProxy(useProxy bool) *dto.SystemProxy {
|
|||
systemProxy, _ := settingService.GetSystemProxy()
|
||||
return systemProxy
|
||||
}
|
||||
|
||||
func hasHttp3(params []string) bool {
|
||||
for _, param := range params {
|
||||
if param == "quic" {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func hasDefaultServer(params []string) bool {
|
||||
for _, param := range params {
|
||||
if param == "default_server" {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
|
|
@ -99,13 +99,6 @@ defineExpose({
|
|||
});
|
||||
|
||||
onMounted(() => {
|
||||
if (props.paginationConfig?.cacheSizeKey) {
|
||||
let itemSize = Number(localStorage.getItem(props.paginationConfig.cacheSizeKey));
|
||||
if (itemSize) {
|
||||
props.paginationConfig.pageSize = itemSize;
|
||||
sizeChange();
|
||||
}
|
||||
}
|
||||
let heightDiff = 320;
|
||||
if (props.heightDiff) {
|
||||
heightDiff = props.heightDiff;
|
||||
|
|
|
@ -160,7 +160,7 @@
|
|||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
width="120px"
|
||||
width="180px"
|
||||
:label="$t('commons.table.type')"
|
||||
fix
|
||||
show-overflow-tooltip
|
||||
|
|
Loading…
Add table
Reference in a new issue