Generate htpasswd for nginx with openssl

There’s no need to have apache utils or tools to generate a Basic authentication password for nginx. Type the following in bash and replace user with the username you want:

printf "user:`openssl passwd -apr1`\n" >> /etc/nginx/.htpasswd

Leave a Reply

Your email address will not be published.