我正在尝试使用 IfDefine 阻止由 CustomLog 生成的 IP 列表,以避免再次记录 ip,但它不起作用。我更改了 CustomLog 条件,可以观察到一些奇怪的行为:
RewriteMap blacklist txt:/var/www/blacklist.log
RewriteCond ${blacklist:%{REMOTE_ADDR}|NOT-FOUND} !=NOT-FOUND [OR]
RewriteCond ${blacklist:%{REMOTE_HOST}|NOT-FOUND} !=NOT-FOUND
RewriteRule ^ - [F,E=BLOCKED_IP]
<IfDefine !BLOCKED_IP>
SetEnvIf Request_URI "^/xmlrpc\.php$" BAD_BEHAVIOR
CustomLog /var/log/apache2/blacklist.log "%h ## %t BAD_BEHAVIOR \"%r\" %>s %b \"%{User-agent}i\"" env=BLOCKED_IP
</IfDefine>
即使 BLOCKED_IP 为 true,IfDefine 中的代码也会执行并且 CustomLog 有一个逆条件......它没有任何意义 -.-
- RewriteRule 定义 BLOCKED_IP
- IfDefine !BLOCKED_IP pass(为什么?)
- CustomLog 使用逆条件(为什么又是?)
- blacklist.log 添加了相同的 IP
有人可以解释这种行为吗?