From 8019e641ddf7ad753eaa0af1e063adaedc5294ac Mon Sep 17 00:00:00 2001 From: GoEdgeLab Date: Thu, 7 Sep 2023 15:15:35 +0800 Subject: [PATCH] =?UTF-8?q?=E9=9B=86=E7=BE=A4=E8=AE=BE=E7=BD=AE=20--=20?= =?UTF-8?q?=E7=BD=91=E7=AB=99=E8=AE=BE=E7=BD=AE--=20=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E2=80=9C=E5=A4=84=E7=90=86=E6=9C=AA=E7=BB=91=E5=AE=9A=E5=9F=9F?= =?UTF-8?q?=E5=90=8D=E6=96=B9=E5=BC=8F=E2=80=9D=E9=80=89=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../settings/global-server-config/index.go | 20 ++++++++++++----- .../settings/global-server-config/index.html | 22 ++++++++++++++----- 2 files changed, 31 insertions(+), 11 deletions(-) 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会提示证书错误)。

+ 允许例外的域名