Nginx: index.php URLs still being served alongside pretty URLs
I fixed it by adding rewrite ^/index.php/(.*) /$1 permanent; to my server block. This will redirect all urls containing index.php and something after it to the contents after index.php.

E.g. /index.php/about will be permanently redirected to /about. Google knows that if something is permanently redirected its the same content and will only index the redirect.

There's one drawback though, because index.php is an actual file you can still access that. So you need to keep Disallow: /index.php into your robots.txt as well.