diff --git a/internal/web/actions/default/clusters/cluster/settings/global-server-config/index.go b/internal/web/actions/default/clusters/cluster/settings/global-server-config/index.go index a77e2fd3..65fbe53f 100644 --- a/internal/web/actions/default/clusters/cluster/settings/global-server-config/index.go +++ b/internal/web/actions/default/clusters/cluster/settings/global-server-config/index.go @@ -43,13 +43,19 @@ func (this *IndexAction) RunGet(params struct { } this.Data["config"] = config + var httpAllDomainMismatchActionCode = serverconfigs.DomainMismatchActionPage var httpAllDomainMismatchActionContentHTML string var httpAllDomainMismatchActionStatusCode = "404" - if config.HTTPAll.DomainMismatchAction != nil && config.HTTPAll.DomainMismatchAction.Options != nil { - httpAllDomainMismatchActionContentHTML = config.HTTPAll.DomainMismatchAction.Options.GetString("contentHTML") - var statusCode = config.HTTPAll.DomainMismatchAction.Options.GetInt("statusCode") - if statusCode > 0 { - httpAllDomainMismatchActionStatusCode = types.String(statusCode) + if config.HTTPAll.DomainMismatchAction != nil { + httpAllDomainMismatchActionCode = config.HTTPAll.DomainMismatchAction.Code + + if config.HTTPAll.DomainMismatchAction.Options != nil { + // 即使是非 page 处理动作,也读取这些内容,以便于在切换到 page 时,可以顺利读取到先前的设置 + httpAllDomainMismatchActionContentHTML = config.HTTPAll.DomainMismatchAction.Options.GetString("contentHTML") + var statusCode = config.HTTPAll.DomainMismatchAction.Options.GetInt("statusCode") + if statusCode > 0 { + httpAllDomainMismatchActionStatusCode = types.String(statusCode) + } } } else { httpAllDomainMismatchActionContentHTML = ` @@ -73,6 +79,7 @@ p { color: grey; } ` } + this.Data["httpAllDomainMismatchActionCode"] = httpAllDomainMismatchActionCode this.Data["httpAllDomainMismatchActionContentHTML"] = httpAllDomainMismatchActionContentHTML this.Data["httpAllDomainMismatchActionStatusCode"] = httpAllDomainMismatchActionStatusCode @@ -83,6 +90,7 @@ func (this *IndexAction) RunPost(params struct { ClusterId int64 HttpAllMatchDomainStrictly bool + HttpAllDomainMismatchActionCode string HttpAllDomainMismatchActionContentHTML string HttpAllDomainMismatchActionStatusCode string HttpAllAllowMismatchDomainsJSON []byte @@ -140,7 +148,7 @@ func (this *IndexAction) RunPost(params struct { config.HTTPAll.MatchDomainStrictly = params.HttpAllMatchDomainStrictly config.HTTPAll.DomainMismatchAction = &serverconfigs.DomainMismatchAction{ - Code: serverconfigs.DomainMismatchActionPage, + Code: params.HttpAllDomainMismatchActionCode, Options: maps.Map{ "statusCode": domainMisMatchStatusCode, "contentHTML": params.HttpAllDomainMismatchActionContentHTML, diff --git a/web/views/@default/clusters/cluster/settings/global-server-config/index.html b/web/views/@default/clusters/cluster/settings/global-server-config/index.html index 95f2dfdc..82516965 100644 --- a/web/views/@default/clusters/cluster/settings/global-server-config/index.html +++ b/web/views/@default/clusters/cluster/settings/global-server-config/index.html @@ -14,23 +14,35 @@ 禁止未绑定域名访问 -

选中后,表示禁止未绑定的域名和IP访问。

+

选中后,表示禁止未在网站绑定的域名和IP访问。

- + + + 处理未绑定域名方式 + + 显示提示页面   +   关闭连接 +

显示提示内容。

+

直接关闭网络连接,不提示任何内容。

+ + + + 提示页面状态码

访问未绑定域名时的提示页面状态码,默认404。

- - 未绑定域名页面提示 + + 提示页面内容 -

访问未绑定的域名时提示的文字,可以使用HTML;仅限于HTTP请求,不适于用HTTPS(HTTPS会提示证书错误)。

+

访问未绑定的域名时提示页面内容,可以使用HTML;仅限于HTTP请求,不适于用HTTPS(HTTPS会提示证书错误)。

+ 允许例外的域名