This post will explain how to password protect a site in nginx. It is very simple and it uses the normal htpasswd protection
Suppose I need to password protect the site greproot.com whose document root is /var/www/greproot/public_html
Simple follow the steps given below
[root@abc ~]# cd /var/www/greproot/public_html
[root@abc ~]# htpasswd -c .htpasswd admin where admin is the username chosen. It will prompt for password, give a strong password.
Now, your login details are stored to the file /var/www/greproot/public_html/.htpasswd and we need to call this file from greproot.com’s conf.
Simply add the following two lines before the locations
[root@abc ~]# cd /etc/nginx/sites-available/
[root@abc ~]# vi greproot.com
auth_basic “Restricted”;
auth_basic_user_file /var/www/g...
Recent Comments