nginx rules to deny php/perl execution

António P. P. Almeida appa at
Sat Nov 20 22:14:32 MSK 2010

On 20 Nov 2010 19h00 WET, appa at wrote:

> On 20 Nov 2010 18h39 WET, nginx-forum at wrote:
>> Hello,
>> I have some directories (cache, static, etc) that denies execution
>> of some files.  In these directories I have a .htaccess file with
>> this rule:
>> Order allow,deny
>> Deny from all
>> I would like to test nginx with php-fpm but I don't know how to
>> rewrite these rules in nginx Can someone help me?

Also add this as your *last* location directive:

location ~* \.(?:php|pl)$ {
   return 404; # or 403 if you prefer.

Note that you should have defined the locations where it's "legal" to
handle PHP and Perl before.

--- appa

More information about the nginx mailing list