Does nginx have a directive analogous to Apache's <Directory>?


I’m trying to set up an nginx server to replace our current setup
based on Apache. Our users have password protected directories (with
directives in .htaccess files) which we need to keep protected in the
new setup.

As far as I can see, nginx doesn’t have a Directory directive, but
only a Location directive, which refers to URIs instead of file system
paths. This means that if a directory is reachable through more than
one URL, I have to include them all in one or more Location
directives. For example:, root: /home/user/public_html, root: /home/user/public_html/sub

If user protects (directory
/home/user/public_html/sub/admin) I must make sure that both /admin in and /sub/admin in are protected with the
same password file. I’d rather protect the directory itself, and not
every URL through which visitors can access its contents.

So, does nginx have any mechanism that allows to refer to file system
paths in configuration files, like Apache’s blocks do?

Thank you.


Juan R. Pozo -

No it doesn’t. You will need to specify all the locations.

Posted at Nginx Forum: