mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-10-22 05:16:54 +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
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if err := handleSSLConfig(appInstall); err != nil {
|
if err := handleSSLConfig(appInstall, hasDefaultWebsite); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if len(websites) == 0 {
|
if len(websites) == 0 {
|
||||||
|
@ -1884,7 +1884,7 @@ func handleDefaultServer(appInstall *model.AppInstall) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleSSLConfig(appInstall *model.AppInstall) error {
|
func handleSSLConfig(appInstall *model.AppInstall, hasDefaultWebsite bool) error {
|
||||||
sslDir := path.Join(appInstall.GetPath(), "conf", "ssl")
|
sslDir := path.Join(appInstall.GetPath(), "conf", "ssl")
|
||||||
fileOp := files.NewFileOp()
|
fileOp := files.NewFileOp()
|
||||||
if !fileOp.Stat(sslDir) {
|
if !fileOp.Stat(sslDir) {
|
||||||
|
@ -1923,9 +1923,11 @@ func handleSSLConfig(appInstall *model.AppInstall) error {
|
||||||
}
|
}
|
||||||
defaultConfig.FilePath = defaultConfigPath
|
defaultConfig.FilePath = defaultConfigPath
|
||||||
defaultServer := defaultConfig.FindServers()[0]
|
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, "quic", "reuseport")
|
||||||
defaultServer.UpdateListen(fmt.Sprintf("[::]:%d", appInstall.HttpsPort), false, "ssl")
|
|
||||||
defaultServer.UpdateListen(fmt.Sprintf("[::]:%d", appInstall.HttpsPort), false, "quic", "reuseport")
|
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("include", []string{"/usr/local/openresty/nginx/conf/ssl/root_ssl.conf"})
|
||||||
defaultServer.UpdateDirective("http2", []string{"on"})
|
defaultServer.UpdateDirective("http2", []string{"on"})
|
||||||
|
|
|
@ -103,6 +103,32 @@ func getNginxParamsByKeys(scope string, keys []string, website *model.Website) (
|
||||||
return res, nil
|
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 {
|
func updateNginxConfig(scope string, params []dto.NginxParam, website *model.Website) error {
|
||||||
nginxFull, err := getNginxFull(website)
|
nginxFull, err := getNginxFull(website)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -1296,7 +1296,12 @@ func (w WebsiteService) ChangeDefaultServer(id uint) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if id > 0 {
|
if err := updateDefaultServerConfig(!(id > 0)); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if id == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
website, err := websiteRepo.GetFirst(repo.WithByID(id))
|
website, err := websiteRepo.GetFirst(repo.WithByID(id))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -1305,23 +1310,12 @@ func (w WebsiteService) ChangeDefaultServer(id uint) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
httpPort, httpsPort, err := getAppInstallPort(constant.AppOpenresty)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
var changeParams []dto.NginxParam
|
var changeParams []dto.NginxParam
|
||||||
for _, param := range params {
|
for _, param := range params {
|
||||||
paramLen := len(param.Params)
|
if hasHttp3(param.Params) || hasDefaultServer(param.Params) {
|
||||||
bind := param.Params[0]
|
continue
|
||||||
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)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
newParam := append(param.Params, components.DefaultServer)
|
||||||
changeParams = append(changeParams, dto.NginxParam{
|
changeParams = append(changeParams, dto.NginxParam{
|
||||||
Name: param.Name,
|
Name: param.Name,
|
||||||
Params: newParam,
|
Params: newParam,
|
||||||
|
@ -1332,8 +1326,6 @@ func (w WebsiteService) ChangeDefaultServer(id uint) error {
|
||||||
}
|
}
|
||||||
website.DefaultServer = true
|
website.DefaultServer = true
|
||||||
return websiteRepo.Save(context.Background(), &website)
|
return websiteRepo.Save(context.Background(), &website)
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w WebsiteService) ChangePHPVersion(req request.WebsitePHPVersionReq) error {
|
func (w WebsiteService) ChangePHPVersion(req request.WebsitePHPVersionReq) error {
|
||||||
|
|
|
@ -1395,3 +1395,21 @@ func getSystemProxy(useProxy bool) *dto.SystemProxy {
|
||||||
systemProxy, _ := settingService.GetSystemProxy()
|
systemProxy, _ := settingService.GetSystemProxy()
|
||||||
return systemProxy
|
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(() => {
|
onMounted(() => {
|
||||||
if (props.paginationConfig?.cacheSizeKey) {
|
|
||||||
let itemSize = Number(localStorage.getItem(props.paginationConfig.cacheSizeKey));
|
|
||||||
if (itemSize) {
|
|
||||||
props.paginationConfig.pageSize = itemSize;
|
|
||||||
sizeChange();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let heightDiff = 320;
|
let heightDiff = 320;
|
||||||
if (props.heightDiff) {
|
if (props.heightDiff) {
|
||||||
heightDiff = props.heightDiff;
|
heightDiff = props.heightDiff;
|
||||||
|
|
|
@ -160,7 +160,7 @@
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column
|
<el-table-column
|
||||||
width="120px"
|
width="180px"
|
||||||
:label="$t('commons.table.type')"
|
:label="$t('commons.table.type')"
|
||||||
fix
|
fix
|
||||||
show-overflow-tooltip
|
show-overflow-tooltip
|
||||||
|
|
Loading…
Add table
Reference in a new issue