Linux centosVMware Apache 配置防盜鏈、訪問控制Directory、訪問控制FilesMatch

1、配置防盜鏈php

經過限制referer來實現防盜鏈的功能apache

配置文件增長以下內容vim

vim /usr/local/apache2.4/conf/extra/httpd-vhosts.conf //改成以下curl

 

[root@davery ~]# curl -x127.0.0.1:80 -e "http://www.111.com/0.mp3" http://www.111.com/davery.mp3 -I 訪問.mp3格式就會被屏蔽測試

 

[root@davery ~]# curl -x127.0.0.1:80 -e "http://www.111.com/123.php" http://www.111.com/index.php -I 訪問網頁就不會被屏蔽url

 

 

2、 訪問控制Directoryspa

只容許127.0.0.1訪問,不容許192.168.1.101訪問3d

核心配置文件內容blog

<Directory /data/wwwroot/www.111.com/admin/>配置

Order deny,allow

Deny from all

Allow from 127.0.0.1

</Directory>

 

建立一個davery

[root@davery ~]# mkdir /data/wwwroot/www.111.com/davery

[root@davery ~]# vim /data/wwwroot/www.111.com/davery/index.php

[root@davery ~]# cat /data/wwwroot/www.111.com/davery/index.php

 

 curl測試127.0.0.1  IP是能夠訪問到

 

測試192.168.1.101就不能訪問到

 

 

3、訪問控制FilesMatch,單獨針對某個文件來作限制

核心配置文件內容:限制davery/index.php

<Directory /data/wwwroot/www.111.com>

<FilesMatch "davery/index.php(.*)">

Order deny,allow

Deny from all

Allow from 127.0.0.1·

</FilesMatch>

</Directory>

 

原127.0.0.1是能夠訪問到

192.168.1.101就不能夠訪問到

相關文章
相關標籤/搜索