To create the htpasswd
file along with its first user, I just:
htpasswd -c /path/to/htpasswdfile/htpasswd some-user
It’ll ask you for the password for that user, encrypt it and store it in that location.
Add these lines to get Nginx to use the file for basic auth:
auth_basic "Login to Proceed: "; #(or whatever message you want)
auth_basic_user_file /path/to/htpasswdfile/htpasswd;
To append another user to the htpasswd
file do:
htpasswd /path/to/htpasswd/htpasswd second-user
That ought to do it.
P.S. Install apache-utils
on Debian or use Paru/Yay to install nginx_passwd
on Arch.
Feedback on this post? Mail me at feedback@janusworx.com
P.P.S. Subscribe to my mailing list!
Forward these posts and letters to your friends and get them to subscribe!
P.P.P.S. Feed my insatiable reading habit.