簡體   English   中英

大文件上傳時出現 Apache 錯誤 500 (mod_security)

[英]Apache error 500 on large file uploads (mod_security)

據我嘗試,通常的解決方案都不適用於我。 好吧,我的問題,每次上傳“大文件”(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(它具有默認配置和空的 activate_rules)配置以便(我認為)允許這個“大”文件上傳。 我在 Apache 2.4/CentOS 7 中運行 PHP 5.3。

您有ModSecurity alert的事實意味着您不能有空的 activate_rules 文件夾,或者您以其他方式包含規則。

ModSecurity 存在針對此錯誤的已知問題,並且它似乎很容易出現誤報。

當我的規則引發太多誤報時,主要建議是關閉該規則(我假設觸發的是規則 200003,但要根據需要替換 id):

SecRuleRemoveById 200003

嘗試檢查 fcgi 配置中的 FcgidBusyTimeout 參數

我得到了同樣的錯誤:

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 答案是正確的,由於圖像名稱和更改名稱問題解決后,我遇到了這個問題。

但這不是我想要的,因為我知道解決方案,但我的客戶不知道他們必須更改名稱。

重命名您嘗試上傳的文件。 此錯誤表示文件名包含 mod_security 不允許的字符。 重命名文件,然后再次嘗試上傳。 通過禁用 mod_security.conf 中提到的行,它會很樂意跳過此檢查,但這會使您的服務器容易受到漏洞的攻擊。

我找到了解決方案!!!

UBUNTU 16.04 + Apache(我的 mod_secure 工作和上傳正常)

0. apache a2enmod 頭文件(激活頭文件和 .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>
  1. https://www.maketecheasier.com/securing-apache-ubuntu/命令說明

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

//開關

bash->a2dismod mod-security2 //off

或者

bash->a2dismod security2 //off bash->a2enmod mod-security2 //on bash->a2enmod security2 //on
  1. 如果需要,您可以刪除特定規則:

http://www.inmotionhosting.com/support/website/modsecurity/find-and-disable-specific-modsecurity-rules

modsecurity.conf 中的 SecRuleRemoveById 950004

4. Byteconverter - http://whatsabyte.com/P1/byteconverter.htm

夠了!!!!

4小時!!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM