linux http 访问限制,51CTO博客-专业IT技术博客创作平台-技术成就梦想

前提:

安装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

This is a test Page!!!

This is http://www.tarena.com/authdir/index.html!!!

[root@localhost ~]#vim /var/www/html/authdir/index.html //默认站点目录

This is a test Page!!!

This is http://www.tarena.com/authdir/index.html!!!

(2)修改主配置文件

[root@localhost ~]# vim /etc/httpd/conf/httpd.conf

...

306

...

332 Order allow,deny

333 # Allow from all

334 Allow from 192.168.10.5

...

337

338 Order allow,deny

339 Allow from all

340

(3)启动服务

[root@localhost ~]# service httpd restart

(4)在不同客户端测试

A:访问/var/www/html/index.html

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

c449d289df26d78982a10a8e6ae21d1a.png

用Linux客户端(IP 192.168.1.2)来访问

efb474164a9509313abeadfa06347a1f.png

B:访问/var/www/html/authdir/index.html

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

edc983f769752082818260d99eae109d.png

用Linux 客户端(IP 192.168.1.2)来访问

8921a5d280eea799ee4dd5b99a7ed377.png

总体访问控制设置成功!!!

补充:

在服务器上查看登录错误日志

root@localhost ~]# tail /var/log/httpd/tarena.com-error_log

7272575c11b05151fcbf1d138884a87c.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值