Welcome! Log In Create A New Profile


Blocking files inside some directories...

Posted by atipico 
Blocking files inside some directories...
October 10, 2011 02:03PM
I have different files inside three different directories.

I'd like to block access to all files inside those whatever the file extension (and also block directory listing).

For example:

So far, the bellow is working:

location ~ /folder/(a|b|c) {
deny all;
return 403;

However, it is also blocking the access to files on domain.com/folder/ (which I don't want). Besides, when I make a simples ajax call for some php file inside one of the blocked folders (from some of the sites hosted on the IP the call is also blocked.

Any suggestions of how I can fix this?

Re: Blocking files inside some directories...
October 11, 2011 06:05AM
Re: Blocking files inside some directories...
October 16, 2011 05:43PM

It shouldn't block access to folder itself. Perhaps, auto-indexing is disabled and you're trying to access /folder URL without explicitly specifying the document. Anyway, here the test configuration you posted works OK (nginx/1.1.4)

As to why PHP files don't work work inside /folder -- no idea, post your entire nginx.conf so we could take a look.

Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 246
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready