博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
11.26 访问控制Directory
阅读量:6906 次
发布时间:2019-06-27

本文共 1775 字,大约阅读时间需要 5 分钟。

hot3.png

访问控制 – Directory目录概要

  • 核心配置文件内容
Order deny,allow Deny from all Allow from 127.0.0.1
  • curl测试状态码为403则被限制访问了

访问控制

  1. 打开虚拟主机配置文件
  • Order,用来定义顺序,是先deny,还是allow
    • 若是先deny,就先执行deny的语句
    • 若是先allow,就先执行allow的语句
    • 特殊性:
      • 不管IP是否匹配到,它都会从头到尾执行完
[root@hf-01 ~]# vim /usr/local/apache2.4/conf/extra/httpd-vhosts.conf将代码放在防盗链代码上面,防止冲突  
Order deny,allow Deny from all Allow from 127.0.0.1
  1. 创建一个admin目录,并新建一个index.php文件,内容为121212
[root@hf-01 ~]# cd /data/wwwroot/111.com[root@hf-01 111.com]# ls11.png  123.php  [root@hf-01 111.com]# mkdir admin/[root@hf-01 111.com]# cd admin/[root@hf-01 admin]# ls[root@hf-01 admin]# touch index.php[root@hf-01 admin]# echo "121212" > index.php[root@hf-01 admin]# lsindex.php[root@hf-01 admin]# cat index.php121212[root@hf-01 admin]# cd ..[root@hf-01 111.com]#
  1. 检查语法错误,并重新加载配置文件
[root@hf-01 111.com]# /usr/local/apache2.4/bin/apachectl -tSyntax OK[root@hf-01 111.com]# /usr/local/apache2.4/bin/apachectl graceful[root@hf-01 111.com]#
  1. 限制的原 IP
  • curl -x127.0.0.1:80 111.com/admin/index.php -I
    • 127.0.0.1是目标 IP ,而要访问的IP,也要使用127.0.0.1去访问,最终就是目标IP和原IP是同一个IP,自己和自己通信,限制IP是 原 IP
    • -x指定的是目标IP
[root@hf-01 111.com]# curl -x127.0.0.1:80 111.com/admin/index.php -IHTTP/1.1 200 OKDate: Mon, 25 Dec 2017 23:42:01 GMTServer: Apache/2.4.29 (Unix) PHP/5.6.30X-Powered-By: PHP/5.6.30Content-Type: text/html; charset=UTF-8[root@hf-01 111.com]#
  1. 在更换目标IP,那么原IP也会跟着变化
[root@hf-01 111.com]# curl -x192.168.74.150:80 111.com/admin/index.php -IHTTP/1.1 403 ForbiddenDate: Mon, 25 Dec 2017 23:47:06 GMTServer: Apache/2.4.29 (Unix) PHP/5.6.30Content-Type: text/html; charset=iso-8859-1[root@hf-01 111.com]#
  1. 浏览器访问111.com/admin会显示forbidden

输入图片说明

  • 访问控制是用目录的形式来做的,首先规定一个目录访问到哪里去的(目录必须使用绝对路径),然后是Oerder,控制的对象就是来源IP

转载于:https://my.oschina.net/u/3707314/blog/1593441

你可能感兴趣的文章
PS命令
查看>>
IP地址规划
查看>>
在ssh项目中导出excel
查看>>
struts-上传
查看>>
javascript的for in
查看>>
MongoDB通过Save修改数据
查看>>
大容量导入和导出数据 -- 介绍
查看>>
我的友情链接
查看>>
第三次作业
查看>>
基于MariaDB-10 半同步复制数据的配置解析
查看>>
关于虚拟机安装linux的发生的网络不通的问题。及解决方案
查看>>
Memcache的简单笔记
查看>>
忘记密码
查看>>
CentOS虚拟机静态IP配置过程及问题分析
查看>>
第一天 css学习
查看>>
linux sort(每日一令之二十二)
查看>>
Cisco Plus 大会资料
查看>>
用thinkphp做的留言板
查看>>
让scanf()接收空格
查看>>
我的友情链接
查看>>