I have the following location block in my NGINX server block:
location ~ ^/admin {
auth_basic "Restricted";
auth_basic_user_file /etc/nginx/.htpasswd;
if (!-e $request_filename){
rewrite ^(.*)$ /index.php?uri=$1;
}
}
But it doesn't work. The /etc/nginx/.htpasswd file exists and was generated using the htpasswd command:
sudo htpasswd -c /etc/nginx/.htpasswd admin
I've done this before but it just stopped working this time. The only difference this time is that I'm trying to do auth_basic_user_file inside of a rewrite block this time.