Monday, September 2, 2024

ກຳນົດ actionban ແລະ actionunban ໃຫ້ກັບ Fail2ban ຕໍ່ກັບ Cloudflare API

Modify the Fail2ban Action:

[Definition]
actionban = curl -s -X POST "https://api.cloudflare.com/client/v4/zones/YOUR_ZONE_ID/firewall/access_rules/rules" 
-H "X-Auth-Email: [email protected]" 
-H "X-Auth-Key: your-global-api-key" 
-H "Content-Type: application/json" 
--data '{"mode":"block","configuration":{"target":"ip","value":"<ip>"},"notes":"Fail2ban block"}'

Fail2ban actionunban

[Definition]
actionunban = bash -c '
RULE_ID=$(curl -s -X GET "https://api.cloudflare.com/client/v4/zones/YOUR_ZONE_ID/firewall/access_rules/rules" 
-H "X-Auth-Email: [email protected]" 
-H "X-Auth-Key: your-global-api-key" 
-H "Content-Type: application/json" | jq -r ".result[] | select(.configuration.value == "<ip>") | .id") && 
curl -s -X DELETE "https://api.cloudflare.com/client/v4/zones/YOUR_ZONE_ID/firewall/access_rules/rules/$RULE_ID" 
-H "X-Auth-Email: [email protected]" 
-H "X-Auth-Key: your-global-api-key" 
-H "Content-Type: application/json"'

Get the Zone ID for Your Domain:

curl -X GET "https://api.cloudflare.com/client/v4/zones?name=example.com" 
-H "X-Auth-Email: [email protected]" 
-H "X-Auth-Key: your-global-api-key" 
-H "Content-Type: application/json"

Subscribe

  • RSS Atom

ອອນລາຍ: 2 | ມື້ນີ້: 10 | ວານນີ້: 25 | ທິດນີ້: 90 | ເດືອນນີ້: 869 | ປີນີ້: 11829 | ລວມ: 78932