nginx auth_basic 비밀번호 암호화 하기

(Last Updated On: January 2, 2022)

 

printf "${username}:`openssl passwd -apr1`\n" >> .htpasswd

변수로 쓰기

username=john
password=STRONGPASSWORD123$
printf "${username}:`openssl passwd -stdin -apr1 <<< ${password}`\n" >> .htpasswd

 

 

nginx에 적용하기

location / {
auth_basic "nginx";
auth_basic_user_file /etc/nginx/.htpasswd;
...
}