Friday, August 23, 2013

MaxRequestLen Issue - Plesk Server

I'm not sure if Plesk upgrade to 10.3.1 is responsible for this issue, but it started occurring after a server was upgraded to Plesk 10.3.1.

Product: Parallels Plesk Panel Linux 10.3.1, version: psa v10.3.1_build1013110726.09 os_CentOS 5
Operating System: CentOS 5 i386. Kernel: 2.6.18-194.26.1.el5PAE
Architecture: i386

Problem Description:
When using PHP as FastCGI, if you try to upload a file larger than 128KB, an error "mod_fcgid: HTTP request length 131388 (so far) exceeds MaxRequestLen (131072)" occurs and causes an 550 internal server error.

Steps to reproduce:
1. Set PHP to run as FastCGI
2. Try to upload a file larger than 128KB using any PHP upload script.


Actual Results:
When using PHP as FastCGI, if you try to upload a file larger than 128KB, an error "mod_fcgid: HTTP request length 131388 (so far) exceeds MaxRequestLen (131072)" occurs and causes an 550 internal server error.
This happens because the value of MaxRequestLen directive is set to 131072 bytes (128KB) by default.
One way to correct this, is to edit /etc/httpd/conf.d/fcgid.conf and set MaxRequestLen to a higher value, for example 15MB (MaxRequestLen 15728640)


Expected Results:
MaxRequestLen should have been set to a higher value from the beginning to avoid such issues, 128KB is too low.

Additional Information:
This issue started occurring when a server was upgraded to Plesk 10.3.1.

Noticed that the file /etc/httpd/conf.d/fcgid.conf belongs to the package psa-mod_fcgid-2.3.6-11062118.i386. According http://httpd.apache.org/mod_fcgid/mod/mod_fcgid.html , before the version 2.3.6 of this module, the default value of ​MaxRequestLen was 1GB, but since the 2.3.6 version, the default value of ​MaxRequestLen was changed to 128KB and that most likely caused the issue.
Therefore it seems Plesk is not directly responsible for this issue (mod_fcgid is) but since Parallels is using mod_fcgid in their package psa-mod_fcgid-2.3.6-11062118.i386

Solution:
=========
FcgidMaxRequestLen -->This is causing the problem. Before updating to the newest version, it was default set to 1gb. Now it is 128kb. Add the following to the file /etc/apache2/conf.d/fcgid.conf :

FcgidMaxRequestLen 1073741824

This wil give you a limit of 1gb. Next, restart your apache.

If you experienced the same problem on my Ubuntu 10.04 server after upgrading Plesk to 10.3.1. It took a while to figure out it was caused by this particular setting.

Now make the following change in the following file:
/etc/apache2/mods-available/fcgid.conf.

Almost on the end after the last row of Fcgi commands and before the </IfModule> just add:

FcgidMaxRequestLen 1073741824