0

As the titles suggests, I am trying to password protect all directories and sub-directories, but not the files. This is so that I can still browse through the files, and share the download links privately.

I have tried many configurations, but I can't seem to get it to work, here is the latest of many:

location ~ ^/(files|files/).*$  {
  auth_basic            "Restricted";
  auth_basic_user_file  /path/to/.htpasswd;
  autoindex on;
}

location ~ ^/files/* {
  autoindex off;
}

It is based off this post.

Thank you in advance for any responses!

1 Answers1

0

I have solved it by doing this:

location ~ /files/.*/$  {
  auth_basic            "Restricted";
  auth_basic_user_file  /path/to/.htpasswd;
  autoindex on;
}

I'm not sure why, or how it works. Next step might be to password protect the files with a username and password I can give out to people.