block access to a file !!

Francis Daly francis at
Wed Jun 6 13:41:08 UTC 2012

On Wed, Jun 06, 2012 at 09:22:50AM -0400, torajx wrote:

Hi there,

> it must be a piece of cake but i can not find a soloution...
> the problem is " location admin.php". you can check it below...

No, the problem is "location ~ admin.php" coming after "location ~
\.php$". The exact characters matter.

> i just want to allow access to admin.php to some ip address and deny
> others.

Either use something like "location = /admin.php", or maybe reorder to
regex locations (with ~) so they match in the order you want.

You will (probably) want to repeat your fastcgi_pass and other fastcgi_*
config lines inside the new location block. One request is handled by
one location.

Good luck with it,

Francis Daly        francis at

More information about the nginx mailing list