Skip to content

Commit 56acdf3

Browse files
committed
集群设置 -- 网站设置-- 增加“处理未绑定域名方式”选项
1 parent 5d6d970 commit 56acdf3

File tree

2 files changed

+31
-11
lines changed
  • internal/web/actions/default/clusters/cluster/settings/global-server-config
  • web/views/@default/clusters/cluster/settings/global-server-config

2 files changed

+31
-11
lines changed

internal/web/actions/default/clusters/cluster/settings/global-server-config/index.go

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,19 @@ func (this *IndexAction) RunGet(params struct {
4343
}
4444
this.Data["config"] = config
4545

46+
var httpAllDomainMismatchActionCode = serverconfigs.DomainMismatchActionPage
4647
var httpAllDomainMismatchActionContentHTML string
4748
var httpAllDomainMismatchActionStatusCode = "404"
48-
if config.HTTPAll.DomainMismatchAction != nil && config.HTTPAll.DomainMismatchAction.Options != nil {
49-
httpAllDomainMismatchActionContentHTML = config.HTTPAll.DomainMismatchAction.Options.GetString("contentHTML")
50-
var statusCode = config.HTTPAll.DomainMismatchAction.Options.GetInt("statusCode")
51-
if statusCode > 0 {
52-
httpAllDomainMismatchActionStatusCode = types.String(statusCode)
49+
if config.HTTPAll.DomainMismatchAction != nil {
50+
httpAllDomainMismatchActionCode = config.HTTPAll.DomainMismatchAction.Code
51+
52+
if config.HTTPAll.DomainMismatchAction.Options != nil {
53+
// 即使是非 page 处理动作,也读取这些内容,以便于在切换到 page 时,可以顺利读取到先前的设置
54+
httpAllDomainMismatchActionContentHTML = config.HTTPAll.DomainMismatchAction.Options.GetString("contentHTML")
55+
var statusCode = config.HTTPAll.DomainMismatchAction.Options.GetInt("statusCode")
56+
if statusCode > 0 {
57+
httpAllDomainMismatchActionStatusCode = types.String(statusCode)
58+
}
5359
}
5460
} else {
5561
httpAllDomainMismatchActionContentHTML = `<!DOCTYPE html>
@@ -73,6 +79,7 @@ p { color: grey; }
7379
</html>`
7480
}
7581

82+
this.Data["httpAllDomainMismatchActionCode"] = httpAllDomainMismatchActionCode
7683
this.Data["httpAllDomainMismatchActionContentHTML"] = httpAllDomainMismatchActionContentHTML
7784
this.Data["httpAllDomainMismatchActionStatusCode"] = httpAllDomainMismatchActionStatusCode
7885

@@ -83,6 +90,7 @@ func (this *IndexAction) RunPost(params struct {
8390
ClusterId int64
8491

8592
HttpAllMatchDomainStrictly bool
93+
HttpAllDomainMismatchActionCode string
8694
HttpAllDomainMismatchActionContentHTML string
8795
HttpAllDomainMismatchActionStatusCode string
8896
HttpAllAllowMismatchDomainsJSON []byte
@@ -140,7 +148,7 @@ func (this *IndexAction) RunPost(params struct {
140148

141149
config.HTTPAll.MatchDomainStrictly = params.HttpAllMatchDomainStrictly
142150
config.HTTPAll.DomainMismatchAction = &serverconfigs.DomainMismatchAction{
143-
Code: serverconfigs.DomainMismatchActionPage,
151+
Code: params.HttpAllDomainMismatchActionCode,
144152
Options: maps.Map{
145153
"statusCode": domainMisMatchStatusCode,
146154
"contentHTML": params.HttpAllDomainMismatchActionContentHTML,

web/views/@default/clusters/cluster/settings/global-server-config/index.html

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,35 @@ <h4>域名</h4>
1414
<td class="title color-border">禁止未绑定域名访问</td>
1515
<td>
1616
<checkbox name="httpAllMatchDomainStrictly" v-model="config.httpAll.matchDomainStrictly"></checkbox>
17-
<p class="comment">选中后,表示禁止未绑定的域名和IP访问</p>
17+
<p class="comment">选中后,表示禁止未在网站绑定的域名和IP访问</p>
1818
</td>
1919
</tr>
20-
<tr v-show="config.httpAll.matchDomainStrictly">
20+
21+
<tr>
22+
<td class="color-border">处理未绑定域名方式</td>
23+
<td>
24+
<radio name="httpAllDomainMismatchActionCode" :v-value="'page'" v-model="httpAllDomainMismatchActionCode">显示提示页面</radio> &nbsp;
25+
&nbsp; <radio name="httpAllDomainMismatchActionCode" :v-value="'close'" v-model="httpAllDomainMismatchActionCode">关闭连接</radio>
26+
<p class="comment" v-if="httpAllDomainMismatchActionCode == 'page'">显示提示内容。</p>
27+
<p class="comment" v-if="httpAllDomainMismatchActionCode == 'close'">直接关闭网络连接,不提示任何内容。</p>
28+
</td>
29+
</tr>
30+
31+
<tr v-show="config.httpAll.matchDomainStrictly && httpAllDomainMismatchActionCode == 'page'">
2132
<td class="color-border">提示页面状态码</td>
2233
<td>
2334
<input type="text" name="httpAllDomainMismatchActionStatusCode" v-model="httpAllDomainMismatchActionStatusCode" style="width: 4em" maxlength="3"/>
2435
<p class="comment">访问未绑定域名时的提示页面状态码,默认404。</p>
2536
</td>
2637
</tr>
27-
<tr v-show="config.httpAll.matchDomainStrictly">
28-
<td class="color-border">未绑定域名页面提示</td>
38+
<tr v-show="config.httpAll.matchDomainStrictly && httpAllDomainMismatchActionCode == 'page'">
39+
<td class="color-border">提示页面内容</td>
2940
<td>
3041
<textarea rows="3" name="httpAllDomainMismatchActionContentHTML" v-model="httpAllDomainMismatchActionContentHTML"></textarea>
31-
<p class="comment">访问未绑定的域名时提示的文字,可以使用HTML;仅限于HTTP请求,不适于用HTTPS(HTTPS会提示证书错误)。</p>
42+
<p class="comment">访问未绑定的域名时提示页面内容,可以使用HTML;仅限于HTTP请求,不适于用HTTPS(HTTPS会提示证书错误)。</p>
3243
</td>
3344
</tr>
45+
3446
<tr v-show="config.httpAll.matchDomainStrictly">
3547
<td class="color-border">允许例外的域名</td>
3648
<td>

0 commit comments

Comments
 (0)