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

apache Utils

– With :

yum -y install httpd-tools

– With :

apt-get install apache2-utils

Config Nginx 

location / {
auth_basic “Authen Area”;
auth_basic_user_file /home/htpasswd;

…..

}

Create User and Password

sudo htpasswd -c  /home/htpasswd gocit New password:

Re-type new password:

Adding password for user gocit

The structure of the htpasswd file would be like this

gocit:5Qez1GrzCL7Zk

Reload config Nginx

/etc/init.d/nginx reload

Access to the test page set Basic Auth. When accessed, input the username and password you set.

Print Friendly

Comments

comments

Bài viết liên quan