Welcome! Log In Create A New Profile

Advanced

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:
domain.com/folder/a/file
domain.com/folder/b/file
domain.com/folder/c/file

So far, the bellow is working:

location ~ /folder/(a|b|c) {
allow 1.2.3.4;
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 1.2.3.4) the call is also blocked.

Any suggestions of how I can fix this?

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

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.

Andrejs
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 310
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