apache用户验证板块,实施HTTP安全性
2009-04-11 14:03
267 查看
直接从别的论坛转过来,加入了一些讨论的,希望能够帮助到您
第1步:
我们在/var/www(apache的主页根目录)下建立一个test目录
mkdir /var/www/test
第2步
然后我们编辑httpd.conf
添加
Alias /test"/var/www/test"
<Directory "/var/www/test">
Options Indexes MultiViews
AllowOverride AuthConfig #表示进行身份验证
Order allow,deny
Allow from all
</Directory>
#AllowOverride AuthConfig 表示进行身份验证 这是关键的设置
第3步
在/var/www/test创建.htaccess文件
vi /var/www/test/.htaccess
AuthName "frank share web"
AuthType Basic
AuthUserFile /var/www/test/.htpasswd
require valid-user
#AuthName 描述,随便写
#AuthUserFile /var/www/test/.htpasswd
#require valid-user 或者 require user frank 限制是所有合法用户还是指定用户
#密码文件推荐使用.htpasswd,因为apache默认系统对“.ht”开头的文件默认不允许外部读取,安全系数会高一点哦。
第4步
就是创建apache的验证用户
htpasswd -c /var/www/test/.htpasswd frank
#第一次创建用户要用到-c 参数 第2次添加用户,就不用-c参数
如果你们想修改密码,可以如下
htpasswd -m .htpasswd frank
第5步:
ok,重启apache服务,然后访问 http://你的网站地址/test 如果顺利的话,应该能看到一个用户验证的弹出窗口,只要填入第4步创建的用户名和密码就行
后话,为了服务器的性能,一般不推荐使用AllowOverride AuthConfig或者AllowOverride ALL,因为这会使服务器会不断的去寻找.htaccess,从而影响服务器的效能,一般我们把一些后台管理界面或者其他特殊目录可能需要加验证这个需求。
如果用Mozilla访问的话就会出现上面的问题,可是,如果用IE或者其他的浏览器就没有问题,请问这是怎么回事啊?如何解决?
谢谢!
第1步:
我们在/var/www(apache的主页根目录)下建立一个test目录
mkdir /var/www/test
第2步
然后我们编辑httpd.conf
添加
Alias /test"/var/www/test"
<Directory "/var/www/test">
Options Indexes MultiViews
AllowOverride AuthConfig #表示进行身份验证
Order allow,deny
Allow from all
</Directory>
#AllowOverride AuthConfig 表示进行身份验证 这是关键的设置
第3步
在/var/www/test创建.htaccess文件
vi /var/www/test/.htaccess
AuthName "frank share web"
AuthType Basic
AuthUserFile /var/www/test/.htpasswd
require valid-user
#AuthName 描述,随便写
#AuthUserFile /var/www/test/.htpasswd
#require valid-user 或者 require user frank 限制是所有合法用户还是指定用户
#密码文件推荐使用.htpasswd,因为apache默认系统对“.ht”开头的文件默认不允许外部读取,安全系数会高一点哦。
第4步
就是创建apache的验证用户
htpasswd -c /var/www/test/.htpasswd frank
#第一次创建用户要用到-c 参数 第2次添加用户,就不用-c参数
如果你们想修改密码,可以如下
htpasswd -m .htpasswd frank
第5步:
ok,重启apache服务,然后访问 http://你的网站地址/test 如果顺利的话,应该能看到一个用户验证的弹出窗口,只要填入第4步创建的用户名和密码就行
后话,为了服务器的性能,一般不推荐使用AllowOverride AuthConfig或者AllowOverride ALL,因为这会使服务器会不断的去寻找.htaccess,从而影响服务器的效能,一般我们把一些后台管理界面或者其他特殊目录可能需要加验证这个需求。
--> 作者: guanjun 我按你的配置做但不能登入。出现如下错误: authorization required this server could not verify that you are authorized to access the document requested ,either you supplied the wrong credentials(eg: a bad passward) or your browser does not understand now to supply the credentials required apache/2.0.46(Radhat)server at localhost port 80--> |
谢谢!
相关文章推荐
- JSP开发中Apache-HTTPClient 用户验证的实例详解
- Apache-HTTPClient 用户验证实现
- Apache 用户验证
- 关于对于安全性比较高的网站对于用户验证的技术设计
- HTTP, WWW-Authenticate, Authorization 验证授权 | Apache验证 | Python处理
- 【Scikit-Learn 中文文档】交叉验证 - 模型选择和评估 - 用户指南 | ApacheCN
- 使用HttpContext的User属性来实现用户验证
- HttpModule用户的验证
- apache http server用户认证
- 使用HttpContext的User属性来实现用户身份验证
- 4.2用户登陆和安全验证(利用HttpModule集中处理身份检查)
- SpringMVC+Apache Shiro+JPA(hibernate)案例教学(四)基于Shiro验证用户权限,且给用户授权
- HTTP、POP3用户使用AD验证访问Lotus Domino
- apache discuz 用户验证
- CXF发布webService、tomcat用户验证、axis2(http/https)调用服务
- Apache HttpClient4.3.x忽略证书验证
- Apache服务器实现用户验证
- SpringMVC+Apache Shiro+JPA(hibernate)案例教学(四)基于Shiro验证用户权限,且给用户授权
- apache如何在虚拟主机中实现用户验证
- 使用HttpContext的User属性来实现用户身份验证