To resolve it this is my preferred way.
1. Create your custom 404 file, we'll call it 404.html and upload it to your site.
2. Edit your nginx virtual host and add error_page /404.html; into your server block
3. Add fastcgi_intercept_errors on; into the bit before your fcgi_pass
4. Reload the nginx server
What this does is it tells nginx to catch all 4xx and 5xx errors from php and if there is a error_page directive set for that code return that page.