nginx Basic加密:
location / {
root html;
index index.html;
auth_basic "nginx";//认证提示信息
auth_basic_user_file password;//认证的文件包含username和password
}
cd /usr/local/mybin/nginx/conf/
htpasswd -c password xiaoming
输入密码
再次输入密码
Apache Basic加密:
<Directory "/var/www/html">
AuthType Basic
AuthName "apache" #提示信息和nginx的auth_basic 一样,随便写
AuthUserFile /var/www/html/html.passwd #认证的文件和nginx的auth_basic_user_file
#注意这个密码文件一定要用绝对路径,因为这个文件不是用来访问的.
Require user tom #这里填写认证文件里的用户名
</Directory>
cd /var/www/html/
htpasswd -c html.passwd tom
输入密码
再次输入密码
Apache Digest加密:
<Directory "/var/www/html">
Options Indexes FollowSymLinks
AllowOverride None
AuthType Digest #注意这个不是Basic
AuthName "Digest Encrypt" #这个值是realm,不能像Basic验证方式一样随便写
AuthDigestProvider file
AuthUserFile /var/www/html/dig.passwd //存放 账号:realm:密码的地方
require valid-user
</Directory>
在/var/www/html/目录下
htdigest -c dig.passwd "Digest Encrypt" lw //#注意这个Digest Encrypt是realm和AuthName一样,账号为lw
输入密码
再次输入密码