当前位置:首页 > 网站建设 > 建站交流 > 正文内容

cloudflare防火墙规则设置详细教程

热淘网6个月前 (10-14)建站交流195

规则,防火墙,使用方法

  • 规则防火墙使用方法

  • 套餐情况
  • 套餐规则数量拦截方式是否允许正则
    Free/PRO-plus5No LogNo
    PRO20No LogNo
    Business100No LogYes
    Enterprise1000AllYes

    部分案例


    案例说明
    (ip.src ne 127.0.0.1)全站开启验证码,访客IP不是127.0.0.1开启防御机制
    (not cf.client.bot)非搜索引擎的IP进行的访问进行验证码或屏蔽
    (not ip.geoip.country in {"CN" "HK" "TW" "MO"} and not cf.client.bot)访客不是大陆,香港,台湾,澳门的并且不是搜索引擎的进行拦截(加入搜索引擎判断,防止谷歌,BING等国外搜索引擎被拦截)
    (not ip.geoip.country in {"CN" "HK" "TW" "MO"} and http.request.full_uri contains "login")访客不是大陆,香港,台湾,澳门的并且访问的链接里面带有login的就进行防火墙动作
    (ip.geoip.country in {"CN"} and http.request.full_uri contains "login") or (ip.geoip.country in {"CN"} and http.request.full_uri contains "register")大陆访客的并且访问的链接里面带有login/或者register的就进行防火墙动作
    (not http.referer contains "bnxb.com" and not http.referer contains "baidu.com") or (http.referer eq "")防盗链:来路域名非bnxb.com(含子域名)也非百度下的域名,或者来路为空就触发防火墙拦截
    (http.request.full_uri contains "cdn.bnxb.com" and not ip.geoip.country in {"CN" "HK"})cdn.bnxb.com这个子域名只允许大陆,香港访问,其他屏蔽

    规则类型及编写方法


    判断语句 eq-等于,ne-不等于,gt-大于,lt-小于,ge-大于等于,le-小于等于,contains-包含,not contains-不包含,in-在某几个里面,not in-不在里面
    多个条件组合可以用and并且,or或者来连接,例如:
    (http.request.full_uri contains "?" and http.request.full_uri contains "cate=" and not http.request.full_uri contains "js") 意思是访问的URL里面包含?并且包含cate= 并且不包含js的进行处理

    规则名称字段允许类型案例说明
    http.cookie字符串eq\ne\contains\not contains\matches\not matches

    (http.cookie eq "session=8521F670545D7865F79C3D7BED C29CCE;-background=light")

    (http.cookie ne "session=8521F670545D7865F79C3D7BED C29CCE;-background=light")

    (http.cookie contains "session=8521F670545D7865F79C3D7BED C29CCE;-background=light")

    (not http.cookie contains "session=8521F670545D7865F79C3D7BED C29CCE;-background=light")

    判断本地COOKIE是否包含某些特定值支持matches\not matches匹配正则

    注意两端需要用括号括起来,可以用and ,or 连接,类似

    (not http.cookie contains "session=8521F670545D7865F79C3D7BED C29CCE;-background=light" and ip.geoip.asnum lt 2000)

    http.host字符串eq\ne\contains\not contains\in\not in\matches\not matches

    (http.host eq "bnxb.com")

    (http.host ne "bnxb.com")

    (http.host contains "bnxb.com")

    (not http.host contains "bnxb.com")

    (http.host in {"bnxb.com" "cdn.bnxb.com"})

    (not http.host in {"bnxb.com" "cdn.bnxb.com"})

    主机名,判断主机名是否存在设定的值支持正则匹配matches\not matches
    http.referer字符串eq\ne\contains\not contains\matches\not matches

    (http.referer contains "bnxb.com")

    (not http.referer contains "bnxb.com")

    判断来源是否存在设置的值,正常用cotains(包含)和not contains(不包含)支持正则匹配matches\not matches
    http.request.full_uri字符串eq\ne\contains\not contains\matches\not matches

    (http.request.full_uri eq "https://www.bnxb.com/html/123.html")

    (http.request.full_uri ne "https://www.bnxb.com/html/123.html")

    (http.request.full_uri contains "123")

    (not http.request.full_uri contains "123")

    设置防火墙的网站的某个完整链接,访客访问这个链接就会触发防御规则,不能含#,正常可以用contains 来判断域名中含有某个词的进行拦截或者放行,支持正则匹配matches\not matches
    http.request.method字符串eq\ne\in\not in

    (http.request.method eq "GET")

    (http.request.method ne "GET")

    (http.request.method in {"GET" "POST" "PUT"})

    (not http.request.method in {"GET" "POST" "PUT"})

    访客请求您网站的方式,可选GET,POST,PURGE,PUT,HEAD,OPTIONS,DELETE,PATCH
    http.request.uri字符串eq\ne\contains\not contains\matches\not matches

    (http.request.uri eq "/articles/index?section=539061&expand=comments")

    (http.request.uri ne "/articles/index?section=539061&expand=comments")

    (http.request.uri contains "expand=comments")

    (not http.request.uri contains "expand=comments")

    您域名的URI
    http.request.uri.path字符串eq\ne\contains\not contains\in\not in\matches\not matches

    (http.request.uri.path eq "/articles/index")

    (http.request.uri.path ne "/articles/index")

    (http.request.uri.path contains "/articles/index")

    (not http.request.uri.path contains "/articles/index")

    (http.request.uri.path in {"/articles/index" "/articles/bnxb" "/bnxb/com"})

    (not http.request.uri.path in {"/articles/index" "/articles/bnxb" "/bnxb/com"})

    请求路径
    http.request.uri.query字符串eq\ne\contains\not contains\matches\not matches

    (http.request.uri.query eq "section=539061&expand=comments")

    (http.request.uri.query ne "section=539061&expand=comments")

    (http.request.uri.query contains "expand=comments")

    (not http.request.uri.query contains "expand=comments")

    query请求参数,也就是?后面的一串
    http.request.version字符串eq\ne\contains\not contains

    (http.request.version eq "SPDY/3.1")

    (http.request.version ne "SPDY/3.1")

    (http.request.version in {"SPDY/3.1" "HTTP/1.1" "HTTP/2"})

    (not http.request.version in {"SPDY/3.1" "HTTP/1.1" "HTTP/2"})

    HTTP请求协议的版本,有以下选项

    HTTP/1.0

    HTTP/1.1

    HTTP/1.2

    HTTP/2

    HTTP/3

    SPDY/3.1

    http.user_agent字符串eq\ne\contains\not contain\matches\not matches

    (http.user_agent eq "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36")

    (http.user_agent ne "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36")

    (http.user_agent contains "Chrome/65.0.3325.181")

    (not http.user_agent contains "Chrome/65.0.3325.181")

    用户浏览器标识,推荐使用contains/not contains
    http.x_forwarded_for字符串eq\ne\contains\not contain\matches\not matches

    (http.x_forwarded_for eq "111.111.11.11")

    (http.x_forwarded_for ne "111.111.11.11")

    (http.x_forwarded_for contains "11.11")

    (not http.x_forwarded_for contains "11.11")

    x-forwarded-for标头 支持matches\not matches匹配正则表达式
    ip.srcIP 地址eq\ne\in\not in

    (ip.src eq 192.0.2.0)

    (ip.src ne 192.0.2.0)

    (ip.src in {192.0.2.0 192.0.3.0 192.168.1.1})

    (not ip.src in {192.0.2.0 192.0.3.0 192.168.1.1})

    客户端IP地址
    ip.geoip.asnum数字eq\ne\gt\lt\ge\le\in\not in

    (ip.geoip.asnum eq 13335)

    (ip.geoip.asnum ne 13335)

    (ip.geoip.asnum gt 13335)

    (ip.geoip.asnum lt 13335)

    (ip.geoip.asnum ge 13335)

    (ip.geoip.asnum le 13335)

    (ip.geoip.asnum in {13335 13332 11112})

    (not ip.geoip.asnum in {13335 13332 11112})

    访客IP所属的AS号,gt-大于,lt-小于,ge-大于等于,le-小于等于
    ip.geoip.continent字符串eq\ne\in\not in

    (ip.geoip.continent eq "AS")

    (ip.geoip.continent ne "AS")

    (ip.geoip.continent in {"AS" "AF" "EU" "OC"})

    (not ip.geoip.continent in {"AS" "AF" "EU" "OC"})

    访客所属的洲(7大洲),洲代码如下:
    ip.geoip.country字符串eq\ne\in\not in

    (ip.geoip.country eq "CN")

    (ip.geoip.country ne "CN")

    (ip.geoip.country in {"CN" "HK" "TW" "MO"})

    (not ip.geoip.country in {"CN" "HK" "TW" "MO"})

    访客所属国家,使用二位英文字母标识国别,详见http://tool.bnxb.com/domainname.html
    ip.geoip.subdivision_1_iso_code字符串 GB-ENGIf known, the  ISO 3166-2 code for the first level region associated with the IP address. 1 If not known, this is an empty string.
    ip.geoip.subdivision_2_iso_code字符串 GB-SWKIf known, the  ISO 3166-2 code for the second level region associated with the IP address. If not known, this is an empty string.
    ip.geoip.is_in_european_union真假 trueTrue if this is an EU country
    ssl真假 

    (ssl)

    (not ssl)

    是否使用HTTPS
    cf.client.bot真假 

    (cf.client.bot)

    (not cf.client.bot)

    基于各家搜索引擎IP段判断是否放行(支持百度,谷歌,搜狗,yahoo,yandex,apple,archive,bing,feedbin,grapeshot,linkedin,mail.ru,naver,pingdom,pinterest,seznam,uptimerobot)
    cf.threat_score数字eq\ne\gt\lt\ge\le\in\not in

    (cf.threat_score eq 2)

    (cf.threat_score ne 2)

    (cf.threat_score gt 2)

    (cf.threat_score lt 2)

    (cf.threat_score ge 2)

    (cf.threat_score le 2)

    (cf.threat_score in {2 5 8})

    (not cf.threat_score in {2 5 8})

    访客IP的威胁评分级别,越大说明CF对这个IP视为越危险,10分以上均属于较不安全的IP,40分以上属于对互联网有过攻击行为的IP,因此可以设置10分以上显示验证码,50分以上拦截。(这个设置与防御等级设置是使用同一套评分系统,防御等级-分值>0,防御等级-分值>14,防御等级-分值>24,防御等级半关闭-分值>49)
    cf.tls_client_auth.cert_verified真假 

    (cf.tls_client_auth.cert_verified)

    (not cf.tls_client_auth.cert_verified)

    已验证客户端证书


    • AF – 非洲

    • AN – 南极洲

    • AS – 亚洲

    • EU – 欧洲

    • NA – 北美洲

    • OC – 大洋洲

    • SA – 南美洲

    • ( 或者 T1 代表 Tor网络)


扫描二维码推送至手机访问。

版权声明:本文由热淘网发布,如需转载请注明出处。

本文链接:https://www.retao5.com/jianzhan/1579.html

分享给朋友:

相关文章

给大家分享2个把普通资讯论坛帖子转为门户文章的SQL

给大家分享2个把普通资讯论坛帖子转为门户文章的SQL

[i]有一个网站 以前把论坛的一个板块设置为 XX新闻 当作发布新闻和专门版面 现在转到DX后把门户的新闻作为 网站的新闻资讯版把原来的 论坛XX新闻 里的帖子和回复也转过来, 下面4个SQL 语句...

seo评分标准

seo评分标准

内部链接文字:10分标题title:10分域名:7分H1,H2字号标题:5分每段首句:5分路径或文件名:4分相似度(关键词堆积):4分每句开头:1.5分加粗或斜体:1分文本用法(内容):1分title...

傻瓜式把飞飞影视系统的官方资源库变成自己的

傻瓜式把飞飞影视系统的官方资源库变成自己的

飞飞影视系统的官方资源库经常打不开,让人非常烦恼,迫不得已自己研究了下官方的采集库,找到解决途径1.在Lib/Lib/Action/Admin/XmlAction.class.php文件中加入下面一段...

MySQL为什么会有一大堆在Sleep的进程

MySQL为什么会有一大堆在Sleep的进程

[b]关于php应该在何时调用mysql_close()以及pconnect方式和传统方式有何种区别收藏[/b]以前我一直认为,当php的页面执行结束时,会自动释放掉一切。相信很多人都跟我想的一样。但...

Nginx 504 Gateway Time-out错误的解决方案

Nginx 504 Gateway Time-out错误的解决方案

最近在centos下搭建了一个[b]nginx[/b]的WEB服务器,但是有朋友说经常出现以下错误:504 Gateway Time-out The server didn't respond in...

最大程度的减少网站搬家带来的降权

最大程度的减少网站搬家带来的降权

[b]一、网站更换空间需要注意的事项。[/b]   1.比较新老空间,新空间要比老空间更稳定快速。   2.更换空间前,请事先测试好,保证数据的完整性。   3.老空间数据保留3-5天为最佳,蜘蛛有爬...

发表评论

访客

◎欢迎参与讨论,请在这里发表您的看法和观点。