Likely it cannot communicate with PHP. How is PHP is configured on your server? If it is php-fpm, make sure the service is running and it is properly configured. Or if it is legacy fcgi method, make sure it is properly configured.
If you are using any plugin for nginx support on your cPanel server, reinstall the plugin and see how it goes. Else contact the plugin developers to report the issue. Without checking the exact cause, I don't know how to give you troubleshooting steps as such plugins works with custom code.
By default, when using FastCGI with NGINX (which is how PHP-FPM communicates with NGINX), NGINX has a default 60 second timeout. This means that after 1 minute, if your PHP script hasn't sent any data back, NGINX will stop listening and give you a 504 gateway timeout - regardless of how PHP is set up. That setting can be changed in your nginx configuration with the directive fastcgi_read_timeout. Not knowing your full environment I can't tell you where exactly your fastcgi parameters are being housed, but they are most likely in a configuration file under /etc/nginx/ - possibly /etc/nginx/conf.d/ or maybe right in /etc/nginx/nginx.conf. Those are just my off the cuff guesses for file locations though, as I do not use cpanel and don't know your full environment.