5

I have different files inside three different directories.

I'd like to block access to all files inside those (also block directory listing).

This way, I'd block, for example:

  • /a/b/file

  • /a/c/file

  • /a/d/file

Whatever the file extension...

This is what I am trying:

location /a/(b|c|d) {
    allow 1.2.3.4; #IP
    deny all;
    return 403;
}

But it's not working.

1 Answer 1

5

You need ~ in your location config - without it means literal prefix matching, while you're attempting to use regex syntax.

location ~ /a/(b|c|d) {
2
  • Is the allow 1.2.3.4; #IP in the right position? Should it come after "deny all;" and "return 403"?
    – Roger
    Oct 9, 2011 at 23:00
  • Yes, the order is right: wiki.nginx.org/HttpAccessModule
    – quanta
    Oct 10, 2011 at 2:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .