Nginx and password protected pages · uwot.eu
another meaningless subtitle

Nginx and password protected pages

· by fabio · Read in about 1 min · (66 Words)
CentOS htpasswd ngnx password protected directory

To password protect a directory “xyz” and every file and subdirectory in it open the configuration file (nginx.conf or one of the virtual host configuration files) and add the following two lines:

location /xyz/ {
   auth_basic            "Restricted Area";
   auth_basic_user_file  conf.d/htpasswd;
}

htpasswd file must be encrypted, it can be created using a tool named htpasswd.

[root@xenserver ~]# cd /etc/nginx/conf.d/
[root@xenserver ~]# htpasswd -b htpasswd user password