The syntax of your location
directive is invalid. If you would like to match all files with a .cgi
extension within the /cgi-bin/
directory, you should use:
location ~* ^/cgi-bin/.*\.cgi$ { ... }
See this document for details.
Also, $fastcgi_script_name
will be set to the value of $uri
which includes the /cgi-bin/
element of the path name. So your SCRIPT_FILENAME
should probably be set to:
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;