sakana

very short memo

password authentication on nginx

I hereby demonstrate a simple procedure to set password authentication against content on nginx, which is quite similar to that of apache.

First, you need to install apache2-utils for the purpose of creating password file.

$ sudo apt-get install apache2-utils

Create password file with htpasswd command.

$ sudo htpasswd -c /home/ubuntu/wiki/.htpasswd lupin

Incorporate newly created password file into virtual host configuration.

location / {
    auth_basic "Open Sesame!";
    auth_basic_user_file /home/ubuntu/wiki/.htpasswd;
}

Reflect modified configuration into running nginx process.

$ sudo /etc/init.d/nginx reload