Place the following two entries in nginx configuration file:
auth_basic "Restricted";
auth_basic_user_file /var/www/mywebsite.com/.htpasswd;
Eg:
location / {
root /var/www/mywebsite.com;
index index.html index.htm;
auth_basic "Restricted"; #For Basic Auth
auth_basic_user_file /var/www/mywebsite.com/.htpasswd; #For Basic Auth
}
The .htpasswd must contain:
username:password
Generate the password with this command:
[root@IBM ~]#printf "USERNAME:$(openssl passwd -crypt PASSWORD)\n" >> htpasswd
Comments
Comments are not available for this entry.