简体   繁体   English

关闭共享托管环境中页面的mod_security

[英]Turn off mod_security for a page in shared hosting environment

My page showing error forbidden access error, when I post some html and javascript mixed data by other page post method . 当我通过其他页面发布方法发布一些htmljavascript混合数据时,我的页面显示错误禁止访问错误。

but when I open that page directly its appears correctly without any error. 但当我直接打开该页面时,它正确显示没有任何错误。

I know this is server security related issue when I am posting data. 我发布数据时,我知道这是与服务器安全相关的问题。

As I searched I found the solution of Turn off mod_security in . 当我搜索时,我找到了关闭mod_security的解决方案。 htaccess file . htaccess文件。

But I want to do this just for this page not for my complete website. 但我想为这个页面做这个而不是我的完整网站。

My hosing environment is shared.but I can edit my . 我的软管环境是共享的。但我可以编辑我的。 htaccess file. htaccess文件。

Take a look at some mod_security and .htaccess tricks . 看看一些mod_security和.htaccess技巧 There's a lot of different ways you can enable or disable mod_sceurity. 您可以通过许多不同的方式启用或禁用mod_sceurity。 The easiest may be to set the MODSEC_ENABLE environment variable to On or Off . 最简单的方法是将MODSEC_ENABLE环境变量设置为OnOff You can use SetEnvIf to match against a number of things including the Request_URI : 您可以使用SetEnvIf匹配许多内容,包括Request_URI

SetEnvIf Request_URI your_page\.php$ MODSEC_ENABLE=Off

Or a number of pages: 或许多页面:

SetEnvIf Request_URI ^/directory/file.*\.php$ MODSEC_ENABLE=Off

Or if you need to do something more complicated, like matching against a query string, using mod_rewrite : 或者如果你需要做一些更复杂的事情,比如匹配查询字符串, 使用mod_rewrite

RewriteEngine On
RewriteCond %{QUERY_STRING} example_param=example_value [NC]
RewriteRule ^path/your_file\.php$ - [E=MODSEC_ENABLE:Off]

Do you have the OWASP Core Rule set enabled? 您是否启用了OWASP核心规则集? Check your Apache error log to see which rule is matching. 检查Apache错误日志以查看匹配的规则。 You may find that it's blocking some of your legitimate users on other pages as well. 您可能会发现它在其他页面上阻止了一些合法用户。 Talk to your hosting provider about what rule set they are using and what they are doing about false positives. 与您的托管服务提供商讨论他们正在使用的规则集以及他们对误报的处理方式。


To solve your immediate problem, you can prevent a URI from being blocked by adding a new SecRule (and you can do this in your .htaccess file. 要解决您的紧急问题,可以通过添加新的SecRule来阻止URI被阻止(您可以在.htaccess文件中执行此操作。

SecRule REQUEST_URI "/your/uri" "phase:1,pass"

To limit this to POST requests, you could use REQUEST_LINE : 要将此限制为POST请求,您可以使用REQUEST_LINE

SecRule REQUEST_LINE "POST /your/uri" "phase:1,pass"

Depending on what rule is matching and blocking the request currently, you may have to change those to phase:2 or even add a second, identical rule with phase:2 . 根据匹配的规则和当前阻止请求,您可能必须将这些更改为phase:2或甚至添加第二个相同的规则,其中phase:2

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM