上传大文件时出现 Apache 错误 500 (mod_security)
Apache error 500 on large file uploads (mod_security)
据我所试,none 的常用解决方案对我有用。好吧,我的问题是,每次我上传 "large file" (600 KB ~) 时,我都会收到 500 错误,较小的图片效果很好。所以...,即使使用这个(极端的).htaccess 文件,它也会继续发生,是的,.htaccess 处于活动状态:
upload_max_filesize = 100M
post_max_size = 100M
memory_limit = 128M
max_input_time = 6000
max_execution_time = 6000
所以,我看了一下日志,发现了这一点(只有一行,只是为了方便阅读而粘贴了行跳转):
[Mon Jul 27 17:09:28.<port> 2015] [:error] [pid 21423] [client <ip>]
ModSecurity: Access denied with code 44 (phase 2).
Match of "eq 0" against "MULTIPART_UNMATCHED_BOUNDARY" required.
[file "/etc/httpd/conf.d/mod_security.conf"]
[line "35"] [id "<another id>"]
[msg "Multipart parser detected a possible unmatched boundary."]
[hostname "<my host>"] [uri "<my script>"] [unique_id "<id (useless I think)"]
但是,现在我无法找到如何编辑 mod_security(它具有默认配置,并且空 activated_rules)配置以便(我认为)允许此 "large" 文件上传。我是 Apache 2.4/CentOS 7 中的 运行 PHP 5.3。
尝试检查 fcgi 配置中的 FcgidBusyTimeout 参数
您有一个 ModSecurity alert
意味着您不能有空的 activated_rules 文件夹,或者您以其他方式包含规则。
有known problems with ModSecurity for this error,似乎很容易误报。
当我的规则引发太多误报时,主要建议是关闭该规则(我假设触发的是规则 200003,但适当替换 ID):
SecRuleRemoveById 200003
重命名您尝试上传的文件。此错误表示文件名包含 mod_security 不允许的字符。重命名文件,然后尝试再次上传。通过禁用 mod_security.conf 中提到的行,它会愉快地跳过此检查,但这会使您的服务器容易受到漏洞影响。
所有我找到的解决方案!!!
UBUNTU 16.04 + Apache(我的 mod_secure 工作和上传正常)
0。 apache a2enmod headers(激活 headers 和 .htaccess)
1.检查 .htaccess !!!!!
//在.htaccess
php_value upload_max_filesize 50M
php_value post_max_size 50M
//如果你想在.htaccess中自定义
<IfModule mod_security.c>
SecFilterEngine Off
SecFilterScanPOST Off
</IfModule>
sudo nano /etc/apache2/mods-enabled/security2.conf - 我评论最后两行
sudo nano /etc/modsecurity/modsecurity.conf - 配置 mod_secure 很简单
sudo nano /etc/apache2/apache2.conf - apache 配置 CTRL+W
//on/off
bash->a2dismod mod-security2 //off
或
bash->a2dismod security2 //off
bash->a2enmod mod-security2 //on
bash->a2enmod security2 //on
- 如果需要,您可以删除特定规则:
modsecurity.conf
中的 SecRuleRemoveById 950004
4。字节转换器 - http://whatsabyte.com/P1/byteconverter.htm
这就够了!!!!
4 小时!!
我遇到了同样的错误:
ModSecurity: Access denied with code 44 (phase 2). Match of "eq 0" against "MULTIPART_UNMATCHED_BOUNDARY" required. [file "/etc/httpd/conf.d/mod_security.conf"] [line "34"] [id "200003"] [msg "Multipart parser detected a possible unmatched boundary."]
但是@nilpo 回答是正确的
由于图像名称,我遇到了这个问题,更改名称后问题解决了。
但这不是我想要的,因为我知道解决方案,但我的客户不知道他们必须更改名称。
据我所试,none 的常用解决方案对我有用。好吧,我的问题是,每次我上传 "large file" (600 KB ~) 时,我都会收到 500 错误,较小的图片效果很好。所以...,即使使用这个(极端的).htaccess 文件,它也会继续发生,是的,.htaccess 处于活动状态:
upload_max_filesize = 100M
post_max_size = 100M
memory_limit = 128M
max_input_time = 6000
max_execution_time = 6000
所以,我看了一下日志,发现了这一点(只有一行,只是为了方便阅读而粘贴了行跳转):
[Mon Jul 27 17:09:28.<port> 2015] [:error] [pid 21423] [client <ip>]
ModSecurity: Access denied with code 44 (phase 2).
Match of "eq 0" against "MULTIPART_UNMATCHED_BOUNDARY" required.
[file "/etc/httpd/conf.d/mod_security.conf"]
[line "35"] [id "<another id>"]
[msg "Multipart parser detected a possible unmatched boundary."]
[hostname "<my host>"] [uri "<my script>"] [unique_id "<id (useless I think)"]
但是,现在我无法找到如何编辑 mod_security(它具有默认配置,并且空 activated_rules)配置以便(我认为)允许此 "large" 文件上传。我是 Apache 2.4/CentOS 7 中的 运行 PHP 5.3。
尝试检查 fcgi 配置中的 FcgidBusyTimeout 参数
您有一个 ModSecurity alert
意味着您不能有空的 activated_rules 文件夹,或者您以其他方式包含规则。
有known problems with ModSecurity for this error,似乎很容易误报。
当我的规则引发太多误报时,主要建议是关闭该规则(我假设触发的是规则 200003,但适当替换 ID):
SecRuleRemoveById 200003
重命名您尝试上传的文件。此错误表示文件名包含 mod_security 不允许的字符。重命名文件,然后尝试再次上传。通过禁用 mod_security.conf 中提到的行,它会愉快地跳过此检查,但这会使您的服务器容易受到漏洞影响。
所有我找到的解决方案!!!
UBUNTU 16.04 + Apache(我的 mod_secure 工作和上传正常)
0。 apache a2enmod headers(激活 headers 和 .htaccess)
1.检查 .htaccess !!!!!
//在.htaccess
php_value upload_max_filesize 50M
php_value post_max_size 50M
//如果你想在.htaccess中自定义
<IfModule mod_security.c>
SecFilterEngine Off
SecFilterScanPOST Off
</IfModule>
sudo nano /etc/apache2/mods-enabled/security2.conf - 我评论最后两行
sudo nano /etc/modsecurity/modsecurity.conf - 配置 mod_secure 很简单
sudo nano /etc/apache2/apache2.conf - apache 配置 CTRL+W
//on/off
bash->a2dismod mod-security2 //off
或
bash->a2dismod security2 //off
bash->a2enmod mod-security2 //on
bash->a2enmod security2 //on
- 如果需要,您可以删除特定规则:
modsecurity.conf
中的 SecRuleRemoveById 9500044。字节转换器 - http://whatsabyte.com/P1/byteconverter.htm
这就够了!!!!
4 小时!!
我遇到了同样的错误:
ModSecurity: Access denied with code 44 (phase 2). Match of "eq 0" against "MULTIPART_UNMATCHED_BOUNDARY" required. [file "/etc/httpd/conf.d/mod_security.conf"] [line "34"] [id "200003"] [msg "Multipart parser detected a possible unmatched boundary."]
但是@nilpo 回答是正确的 由于图像名称,我遇到了这个问题,更改名称后问题解决了。
但这不是我想要的,因为我知道解决方案,但我的客户不知道他们必须更改名称。