集群设置 -- 网站设置-- 增加“处理未绑定域名方式”选项

This commit is contained in:
GoEdgeLab
2023-09-07 15:15:35 +08:00
parent a46a0296d3
commit 8019e641dd
2 changed files with 31 additions and 11 deletions

View File

@@ -43,13 +43,19 @@ func (this *IndexAction) RunGet(params struct {
} }
this.Data["config"] = config this.Data["config"] = config
var httpAllDomainMismatchActionCode = serverconfigs.DomainMismatchActionPage
var httpAllDomainMismatchActionContentHTML string var httpAllDomainMismatchActionContentHTML string
var httpAllDomainMismatchActionStatusCode = "404" var httpAllDomainMismatchActionStatusCode = "404"
if config.HTTPAll.DomainMismatchAction != nil && config.HTTPAll.DomainMismatchAction.Options != nil { if config.HTTPAll.DomainMismatchAction != nil {
httpAllDomainMismatchActionContentHTML = config.HTTPAll.DomainMismatchAction.Options.GetString("contentHTML") httpAllDomainMismatchActionCode = config.HTTPAll.DomainMismatchAction.Code
var statusCode = config.HTTPAll.DomainMismatchAction.Options.GetInt("statusCode")
if statusCode > 0 { if config.HTTPAll.DomainMismatchAction.Options != nil {
httpAllDomainMismatchActionStatusCode = types.String(statusCode) // 即使是非 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 { } else {
httpAllDomainMismatchActionContentHTML = `<!DOCTYPE html> httpAllDomainMismatchActionContentHTML = `<!DOCTYPE html>
@@ -73,6 +79,7 @@ p { color: grey; }
</html>` </html>`
} }
this.Data["httpAllDomainMismatchActionCode"] = httpAllDomainMismatchActionCode
this.Data["httpAllDomainMismatchActionContentHTML"] = httpAllDomainMismatchActionContentHTML this.Data["httpAllDomainMismatchActionContentHTML"] = httpAllDomainMismatchActionContentHTML
this.Data["httpAllDomainMismatchActionStatusCode"] = httpAllDomainMismatchActionStatusCode this.Data["httpAllDomainMismatchActionStatusCode"] = httpAllDomainMismatchActionStatusCode
@@ -83,6 +90,7 @@ func (this *IndexAction) RunPost(params struct {
ClusterId int64 ClusterId int64
HttpAllMatchDomainStrictly bool HttpAllMatchDomainStrictly bool
HttpAllDomainMismatchActionCode string
HttpAllDomainMismatchActionContentHTML string HttpAllDomainMismatchActionContentHTML string
HttpAllDomainMismatchActionStatusCode string HttpAllDomainMismatchActionStatusCode string
HttpAllAllowMismatchDomainsJSON []byte HttpAllAllowMismatchDomainsJSON []byte
@@ -140,7 +148,7 @@ func (this *IndexAction) RunPost(params struct {
config.HTTPAll.MatchDomainStrictly = params.HttpAllMatchDomainStrictly config.HTTPAll.MatchDomainStrictly = params.HttpAllMatchDomainStrictly
config.HTTPAll.DomainMismatchAction = &serverconfigs.DomainMismatchAction{ config.HTTPAll.DomainMismatchAction = &serverconfigs.DomainMismatchAction{
Code: serverconfigs.DomainMismatchActionPage, Code: params.HttpAllDomainMismatchActionCode,
Options: maps.Map{ Options: maps.Map{
"statusCode": domainMisMatchStatusCode, "statusCode": domainMisMatchStatusCode,
"contentHTML": params.HttpAllDomainMismatchActionContentHTML, "contentHTML": params.HttpAllDomainMismatchActionContentHTML,

View File

@@ -14,23 +14,35 @@
<td class="title color-border">禁止未绑定域名访问</td> <td class="title color-border">禁止未绑定域名访问</td>
<td> <td>
<checkbox name="httpAllMatchDomainStrictly" v-model="config.httpAll.matchDomainStrictly"></checkbox> <checkbox name="httpAllMatchDomainStrictly" v-model="config.httpAll.matchDomainStrictly"></checkbox>
<p class="comment">选中后表示禁止未绑定的域名和IP访问。</p> <p class="comment">选中后,表示禁止未在网站绑定的域名和IP访问。</p>
</td> </td>
</tr> </tr>
<tr v-show="config.httpAll.matchDomainStrictly">
<tr>
<td class="color-border">处理未绑定域名方式</td>
<td>
<radio name="httpAllDomainMismatchActionCode" :v-value="'page'" v-model="httpAllDomainMismatchActionCode">显示提示页面</radio> &nbsp;
&nbsp; <radio name="httpAllDomainMismatchActionCode" :v-value="'close'" v-model="httpAllDomainMismatchActionCode">关闭连接</radio>
<p class="comment" v-if="httpAllDomainMismatchActionCode == 'page'">显示提示内容。</p>
<p class="comment" v-if="httpAllDomainMismatchActionCode == 'close'">直接关闭网络连接,不提示任何内容。</p>
</td>
</tr>
<tr v-show="config.httpAll.matchDomainStrictly && httpAllDomainMismatchActionCode == 'page'">
<td class="color-border">提示页面状态码</td> <td class="color-border">提示页面状态码</td>
<td> <td>
<input type="text" name="httpAllDomainMismatchActionStatusCode" v-model="httpAllDomainMismatchActionStatusCode" style="width: 4em" maxlength="3"/> <input type="text" name="httpAllDomainMismatchActionStatusCode" v-model="httpAllDomainMismatchActionStatusCode" style="width: 4em" maxlength="3"/>
<p class="comment">访问未绑定域名时的提示页面状态码默认404。</p> <p class="comment">访问未绑定域名时的提示页面状态码默认404。</p>
</td> </td>
</tr> </tr>
<tr v-show="config.httpAll.matchDomainStrictly"> <tr v-show="config.httpAll.matchDomainStrictly && httpAllDomainMismatchActionCode == 'page'">
<td class="color-border">未绑定域名页面提示</td> <td class="color-border">提示页面内容</td>
<td> <td>
<textarea rows="3" name="httpAllDomainMismatchActionContentHTML" v-model="httpAllDomainMismatchActionContentHTML"></textarea> <textarea rows="3" name="httpAllDomainMismatchActionContentHTML" v-model="httpAllDomainMismatchActionContentHTML"></textarea>
<p class="comment">访问未绑定的域名时提示的文字可以使用HTML仅限于HTTP请求不适于用HTTPSHTTPS会提示证书错误</p> <p class="comment">访问未绑定的域名时提示页面内容可以使用HTML仅限于HTTP请求不适于用HTTPSHTTPS会提示证书错误</p>
</td> </td>
</tr> </tr>
<tr v-show="config.httpAll.matchDomainStrictly"> <tr v-show="config.httpAll.matchDomainStrictly">
<td class="color-border">允许例外的域名</td> <td class="color-border">允许例外的域名</td>
<td> <td>