CentOS 6
Sponsored Link

Nginx - Basic Auth2013/07/10

Set Basic Authentication for a page.
[1] Configure Nginx
[root@www ~]#
yum -y install httpd-tools
[root@www ~]#
vi /etc/nginx/conf.d/default.conf
# add follows in "server" section

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

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

New password:
# set password

Re-type new password:
# confirm

Adding password for user fedora
[root@www ~]#
/etc/rc.d/init.d/nginx restart

Stopping nginx: [ OK ]
Starting nginx: [ OK ]
[2] Access to the test page set Basic Auth. When accessed, input the username and password you set.
[3] Just Accessed normally.
Matched Content