EdgeJS访问控制规则配置方法
IP黑白名单
if (baidu_utils.ipInCidr(r.remoteAddress, ['192.168.1.1/32','192.168.2.1/24'])) { r.return(403); }
Referer黑白名单
var refers = ['http://*.baidu.com.cn/*','http://*.baidu.com/*'];
var i = 0;
for (; i < refers.length; i += 1) {
if (baidu_utils.matchWildcard(r.headersIn['referer'], refers[i])) {
r.return(403);
return;
}
}
UA黑白名单
var uas = ['curl','AppleWebKit'];
var i = 0;
var ua = r.headersIn['User-Agent'];
for (; i < uas.length; i += 1) {
if (ua.includes(uas[i])) {
r.return(403);
return;
}
}