nginx通过用户名密码认证登录

在server中添加如下图所示:

auth_basic “Password”;
auth_basic_user_file /usr/local/app/nginx/conf/vhosts/htpasswd;
autoindex on;

1111

htpasswd文件使用 htpasswd.py脚本生成即可。

wget http://www.iszone.cn/download/htpasswd.py

使用方法:

Usage: htpasswd.py [-c] -b filename username password

生成后记得chmod 644 htpasswd

效果如图:

11111

发表评论

邮箱地址不会被公开。