|
|||
|
Hello,
I have a problem with the below code, searched a lot, tried a lot of alternatives, but just cannot get it to work. Code:
# Password Protect important Directories
location ~ /(admincp/|modcp/|includes/|install/) {
auth_basic "Restricted";
auth_basic_user_file /home/username/.htpasswd/passwd;
}
The above code works good enough and protects the 4 directories as desired. BUT it does not protect admincp/index.php OR any other file (in any of the folders) if directly opened. For example:- /admincp -> Is protected /admincp/ -> Is protected /admincp/index.php -> Is not protected What should I do? Thanks |
|
|||
|
The nginx location directive documentation suggests that regular expressions can be used - the following should be sufficient to protect the contents of directories:
Code:
# Password Protect important Directories
location ~ /(admincp/.*|modcp/.*|includes/.*|install/.*) {
auth_basic "Restricted";
auth_basic_user_file /home/username/.htpasswd/passwd;
}
|
![]() |
| Bookmarks |
| Tags |
| nginx, nginx password protect |
| Thread Tools | |
| Display Modes | |
|
|