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.

Roger
  • 473
  • 11
  • 22

1 Answers1

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) {
Shane Madden
  • 114,520
  • 13
  • 181
  • 251