HTTP的访问控制

前提:
安装Apache httpd服务,分别在默认站点目录/var/www/html/下创建并编辑index.html和mkdir 后的/var/www/html/authdir新站点下创建并编辑index.html

试验目的:
只允许192.168.1.1访问www.tarena.com
允许所有用户访问www.tarena.com/authdir/index.html
步骤:
(1)修改站点目录
[root@localhost ~]# mkdir /var/www/html/authdir //创建新站点目录
[root@localhost ~]#vim /var/www/html/authdir/index.html
<html>
<head><title>This is a test Page!!!</title>
<body>
<h1>This is http://www.tarena.com/authdir/index.html!!!</h1&gt;
</body>
</html>

[root@localhost ~]#vim /var/www/html/authdir/index.html //默认站点目录
<html>
<head><title>This is a test Page!!!</title>
<body>
<h1>This is http://www.tarena.com/authdir/index.html!!!</h1&gt;
</body>
</html>
(2)修改主配置文件
[root@localhost ~]# vim /etc/httpd/conf/httpd.conf
...
306 <Directory "/var/www/html">
...
332 Order allow,deny
333 # Allow from all
334 Allow from 192.168.10.5
...
337 <Directory "/var/www/html/authdir">
338 Order allow,deny
339 Allow from all
340 </Directory>
(3)启动服务
[root@localhost ~]# service httpd restart
(4)在不同客户端测试
A:访问/var/www/html/index.html

        用Win 7客户端(IP 192.168.1.1)来访问

HTTP的访问控制
用Linux客户端(IP 192.168.1.2)来访问
HTTP的访问控制
B:访问/var/www/html/authdir/index.html
用Win 7客户端(IP 192.168.1.1)来访问
HTTP的访问控制
用Linux 客户端(IP 192.168.1.2)来访问
HTTP的访问控制
总体访问控制设置成功!!!
补充:
在服务器上查看登录错误日志
root@localhost ~]# tail /var/log/httpd/tarena.com-error_log
HTTP的访问控制

转载于:https://blog.51cto.com/zhangguangjun/2053972

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值