Cannot password protect Nginx subdirectory
March 25, 2020 02:21PM
I'm trying to set a username/password protection on an Nginx subdirectory, but I'm still able to access the subdirectory without supplying credentials.

The Nginx is running on an AWS CentOS 7 instance.
My default.conf is:

[centos@ip-172-31-35-133 nginx]$ cat /etc/nginx/conf.d/default.conf
server {

location /rbarark_test {
satisfy any;

root /usr/share/nginx/html;
index index.html index.htm;
auth_basic "Restricted area - This system is for the use of authorized users only!";
auth_basic_user_file /etc/nginx/.htpasswd;
[centos@ip-172-31-35-133 nginx]$

I added a username/password entry to .htpasswd:

[centos@ip-172-31-35-133 nginx]$ ls -ls /etc/nginx/.htpasswd
4 -rw-r--r--. 1 root root 45 Mar 24 23:39 /etc/nginx/.htpasswd
[centos@ip-172-31-35-133 nginx]$

And all the web-site files are at:

[centos@ip-172-31-35-133 nginx]$ ls /usr/share/nginx/html/rbarak_test/en/
amazon-dynamodb-audit-integration-guide.html cockroachdb-integration-guide.html jsonar--solutions-for-agentless-oracle-db-auditing.html os-auditing-solution.html
amazon-redshift-audit-integration-guide.html cockroach-integration-guide.html mongodb-atlas-integration-guide-157488.html params.manifest
aws-auditing-initial-setup.html db-auditing-solution.html mongodb-atlas-integration-guide.html postgresql-integration-guides.html
aws-integration-guides.html dispatcher-rdbms-oracle-prerequisites.html mongodb-integration-guides.html snowflake-integration-guide.html
aws-rds-audit-integration-guide-156347.html glossary.html ms-sql-integration-guides.html sso-with-pingfederate.html
aws-rds-audit-integration-guide.html image mysql-integration-guides.html teradata-integration-guide.html
aws-rds-integration-guide.html index-en.html oracle-audit-vault.html toc-en.html
cloudera-integration-guides.html js oracle-integration-guides.html unified-auditing-solution.html
[centos@ip-172-31-35-133 nginx]$

But still, when I connect my browser to, I'm not challenged to give a username/password.

Can you see what am I doing wrong?
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 109
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready