Putting nginx in front of the Apache server that comes with Cpanel can be tricky.

Bellow is a script that reads the cpanel config files of the accounts and builds nginx server's (similar to Apache vhost) from them.

It can also be added to do this automatically when new accounts and domains are registered on the server.

The script's coding style is not to be taken as an example, this was written many years ago :)