FreeBSD, Nginx and htpasswd file generation

On most Linux distros it is possible to generate the htpasswd file entries simply using the htpasswd command line util. On FreeBSD the easiest way to accomplish the same task is using OpenSSL itself: openssl passwd -apr1 Enter the password twice to get a nice hash, copy that in the htpasswd file with the usual user:password_hash syntax.

Posted on

Nginx and password protected pages

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

Posted on