php - apache mod_security 说 - 访问被拒绝错误

标签 php javascript apache http-status-code-403 mod-security

背景 -

我的网站代码托管在 Linux 服务器上。我的网站允许雇主进行新注册 ( http://www.gymandspajobs.com/Employer/Employer.php )。填写的表单由文件夹“/javascript”中的 JavaScript 进行验证,如果发现信息正确,则通过 JavaScript HTTP 请求对象和 PHP 文件“somefile.php”提交数据。 php”保存在根目录下的文件夹“/somefolder”中进行数据库插入。

问题 -

当新用户尝试使用 Firefox 注册时(我在 WinXP SP2、Firefox - v3.5.2 中进行了测试),我收到的 HTTP 响应(我在 JavaScript 文件中点击)是 “您无权访问此服务器上的/somefolder/somefile.php。”。

令人惊讶的是,相同的功能在 IE7 和 Chrome 中运行得非常好。

问题的最新更新 -

我联系了我的网络托管人员,在收到他们的回复后,我的问题似乎已经解决。

We have disabled mod_security for your domain to fix it. We have entered the below lines to the .htaccess file under the httpdocs directory for your domain. We have also verified and successfully able to submit the Employer registration without any issues. ~~~~~ SecFilterEngine off ~~~~~

虽然问题已经解决,但我认为创建“SecFilterEngine off”可能不是解决此问题的最佳方案,因为它会损害安全性。因此,我问托管人员是否有办法保持 mod_security 开启,同时让我的功能正常工作……这是他们的答复……

Q. is there any way my code can work yet keeping mod_security ON?

Ans. It is possible. But it is not easy. You have to modify the code in the file in such a way that the URI should not have the pattern "!(^application/x-www-form-urlencoded$|^multipart/form-data;)" because we found this entry in the apache error logs -

mod_security-action: 403

mod_security-message: Access denied with code 403. Pattern match "!(^application/x-www-form-urlencoded$|^multipart/form-data;)" at HEADER("Content-Type")

我通过 JavaScript 使用 HTTP 对象和 POST 方法 -

http.setRequestHeader('Content-Type','application/x-www-form-urlencoded')

请指导我在上面的代码行中需要进行哪些更改,以便 mod_security 可以保持打开状态,但我的注册表单仍然可以工作?

感谢和问候,

-鲁帕克·哈万迪卡-

最佳答案

在这种情况下,最好的办法是将特定警告视为误报,因为事实确实如此。请记住,mod_security 不支持内容编码,当您处理 WAF 时,误报是很正常的事情。

仅仅为了一个误报而禁用所有 mod_security 规则是愚蠢的。查找正在触发的规则的 ID 并将其禁用“SecRuleRemoveById”。在我的框中,我创建了一个附加配置来放置我想要禁用的所有规则。

modsecurity_crs_60_myignores.conf

SecRuleRemoveById 960903

SecRuleRemoveById 970903

SecRuleRemoveById 970902

关于php - apache mod_security 说 - 访问被拒绝错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1283909/

相关文章:

javascript - 使用 React Native 从服务器进行奇怪的响应解释

java - tomcat 已启动但应用程序未在浏览器中加载

php - 包括者与返回包括

php - 使用电子商务跟踪将数据发送到Google Universal Analytics中的自定义维度和指标

javascript - 是否可以在 native Android 应用程序中实现 HTML5(我计划使用 WebRTC)作为 WebView?

apache - Mod_rewrite - 如何告诉 Google 在 7 天后从其索引中动态删除页面

Apache SSI 和变量

php - 使用 jQuery 通过 AJAX 提交表单并显示处理 PHP 页面的返回

PHP PDO 插入有缺失值的行

javascript - 实时绑定(bind)是什么意思?