AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 57210
Accepted
dragonmantank
dragonmantank
Asked: 2009-08-22 07:28:23 +0800 CST2009-08-22 07:28:23 +0800 CST 2009-08-22 07:28:23 +0800 CST

禁用特定目录的 modsecurity

  • 772

如何仅为特定目录禁用 modsecurity。我在 phpMyAdmin 中遇到错误,这是由基于规则的 modsecurity 跳闸引起的。我设置了以下文件:

# /etc/httpd/modsecurity.d/modsecurity_crs_15_customrules.conf
<LocationMatch "^/phpMA/">
    SecRuleEngine Off
</LocationMatch>

# /etc/httpd/modsecurity.d/modsecurity_crs_60.custom.conf
<LocationMatch '^/phpMA/*'>
    SecRuleRemoveById 950004
    SecRuleRemoveById 950005
    SecRuleRemoveById 950006
    SecRuleRemoveById 960010
    SecRuleRemoveById 960012
</LocationMatch>

从我可以找到的第一个文件应该禁用它,但它仍然跳闸,所以我尝试将它跳闸的规则 ID 添加到 60 文件,但它仍然抱怨。

我在 CentOS 5.3 上运行以下软件包:

  • mod_security-2.5.0-jason.2
  • httpd-2.2.8-jason.3
  • mod-php5-apache2-zend-ce-5.2.10-65
centos apache-2.2 httpd mod-security
  • 3 3 个回答
  • 32391 Views

3 个回答

  • Voted
  1. Best Answer
    hdanniel
    2009-08-22T07:53:57+08:002009-08-22T07:53:57+08:00

    SecRuleEngine Off 必须工作。您是否尝试将 SecRuleEngine 放在目录中:

    <Directory /var/www/site/phpMA>
    SecRuleEngine Off
    </Directory>
    

    而不是 LocationMatch ?

    • 19
  2. Simon East
    2016-09-01T18:07:50+08:002016-09-01T18:07:50+08:00

    在某些服务器和 Web 主机上,可以通过 禁用 ModSecurity .htaccess,但通过这种方法您只能打开或关闭它,通常无法禁用个别规则。

    因此,与其让整个网站不受保护,不如将其限制在特定的 URL 上。您可以在下面的语句中的正则表达式中指定它们<If>...

    ### DISABLE mod_security firewall
    ### Some rules are currently too strict and are blocking legitimate users
    ### We only disable it for URLs that contain the regex below
    ### The regex below should be placed between "m#" and "#" 
    ### (this syntax is required when the string contains forward slashes)
    <IfModule mod_security.c>
      <If "%{REQUEST_URI} =~ m#/admin/#">
        SecFilterEngine Off
        SecFilterScanPOST Off
      </If>
    </IfModule>
    
    • 4
  3. Pierre C.
    2016-03-28T15:59:48+08:002016-03-28T15:59:48+08:00

    永远不要禁用所有规则!这可能会导致严重的安全问题!

    您需要检查 modsecurity 的日志文件

    tail -f /var/log/apache2/modsec_audit.log
    

    并一一排除每条规则,重现phpmyadmin界面上的错误。

    接下来,添加:

    <Directory /path/to/phpmyadmin>
        <IfModule security2_module>
            SecRuleRemoveByTag "WEB_ATTACK/SQL_INJECTION"
            {And other rules you need to disable ...}
        </IfModule>
    </Directory>
    

    到 /etc/apache2/mods-enabled/modsecurity.conf

    您需要删除的标签将像这样在日志文件中。有关删除特定文件夹规则的完整描述,请参阅项目的 Github wiki。

    • 2

相关问题

  • 在您分发的应用程序中使用 Apache HTTPD 运行 SSL 的最佳方式是什么?

  • 阿帕奇的替代品

  • 如何强制我的网址始终以 www 开头?

  • 在 Linux Xen VPS 上优化 Apache 和 MySQL

  • mod_rewrite 不转发 GET 参数

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    从 IP 地址解析主机名

    • 8 个回答
  • Marko Smith

    如何按大小对 du -h 输出进行排序

    • 30 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    Windows 中执行反向 DNS 查找的命令行实用程序是什么?

    • 14 个回答
  • Marko Smith

    如何检查 Windows 机器上的端口是否被阻塞?

    • 4 个回答
  • Marko Smith

    我应该打开哪个端口以允许远程桌面?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    MikeN 在 Nginx 中,如何在维护子域的同时将所有 http 请求重写为 https? 2009-09-22 06:04:43 +0800 CST
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    0x89 bash中的双方括号和单方括号有什么区别? 2009-08-10 13:11:51 +0800 CST
  • Martin Hope
    kch 如何更改我的私钥密码? 2009-08-06 21:37:57 +0800 CST
  • Martin Hope
    Kyle Brandt IPv4 子网如何工作? 2009-08-05 06:05:31 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve