Applicable to:
- Plesk Onyx for Linux
Applicable to:
- Plesk Onyx for Linux
Symptoms
- A domain in Plesk configured with Apache + with Proxy Nginx + PHP-FPM
- nginx error 504 is shown when the PHP script exceeds configured timeout
- PHP error log file does not contain a corresponding entry regarding script execution timeout
Cause
nginx proxy_read_timeout
has the same value as PHP max_execution_time
, as a result the connection being terminated before PHP has any time to log any PHP error.
Nginx proxy_read_timeout directive limits the only interval between successive reads and operates with real (clock) time.
PHP max_execution_time
is about time consumed by the CPU, details here. PHP process can spend a lot of time waiting for database response or response from a query to some external service.
Ability to configure these settings in details considered to be a feature request with ID PPM-2492.
Workaround
Increase proxy_read_timeout
by creating a custom hosting confiuration template:
-
Connect to the server via SSH
-
Copy the required template from
default/
tocustom/
preserving the directory structure:# mkdir -p /usr/local/psa/admin/conf/templates/custom/domain
# cp /usr/local/psa/admin/conf/templates/default/domain/nginxDomainVirtualHost.php /usr/local/psa/admin/conf/templates/custom/domain/nginxDomainVirtualHost.php -
Modify the templates as follows by adding +20 seconds to the predefined timeout:
# proxy_read_timeout <?php echo min($VAR->domain->physicalHosting->scriptTimeout, 2147483) + 20 ?>;
-
Check that the modified template is a valid PHP files:
# plesk php -l /usr/local/psa/admin/conf/templates/custom/domain/nginxDomainVirtualHost.php
-
Generate new configuration files:
-
For the particular domain:
# plesk sbin httpdmng --reconfigure-domain example.com
-
For all domains:
# plesk sbin httpdmng --reconfigure-all
-
Comments
0 comments
Please sign in to leave a comment.