nginx和apache 加密

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

输入密码

再次输入密码

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值