Symptoms
-
Trying to upload large files on a domain via PHP application results in
550 internal server error
or502 Bad Gateway
errors -
If nginx support is enabled on the server, the domain's Apache error log
/var/www/vhosts/system/example.com/logs/error_log
contains the following record:mod_fcgid: HTTP request length ... (so far) exceeds MaxRequestLen (1310720)
-
The domain's nginx error log
/var/www/vhosts/system/example.com/logs/proxy_error_log
contains the following record:upstream prematurely closed connection while reading response header from upstream
Cause
The FcgidMaxRequestLen
and/or FcgidMaxRequestInMem
directive values are insufficient.
Resolution
Server-wide
This only works with FPM application served by Apache, otherwise use custom templates
-
Connect to the server via SSH.
Note: if direct SSH access to the server is not possible, contact server administrator for further assistance.
-
Edit
fcgid.conf
file which is located in/etc/httpd/conf.d/
(for RHEL based OS) or/etc/apache2/mods-available/
(for Debian based OS). -
Set
FcgidMaxRequestLen
andFcgidMaxRequestInMem
with the same values in bytes. For example, 1024 MB corresponds to 1073741824 B. -
Restart Apache:
For RHEL-based OS
# service httpd restart
For Debian-based OS:
# service apache2 restart
Warning: restarting Apache would cause downtime for the hosted domains
For specific domains
-
Go to Domains > example.com > Apache & Nginx settings > Additional directives for HTTP & HTTPS and add the following lines:
<IfModule mod_fcgid.c>
FcgidMaxRequestLen 1073741824
FcgidMaxRequestsPerProcess 100
FcgidProcessLifeTime 7200
FcgidIOTimeout 7200
FcgidMaxRequestInMem 1073741824
</IfModule>