step1:
Open conf/nginx.conf file, and add some directives into locatiion / section:
location / {
auth_basic "Restricted";
auth_basic_user_file pwd;
...
}
"Restricted" word will appear in the popup dialog when you try to access the Nginx site the first time.
pwd is a file located at conf folder. Note if you type conf/pwd here, the pwd file must be located at /conf/conf folder.
step2:
Create a pwd file. Add your user name and password(plaintext).
The password should be replaced by the step3.
chenshu:770328
step3:
Install Apache2 tools.
apt-get install apache2-utils
step4:
Update password using apache2 tools.
htpasswd /usr/nginx/conf/pwd chenshu
You will be asked to input password twice.
Now the pwd file's content changed:
chenshu:$apr1$I2FIVtPG$I51oSU4eatH.tJdnmxG6K0
step5:Restart Nginx service.
service nginx restart
step6: Log in your site.
Very easy!
No comments:
Post a Comment