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的訪問控制

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章