虽然对于您的需求来说有点晚了,但这里的答案可能会帮助您遇到的其他人。
首先创建测试解决方案所需的工具,假设使用 PHP 进行配置:
//server-side script test-put.php
< ?php
parse_str(file_get_contents('php://input'), $vars);
print_r($vars);
//client-side script send-put-req.php
< ?php
$result = file_get_contents(
'http://www.testsite.ro/test-put.php',
false,
stream_context_create(array(
'http' => array(
'method' => 'PUT'
)
))
);
print_r($result);
然后查看 error_log 文件 (/usr/local/apache/logs/error_log) 中的 mod_security 行,每次请求来自上述脚本时。在我的配置中,我不得不更改这个(/usr/local/apache/conf/modsec2.user.conf):
# allow request methods
SecRule REQUEST_METHOD "!^((?:(?:POS|GE|PU)T|OPTIONS|HEAD**|DELETE))$" \
"phase:2,t:none,log,auditlog,status:501,msg:'Method is not allowed by policy', severity:'2',id:'960032',tag:'POLICY/METHOD_NOT_ALLOWED'"