免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1025 | 回复: 0
打印 上一主题 下一主题

apache用户验证板块,实施HTTP安全性 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-05-06 01:33 |只看该作者 |倒序浏览

                直接从别的论坛转过来,加入了一些讨论的,希望能够帮助到您
第1步:
我们在/var/www(apache的主页根目录)下建立一个test目录
mkdir /var/www/test
第2步
然后我们编辑httpd.conf
添加
Alias /test"/var/www/test"

Options Indexes MultiViews
AllowOverride AuthConfig #表示进行身份验证
Order allow,deny
Allow from all

#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/.thpasswd frank
#第一次创建用户要用到-c 参数 第2次添加用户,就不用-c参数
如果你们想修改密码,可以如下
htpasswd -m .htpasswd frank
第5步:
ok,重启apache服务,然后访问
http://你的网站地址/test
如果顺利的话,应该能看到一个用户验证的弹出窗口,只要填入第4步创建的用户名和密码就行
后话,为了服务器的性能,一般不推荐使用AllowOverride AuthConfig或者AllowOverride ALL,因为这会使服务器会不断的去寻找.htaccess,从而影响服务器的效能,一般我们把一些后台管理界面或者其他特殊目录可能需要加验证这个需求。
       
               
               
                        魔鬼庄园
                        03-11-19 14:08
               
               
               
                -->
不错的文章~谢谢~
       
               
               
                        escapedd
                        03-11-19 18:46
               
               
               
                -->
我来补充:
如果要对AuthUserFile中的用户再进行筛选,比如有两个用户frank,
Paul,则要在.htaccess加上
AuthGroupFile /var/www/test/.htgruop
Require group admin
其中.htgroup为用户组的文件名,文件内容格式为
admin:frank
Require group admin的意思是当用户属于admin组的时候才允许访问
       
               
               
                        petman
                        04-06-01 20:29
               
               
               
                -->
我没有按照你这样的安全配置,因为我在配置的时候跟我在同一局域网上的WINDOWS系统不能访问我的LINUX下的服务器,但却能PING得通我的机子!!不知为什么不能不能访问呢?
       
               
               
                        guanjun
                        04-07-31 11:56
               
               
               
                -->
我按你的配置做但不能登入。出现如下错误:
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
       
               
               
                        radix
                        04-09-23 12:23
               
               
               
                -->
Thank you ,i successed~!~
       
               
               
                        cupid
                        05-03-14 18:26
               
               
               
                -->
我也是跟这位兄弟一样的。

引用:
-->
作者: 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-->
如果用Mozilla访问的话就会出现上面的问题,可是,如果用IE或者其他的浏览器就没有问题,请问这是怎么回事啊?如何解决?
谢谢!
       
               
               
                        hyf003
                        05-04-14 13:30
               
               
               
                -->
上面的楼主
我也按它的做了
可是到第四步我的不执行啊
你们都是怎么做的
给个见解
haoyufu@ioz.ac.cn
       
               
               
                        sczlin
                        05-11-01 10:21
               
               
               
                -->
输入用户名和密码,出现下面提示,无法登陆
Authorization Required
This server could not verify that you are authorized to access the document requested. Either you supplied the wrong credentials (e.g., bad password), or your browser doesn't understand how to supply the credentials required.
--------------------------------------------------------------------------------
Apache/1.3.33 Server at ftp.scylzx.net Port 80
       
               
               
                        xdp4507
                        06-07-13 11:50
               
               
               
                -->
我得去配置一下,谢谢了!!
[/url]
               

本文来自ChinaUnix博客,如果查看原文请点:[url]http://blog.chinaunix.net/u3/93926/showart_1919198.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP