Nginx with PAM authentication through pam_script

The nginx PAM module also runs the PAM account operation, so you need to also configure this. You can use the pam_permit module to always succeed:

auth    required    pam_script.so dir=/path/to/my/auth_scripts
account required    pam_permit.so

Try following the auth log (tail -f /var/log/auth.log) while authenticating, it will show you all pam requests and maybe also the error/warning/exception which will make it al clear to you.