Art*_*cek 2 apache mod-security2
我已经启用了 SecRuleEngine,以便按照本教程在 apache 的 mod_security 中实现每个 IP 请求的突发限制。
https://johnleach.co.uk/words/2012/05/15/rate-limiting-with-apache-and-mod-security/
经过几次测试后,它似乎在 GET 和 POST 请求上按预期工作,但是单独启用 SecRuleEngine(未启用任何规则)似乎会阻止 PUT 和 DELETE 请求。这似乎不是预期的行为。
https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual#SecRuleEngine
我将 Apache 2.4 与 mod_security 版本 2 一起使用,但如果 mod_security 恰好是其中的一个错误,我愿意放弃它,并且我有一个替代方案来限制它的速率。
如何在使用或不使用 mod_security 的情况下修复速率限制系统?
ModSecurity 只会阻止它被告知要阻止的内容。
我的猜测是,尽管说您没有启用任何规则,但您包含了明确阻止这些方法的 OWASP CRS。
例如,版本 2 在其 modsecurity_crs_10_setup.conf.example 配置文件中有以下规则:
#
# Set the following policy settings here and they will be propagated to the 30 rules
# file (modsecurity_crs_30_http_policy.conf) by using macro expansion.
# If you run into false positves, you can adjust the settings here.
#
SecAction \
"id:'900012', \
phase:1, \
t:none, \
setvar:'tx.allowed_methods=GET HEAD POST OPTIONS', \
setvar:'tx.allowed_request_content_type=application/x-www-form-urlencoded|multipart/form-data|text/xml|application/xml|application/x-amf|application/json', \
setvar:'tx.allowed_http_versions=HTTP/0.9 HTTP/1.0 HTTP/1.1', \
setvar:'tx.restricted_extensions=.asa/ .asax/ .ascx/ .axd/ .backup/ .bak/ .bat/ .cdx/ .cer/ .cfg/ .cmd/ .com/ .config/ .conf/ .cs/ .csproj/ .csr/ .dat/ .db/ .dbf/ .dll/ .dos/ .htr/ .htw/ .ida/ .idc/ .idq/ .inc/ .ini/ .key/ .licx/ .lnk/ .log/ .mdb/ .old/ .pass/ .pdb/ .pol/ .printer/ .pwd/ .resources/ .resx/ .sql/ .sys/ .vb/ .vbs/ .vbproj/ .vsdisco/ .webinfo/ .xsd/ .xsx/', \
setvar:'tx.restricted_headers=/Proxy-Connection/ /Lock-Token/ /Content-Range/ /Translate/ /via/ /if/', \
nolog, \
pass"
Run Code Online (Sandbox Code Playgroud)
正如你所看到的只是GET,HEAD,POST并OPTIONS设置为允许的方法。
较新的版本 3 在 crs-setup.conf.example 中有类似的配置:
# HTTP methods that a client is allowed to use.
# Default: GET HEAD POST OPTIONS
# Example: for RESTful APIs, add the following methods: PUT PATCH DELETE
# Example: for WebDAV, add the following methods: CHECKOUT COPY DELETE LOCK
# MERGE MKACTIVITY MKCOL MOVE PROPFIND PROPPATCH PUT UNLOCK
# Uncomment this rule to change the default.
#SecAction \
# "id:900200,\
# phase:1,\
# nolog,\
# pass,\
# t:none,\
# setvar:'tx.allowed_methods=GET HEAD POST OPTIONS'"
Run Code Online (Sandbox Code Playgroud)
在这两种情况下,作为后续规则,使用此设置来阻止像PUT和DELETE。
无论您是使用这些规则还是其他规则集,ModSecurity 都应该在 Apache 错误日志中记录它为什么阻止请求。检查它以了解它被阻止的原因。
| 归档时间: |
|
| 查看次数: |
3683 次 |
| 最近记录: |