mirror of
				https://github.com/TeaOSLab/EdgeAdmin.git
				synced 2025-11-04 21:50:28 +08:00 
			
		
		
		
	创建集群时增加“只允许绑定的域名访问”选项
This commit is contained in:
		@@ -97,11 +97,6 @@ func (this *ClusterHelper) createSettingMenu(cluster *pb.NodeCluster, info *pb.F
 | 
				
			|||||||
		"isActive": selectedItem == "basic",
 | 
							"isActive": selectedItem == "basic",
 | 
				
			||||||
		"isOn":     true,
 | 
							"isOn":     true,
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	items = append(items, maps.Map{
 | 
					 | 
				
			||||||
		"name":     "服务设置",
 | 
					 | 
				
			||||||
		"url":      "/clusters/cluster/settings/global-server-config?clusterId=" + clusterId,
 | 
					 | 
				
			||||||
		"isActive": selectedItem == "globalServerConfig",
 | 
					 | 
				
			||||||
	})
 | 
					 | 
				
			||||||
	items = append(items, maps.Map{
 | 
						items = append(items, maps.Map{
 | 
				
			||||||
		"name":     "缓存设置",
 | 
							"name":     "缓存设置",
 | 
				
			||||||
		"url":      "/clusters/cluster/settings/cache?clusterId=" + clusterId,
 | 
							"url":      "/clusters/cluster/settings/cache?clusterId=" + clusterId,
 | 
				
			||||||
@@ -158,6 +153,12 @@ func (this *ClusterHelper) createSettingMenu(cluster *pb.NodeCluster, info *pb.F
 | 
				
			|||||||
		"isOn":     info != nil && info.HasDDoSProtection,
 | 
							"isOn":     info != nil && info.HasDDoSProtection,
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						items = append(items, maps.Map{
 | 
				
			||||||
 | 
							"name":     "服务设置",
 | 
				
			||||||
 | 
							"url":      "/clusters/cluster/settings/global-server-config?clusterId=" + clusterId,
 | 
				
			||||||
 | 
							"isActive": selectedItem == "globalServerConfig",
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	items = append(items, maps.Map{
 | 
						items = append(items, maps.Map{
 | 
				
			||||||
		"name": "-",
 | 
							"name": "-",
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -7,6 +7,7 @@ import (
 | 
				
			|||||||
	"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/dns/domains/domainutils"
 | 
						"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/dns/domains/domainutils"
 | 
				
			||||||
	"github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs"
 | 
						"github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs"
 | 
				
			||||||
	"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
 | 
						"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
 | 
				
			||||||
	"github.com/iwind/TeaGo/actions"
 | 
						"github.com/iwind/TeaGo/actions"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -55,6 +56,9 @@ func (this *CreateAction) RunPost(params struct {
 | 
				
			|||||||
	// WAF策略
 | 
						// WAF策略
 | 
				
			||||||
	HttpFirewallPolicyId int64
 | 
						HttpFirewallPolicyId int64
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// 服务配置
 | 
				
			||||||
 | 
						MatchDomainStrictly bool
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// SSH相关
 | 
						// SSH相关
 | 
				
			||||||
	GrantId            int64
 | 
						GrantId            int64
 | 
				
			||||||
	InstallDir         string
 | 
						InstallDir         string
 | 
				
			||||||
@@ -93,6 +97,15 @@ func (this *CreateAction) RunPost(params struct {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	// TODO 检查DnsDomainId的有效性
 | 
						// TODO 检查DnsDomainId的有效性
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// 全局服务配置
 | 
				
			||||||
 | 
						var globalServerConfig = serverconfigs.DefaultGlobalServerConfig()
 | 
				
			||||||
 | 
						globalServerConfig.HTTPAll.MatchDomainStrictly = params.MatchDomainStrictly
 | 
				
			||||||
 | 
						globalServerConfigJSON, err := json.Marshal(globalServerConfig)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							this.ErrorPage(err)
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// 系统服务
 | 
						// 系统服务
 | 
				
			||||||
	var systemServices = map[string]any{}
 | 
						var systemServices = map[string]any{}
 | 
				
			||||||
	if params.SystemdServiceIsOn {
 | 
						if params.SystemdServiceIsOn {
 | 
				
			||||||
@@ -107,15 +120,16 @@ func (this *CreateAction) RunPost(params struct {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	createResp, err := this.RPC().NodeClusterRPC().CreateNodeCluster(this.AdminContext(), &pb.CreateNodeClusterRequest{
 | 
						createResp, err := this.RPC().NodeClusterRPC().CreateNodeCluster(this.AdminContext(), &pb.CreateNodeClusterRequest{
 | 
				
			||||||
		Name:                 params.Name,
 | 
							Name:                   params.Name,
 | 
				
			||||||
		NodeGrantId:          params.GrantId,
 | 
							NodeGrantId:            params.GrantId,
 | 
				
			||||||
		InstallDir:           params.InstallDir,
 | 
							InstallDir:             params.InstallDir,
 | 
				
			||||||
		DnsDomainId:          params.DnsDomainId,
 | 
							DnsDomainId:            params.DnsDomainId,
 | 
				
			||||||
		DnsName:              params.DnsName,
 | 
							DnsName:                params.DnsName,
 | 
				
			||||||
		DnsTTL:               params.DnsTTL,
 | 
							DnsTTL:                 params.DnsTTL,
 | 
				
			||||||
		HttpCachePolicyId:    params.CachePolicyId,
 | 
							HttpCachePolicyId:      params.CachePolicyId,
 | 
				
			||||||
		HttpFirewallPolicyId: params.HttpFirewallPolicyId,
 | 
							HttpFirewallPolicyId:   params.HttpFirewallPolicyId,
 | 
				
			||||||
		SystemServicesJSON:   systemServicesJSON,
 | 
							SystemServicesJSON:     systemServicesJSON,
 | 
				
			||||||
 | 
							GlobalServerConfigJSON: globalServerConfigJSON,
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		this.ErrorPage(err)
 | 
							this.ErrorPage(err)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -7,7 +7,6 @@ import (
 | 
				
			|||||||
	"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
 | 
						"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
 | 
				
			||||||
	"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
 | 
						"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
 | 
				
			||||||
	"github.com/iwind/TeaGo/actions"
 | 
						"github.com/iwind/TeaGo/actions"
 | 
				
			||||||
	"github.com/iwind/TeaGo/maps"
 | 
					 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const (
 | 
					const (
 | 
				
			||||||
@@ -65,7 +64,7 @@ func (this *IndexAction) RunPost(params struct {
 | 
				
			|||||||
	DefaultDomain string
 | 
						DefaultDomain string
 | 
				
			||||||
}) {
 | 
					}) {
 | 
				
			||||||
	// 创建日志
 | 
						// 创建日志
 | 
				
			||||||
	defer this.CreateLog(oplogs.LevelInfo, "保存代理服务全局配置")
 | 
						defer this.CreateLog(oplogs.LevelInfo, "保存网站服务全局配置")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if len(params.GlobalConfigJSON) == 0 {
 | 
						if len(params.GlobalConfigJSON) == 0 {
 | 
				
			||||||
		this.Fail("错误的配置信息,请刷新当前页面后重试")
 | 
							this.Fail("错误的配置信息,请刷新当前页面后重试")
 | 
				
			||||||
@@ -84,27 +83,6 @@ func (this *IndexAction) RunPost(params struct {
 | 
				
			|||||||
			allowMismatchDomains = append(allowMismatchDomains, domain)
 | 
								allowMismatchDomains = append(allowMismatchDomains, domain)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	globalConfig.HTTPAll.AllowMismatchDomains = allowMismatchDomains
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	// 不匹配域名的动作
 | 
					 | 
				
			||||||
	switch params.DomainMismatchAction {
 | 
					 | 
				
			||||||
	case "close":
 | 
					 | 
				
			||||||
		globalConfig.HTTPAll.DomainMismatchAction = &serverconfigs.DomainMismatchAction{
 | 
					 | 
				
			||||||
			Code:    "close",
 | 
					 | 
				
			||||||
			Options: nil,
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	case "page":
 | 
					 | 
				
			||||||
		if params.DomainMismatchActionPageStatusCode <= 0 {
 | 
					 | 
				
			||||||
			params.DomainMismatchActionPageStatusCode = 404
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		globalConfig.HTTPAll.DomainMismatchAction = &serverconfigs.DomainMismatchAction{
 | 
					 | 
				
			||||||
			Code: "page",
 | 
					 | 
				
			||||||
			Options: maps.Map{
 | 
					 | 
				
			||||||
				"statusCode":  params.DomainMismatchActionPageStatusCode,
 | 
					 | 
				
			||||||
				"contentHTML": params.DomainMismatchActionPageContentHTML,
 | 
					 | 
				
			||||||
			},
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// TCP端口范围
 | 
						// TCP端口范围
 | 
				
			||||||
	if params.TcpAllPortRangeMin < 1024 {
 | 
						if params.TcpAllPortRangeMin < 1024 {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -47,6 +47,6 @@ Vue.component("checkbox", {
 | 
				
			|||||||
	},
 | 
						},
 | 
				
			||||||
	template: `<div class="ui checkbox">
 | 
						template: `<div class="ui checkbox">
 | 
				
			||||||
	<input type="checkbox" :name="name" :value="elementValue" :id="elementId" @change="change" v-model="newValue"/>
 | 
						<input type="checkbox" :name="name" :value="elementValue" :id="elementId" @change="change" v-model="newValue"/>
 | 
				
			||||||
	<label :for="elementId" style="font-size: 0.85em!important;"><slot></slot></label>
 | 
						<label :for="elementId"><slot></slot></label>
 | 
				
			||||||
</div>`
 | 
					</div>`
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
@@ -23,6 +23,13 @@
 | 
				
			|||||||
                <p class="comment">为可选项。集群中的网站服务可以自行设置是否启用此设置。</p>
 | 
					                <p class="comment">为可选项。集群中的网站服务可以自行设置是否启用此设置。</p>
 | 
				
			||||||
            </td>
 | 
					            </td>
 | 
				
			||||||
        </tr>
 | 
					        </tr>
 | 
				
			||||||
 | 
					        <tr>
 | 
				
			||||||
 | 
					            <td>只允许绑定的域名访问</td>
 | 
				
			||||||
 | 
					            <td>
 | 
				
			||||||
 | 
					                <checkbox name="matchDomainStrictly" value="1"></checkbox>
 | 
				
			||||||
 | 
					                <p class="comment">选中后,表示只有已经绑定(<tip-icon content="已经绑定的域名:为在网站设置--“域名”设置页中已经填入的域名。"></tip-icon>)的域名才允许访问;不选中表示访问一个不存在的域名时默认选择第一个网站。</p>
 | 
				
			||||||
 | 
					            </td>
 | 
				
			||||||
 | 
					        </tr>
 | 
				
			||||||
	</table>
 | 
						</table>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	<h4>节点安装选项  <span class="grey small">(可选)</span></h4>
 | 
						<h4>节点安装选项  <span class="grey small">(可选)</span></h4>
 | 
				
			||||||
@@ -31,7 +38,7 @@
 | 
				
			|||||||
			<td class="title">默认SSH登录方式</td>
 | 
								<td class="title">默认SSH登录方式</td>
 | 
				
			||||||
			<td>
 | 
								<td>
 | 
				
			||||||
				<grant-selector></grant-selector>
 | 
									<grant-selector></grant-selector>
 | 
				
			||||||
				<p class="comment">当节点没有单独设置SSH登录方式时,默认使用此设置。</p>
 | 
									<p class="comment">当前集群下节点统一的登录设置;当节点没有单独设置SSH登录方式时,默认使用此设置。</p>
 | 
				
			||||||
			</td>
 | 
								</td>
 | 
				
			||||||
		</tr>
 | 
							</tr>
 | 
				
			||||||
		<tr>
 | 
							<tr>
 | 
				
			||||||
@@ -42,7 +49,7 @@
 | 
				
			|||||||
					目录。</p>
 | 
										目录。</p>
 | 
				
			||||||
			</td>
 | 
								</td>
 | 
				
			||||||
		</tr>
 | 
							</tr>
 | 
				
			||||||
        <tr>
 | 
					        <tr v-show="false">
 | 
				
			||||||
            <td>自动加入Systemd服务</td>
 | 
					            <td>自动加入Systemd服务</td>
 | 
				
			||||||
            <td>
 | 
					            <td>
 | 
				
			||||||
                <checkbox name="systemdServiceIsOn" checked="checked"></checkbox>
 | 
					                <checkbox name="systemdServiceIsOn" checked="checked"></checkbox>
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user