CentOS 7
Sponsored Link

Nginx : Enable Basic Auth2015/08/18

 
Enable Basic Authentication to limit access on specific web pages.
[1] For example, set Basic Auth under the "/auth-basic" directory.
[root@www ~]#
yum -y install httpd-tools
[root@www ~]#
vi /etc/nginx/nginx.conf
# add into "server" section

        location /auth-basic {
            auth_basic            "Basic Auth";
            auth_basic_user_file  "/etc/nginx/.htpasswd";
        }

[root@www ~]#
htpasswd -c /etc/nginx/.htpasswd cent

New password:    
# set password

Re-type new password:
Adding password for user cent
[root@www ~]#
systemctl restart nginx

[2] Access to the test page with Web browser on a Client and authenticate with a user which is added with htpasswd.
[3] Just accessed.
Matched Content