Symptoms
Certain long-running scripts receive "504 Gateway Timeout" errors from Nginx if they take a long time to complete.
Description
The Nginx configuration limits how long processes can take before they are timed out, dictated by the values in the cpanel-proxy.conf file. This file can be edited to extend the timeout.
Please note that this file is managed and will be overwritten when the Nginx software is updated.
Workaround
The following steps can be used to extend the default timeouts immediately:
- Connect to your server using SSH as the root user.
- Create a backup of your current proxy configuration with a timestamp:
cp /etc/nginx/conf.d/includes-optional/cpanel-proxy.conf{,.$( date +%Y%m%d )} -v - Replace the proxy timeout with a larger value. In this example, we are replacing the 300s (seconds) value with 1d (day). You can use a value that is more appropriate for your needs:
sed -i '/_timeout\ /,/;/s/300s/1d/g' /etc/nginx/conf.d/includes-optional/cpanel-proxy.conf
- Restart Nginx for the changes to take effect:
/scripts/restartsrv_nginx --hard
As mentioned above, these changes will stay in place until the Nginx package is updated. There is no directly supported method to keep these changes from being overwritten, but they can be reapplied after an update occurs. Rerunning the command in Step 3 will be sufficient to reapply the changes.
Comments
0 comments
Article is closed for comments.