kangle多节点服务器均衡负载设置/加固/安全防御/CC防御防注入防木马等操作教程LinuxServer

印迹发布于:2020-12-13 897

Kangle多节点设置说明

权重

权重越高,处理的数据量越大,可填写0-10数值。如多节点服务器群中的服务器有可能具有不同的硬件配置,可以考虑设置不同的权重。权重为0:表示是备用节点,当所有节点服务器出现故障时,系统将自动启用备用节点服务器继续提供服务。使网络具有高稳定性和高可用性。

Ip哈希

基于ip的稳定连接。使来源机器的会话保持连续,即:每个请求按访问ip的hash结果分配,这样每个访客固定访问一个后端服务器,可以解决session的问题,对于一个特定的请求,如果所申请的服务器不能进行处理,其他的服务器可以马上取代它的位置,对所申请的请求进行处理,这一过程对用户感觉来说,服务是稳定、连续的。

Cookie粘住:

在说明cookie粘住前,先在此先简要说明一下什么是cookie。简单的说,Cookie就是服务器暂存放在您计算机上的一笔资料,好让服务器用来辨认你的计算机。根据请求用户的cooki分配固定的一个后端服务器进行服务。说明:在同时使用ip哈希和cookie粘住时,以cookie粘住优先。

错误重试时间(秒):

如果某个节点服务器连不上,自动会从其它节点服务器上连接。每隔设定的错误重试时间,又会尝试去连接该节点服务器。

连接错误次数

当某个节点服务器没连通,系统会把分配给该节点服务的请求转给其它节点服务,同时每隔设定的错误重试时间会自动去连接该节点,如发现能连通,作上线处理。反之,没连通并且连续连接错误次数达到“连接错误次数设定值”后,kangle会认为这台节点有故障,并作下线处理。节点作下线处理后,kangle不会再把请求发送到该节点。


加固设置:安全防御/CC防御/防注入/防木马/SQL等操作


1.禁止目录执行

先点击菜单的请求控制 选择添加 目标 选择拒绝 俩个匹配模块 reg_path

分别写入 记得勾选 nc 详细和图片对比

.*\/((attachment)|(attachments)|(uploadfiles)|(avatar))\/
\.((php)|(php5)|(php7)|(phps)|(jsp)|(asp)|(aspx)|(asa)|(asax)|(ascx)|(ashx)|(asmx)|(axd)).*$


2.保护系统文件

先点击菜单的请求控制 选择添加 目标 选择拒绝 匹配模块 url

分别写入 记得勾选 nc 详细和图片对比

\.(htaccess|uini)


3.保护敏感文件

先点击菜单的请求控制 选择添加 目标 选择拒绝 匹配模块 url

分别写入 记得勾选 nc 详细和图片对比

(up.+\.|web\.|httpd\.)(conf|log|config|ini)


4.获取真实 IP

先点击菜单的请求控制 选择添加 直接添加 选择继续 标记模块 replace_ip

header 处写入 详细和图片对比

X-Forwarded-For


5.防止木马上传

先点击菜单的请求控制 选择添加 直接添加 选择拒绝 标记模块选择 post_file 之后选择 ignore

详细和图片对比

\.((php)|(php5)|(php7)|(phps)|(jsp)|(asp)|(aspx)|(asa)|(asax)|(ascx)|(ashx)|(asmx)|(axd)|(html)|(htm)|(js))$



6.设置防御 CC

这个功能只能在商业版有效,先点击菜单的请求控制 选择添加 直接添加 选择继续 标记模块选择 anti_cc

request 和 second 自己按照需求设置

记得勾选 white list 和 fix_url

详细和图片对比

推荐承防护内容:

HTTP/1.1 200 OK
Content-Type: text/html; charset=utf-8
Connection: keep-alive
Cache-Control: no-cache,no-store
Recaptcha: virplus
<html><body><script language="javascript">window.location="{{url}}";</script><a href="{{url}}"><div class="notice">
<div class="title">You have verified successfully</div>
<div class="description">Please wait, you are being redirected ...</div>
</div></a></body></html>


7.防 SQL 注入

先点击菜单的请求控制 选择添加 直接添加 选择拒绝 标记模块选择 param

之后在 param value:(regex) 输入

'.*[; ]?((or)|(insert)|(select)|(union)|(update)|(delete)|(replace)|(create)|(drop)|(alter)|(grant)|(load)|(show)|(exec))[\s(]


防CC人机验证代码
HTTP/1.1 200 OK
Content-Type: text/html; charset=utf-8
Connection: keep-alive
Cache-Control: no-cache,no-store
Recaptcha: diancc
<!DOCTYPE html>
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>人机验证系统</title>
<meta name="theme-color" content="#3c48b5"/>
<meta name="msapplication-TileColor" content="#3c48b5"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=0.5, maximum-scale=2.0, user-scalable=yes" />
<meta http-equiv="X-UA-Compatible" content="IE-edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1">
<style>
#slider{margin:100px auto;width:300px;height:40px;position:relative;border-radius:2px;background-color:#8f99c7;overflow:hidden;text-align:center;user-select:none;-moz-user-select:none;-webkit-user-select:none}#slider_bg{position:absolute;left:0;top:0;height:100%;background-color:#159957;z-index:1}#label{width:46px;position:absolute;left:0;top:0;height:38px;line-height:38px;border:1px solid #ccc;background:#fff;z-index:3;cursor:move;color:#384daa;font-size:16px;font-weight:900}#labelTip{position:absolute;left:0;width:100%;height:100%;font-size:13px;font-family:microsoft yahei,serif;color:#ffffff;line-height:38px;text-align:center;z-index:2}
    html, body, h1 {
        margin: 0;
        padding: 0;
    }
    body { height: 1024px;background: -webkit-linear-gradient(left top, #009900 , #4C33E5);background: -o-linear-gradient(bottom right, #009900, #4C33E5);background: -moz-linear-gradient(bottom right, #009900, #4C33E5);background: linear-gradient(to bottom right, #009900 , #4C33E5); color: #d5d4ff; overflow: hidden    }
    #demo {
        width: 600px;
        margin: 150px auto;
        padding: 10px;
        border: 1px dashed #d5d4ff;
        border-radius: 10px;
        -moz-border-radius: 10px;
        -webkit-border-radius: 10px;
        text-align: left;
    }
</style>
</head>
<body style="">
<br><br><br><center><p>网站正在检测安全环境,完成后会立即跳转至目标页面......</p></center>
<script>
var host_url = function(){
    var port = location.port;
    var Host_Url = "http://";
      
    if(port == 80){
        Host_Url += location.hostname;
    }else{
        Host_Url += location.host;
    }
      
    return Host_Url;
}();
</script>
<p><center><div id="captcha-box"></center></div>
<script src="https://api.geetest.com/get.php"></script>
<script>
    var captchaObj = new Geetest({
        gt: "0f952b4dac90c9d279a11b4739eedddb",
        product: "embed",
        lang: "zh-cn"
    });
    captchaObj.appendTo("#captcha-box");
    captchaObj.onSuccess(function () {
        location.href="{{murl}}";
    });
    captchaObj.getValidate();
</script></p>
<acl_file_ext revers='1'  icase='1' split='|'>css|gif|ico|jpg|js|kos|png|ttf</acl_file_ext>
</body></html>
实际设置应用

在112.74.208.20的边缘服务器下面增加配置项

  <!--#start 501-->
    <config>
    <server name='test' proto='http'  ip_hash='0' cookie_stick='0' error_try_time='30' max_error_count='5'><node weight='10' host='112.74.208.18' port='80' life_time='10' self_ip='112.74.208.20' /></server>
    </config>

如出现故障,self_ip设置为空再试下

这样用户访问到解析的112.74.208.20IP,会自动中转到112.74.208.18的服务器在从112.74.208.18这台服务器回源

同时可以设置多个节点,防止中间服务器down掉,根据负载实现自动化不同的中间服务器回源,当然这中间服务器也可以是多个源站服务器。

当然可以在中转节点上在设置中转节点,实现多层路由来优化延迟等问题。

同时还可以按照ip来区分路由

提示:一行一个,IP越精确,路由规则越优先

192.168.1.0/24,表示匹配IP前面是192.168.1的IP
192.168.0.0/16,表示匹配IP前面是192.168的IP
192.0.0.0/8,表示匹配IP前面是192的IP
0.0.0.0/0,表示匹配所有IP


其它

Kangle

http://www.virplus.com/thread-1380.htm

转载请注明:2020-12-13 于 VirPlus 发表

推荐阅读
最新回复 (0)

    ( 登录 ) 后,可以发表评论!

    返回