This tutorial shows how you can use basic HTTP authentication with Nginx to password-protect directories on your server or even a whole website. This is the Nginx equivalent to basic HTTP authentication on Apache with .htaccess/.htpasswd.
Read full article