「Cloudflare」修訂間的差異
跳至導覽
跳至搜尋
(→抵擋爬蟲) |
(→抵擋爬蟲) |
||
| 行 1: | 行 1: | ||
[[分類:網路服務]]使用免費服務就夠了 | [[分類:網路服務]]使用免費服務就夠了 | ||
===抵擋爬蟲=== | ===抵擋爬蟲=== | ||
| − | + | 讓 '''wiki1231''' 的 LocalSettings.php 「$wgGroupPermissions['*']['read'] = false; // 禁止路人讀頁面」 | |
| + | |||
| + | '''再登入 cloudflare.com''': | ||
# 到「帳戶首頁」的「網域」,點入域名 | # 到「帳戶首頁」的「網域」,點入域名 | ||
# 查 DNS 記錄,確定「類型:A」的域名對應 IP 的記錄是「通過 Proxy 處理」(橙色),而不是「僅 DNS」 | # 查 DNS 記錄,確定「類型:A」的域名對應 IP 的記錄是「通過 Proxy 處理」(橙色),而不是「僅 DNS」 | ||
| 行 7: | 行 9: | ||
#*自訂規則 | #*自訂規則 | ||
#*# 規則名稱:protect-wiki | #*# 規則名稱:protect-wiki | ||
| − | #*#:((http.request.uri.path contains "/alWiki") or (http.request.uri.path contains "/wellBeingNg | + | #*#:((http.request.uri.path contains "/alWiki") or (http.request.uri.path contains "/wellBeingNg")) and not cf.client.bot and not ip.src in {伺服器的 IPV4} 時採取 「受控的查問」 |
#*#:這條經常使用 | #*#:這條經常使用 | ||
#*# 規則名稱:block-bad-bots | #*# 規則名稱:block-bad-bots | ||
#*#:(http.user_agent contains "curl" or http.user_agent contains "wget" or http.user_agent contains "python" or http.user_agent contains "scrapy") 時採取 「封鎖」 | #*#:(http.user_agent contains "curl" or http.user_agent contains "wget" or http.user_agent contains "python" or http.user_agent contains "scrapy") 時採取 「封鎖」 | ||
| − | #*#: | + | #*#:這條極少使用 |
#*限速規則 | #*限速規則 | ||
#*# 規則名稱:limit-wiki | #*# 規則名稱:limit-wiki | ||
於 2026年4月26日 (日) 19:24 的修訂
使用免費服務就夠了
抵擋爬蟲
讓 wiki1231 的 LocalSettings.php 「$wgGroupPermissions['*']['read'] = false; // 禁止路人讀頁面」
再登入 cloudflare.com:
- 到「帳戶首頁」的「網域」,點入域名
- 查 DNS 記錄,確定「類型:A」的域名對應 IP 的記錄是「通過 Proxy 處理」(橙色),而不是「僅 DNS」
- 選擇「網路安全 / 安全性規則」
- 自訂規則
- 規則名稱:protect-wiki
- ((http.request.uri.path contains "/alWiki") or (http.request.uri.path contains "/wellBeingNg")) and not cf.client.bot and not ip.src in {伺服器的 IPV4} 時採取 「受控的查問」
- 這條經常使用
- 規則名稱:block-bad-bots
- (http.user_agent contains "curl" or http.user_agent contains "wget" or http.user_agent contains "python" or http.user_agent contains "scrapy") 時採取 「封鎖」
- 這條極少使用
- 規則名稱:protect-wiki
- 限速規則
- 規則名稱:limit-wiki
- (http.request.uri.path contains "/alWiki") or (http.request.uri.path contains "/wellBeingNg") or (http.request.uri.path contains "/wiki1231") or (http.request.uri.path contains "/wikiGrade1") 時且使用相同的 IP / 每 10 秒請求 10 次 => 採取動作「封鎖 10 秒」
- 這條偶而使用
- 規則名稱:limit-wiki
- 自訂規則
- 「Caching / Cache rules」不要使用,會使得「分類樹」外掛的即時反應功能消失。
- 會使得 file_get_contents(…) 也被 cloudflare 當成爬蟲阻擋,必須改用 file_get_contents(http://localhost…) 取回資料。