[root@2a2d6ffd4d79 nginx]# printf "test:$(openssl passwd 1234567890)" > .passwd # 這樣只能生成最長8位的密碼
Warning: truncating password to 8 characters
printf "test:$(openssl passwd -5 1234567890123456@Aab)" > .passwd # 這樣可以突破8位密碼長度
下面可以使靜態(tài)服務(wù)器增加密碼驗(yàn)證
location /static {
alias /srv/http/statics;
autoindex on;
auth_basic "DW Center";
auth_basic_user_file /etc/nginx/.passwd;
}