網頁存取控制

來源:互聯網
上載者:User

標籤:awstats 日誌分析 網頁存取控制



首先確認安裝了httpd服務,並且能正常運行。

[[email protected] ~]# netstat -utpln |grep httpdtcp        0      0 :::80                       :::*                        LISTEN      7334/httpd          [[email protected] ~]#


限制ip地址訪問指定的網頁,比如說我們的管理頁面,讓每人都看到,會泄露資訊

  

1:限制ip的方式控制web存取權限:

   (1)    修改httpd主設定檔/usr/local/httpd/conf/httpd.conf。我是編譯安裝的,具體位置還要看個人的安裝位置。

        設定檔內的內容會因安裝方式yum或編譯,配置的行數位置有所不同,注意

428 <Directory "/usr/local/awstats/wwwroot">   ##限制資源的路徑429     Options None    430     AllowOverride None431     Order allow,deny   ##先允許後拒絕,預設拒絕432     Allow from 192.168.100.10   ##白名單,寫在這裡的IP地址或網段允許訪問限制的資源433 </Directory>

   (2)    重啟服務:

[[email protected] ~]# /etc/init.d/httpd restarthttpd is restart ok![[email protected] ~]#

   (3)    訪問驗證:

首先在ip地址為192.168.100.10的vmnet1網卡上測試:

測試192.168.100.150/index.html       訪問正常650) this.width=650;" src="https://s5.51cto.com/wyfs02/M02/9E/88/wKioL1mS6ZHCY-5qAABJdB5BsCw352.png" style="float:none;" title="1.png" alt="wKioL1mS6ZHCY-5qAABJdB5BsCw352.png" />

測試日誌分析平台:       訪問正常

650) this.width=650;" src="https://s5.51cto.com/wyfs02/M00/9E/88/wKioL1mS6ZHTDWTvAAGUNCVBd04054.png" style="float:none;" title="2.png" alt="wKioL1mS6ZHTDWTvAAGUNCVBd04054.png" />

把vmnet1的網卡切換為192.168.100.10以外的任意ip地址測試:  我調成192.168.100.200

    首先訪問192.168.100.150/index.html  訪問正常

650) this.width=650;" src="https://s4.51cto.com/wyfs02/M02/9E/9A/wKiom1mS6n-S8eB9AABFFQabRGw647.png" style="float:none;" title="3.png" alt="wKiom1mS6n-S8eB9AABFFQabRGw647.png" />


    訪問192.168.100.150/aws.html   日誌分析系統     發現沒有許可權訪問

650) this.width=650;" src="https://s4.51cto.com/wyfs02/M00/9E/88/wKioL1mS6n_ygsnbAABk1bepRQU038.png" style="float:none;" title="4.png" alt="wKioL1mS6n_ygsnbAABk1bepRQU038.png" />


這是以限制ip的方式,限制我們的敏感資源不被訪問,從而提高安全效能。我們還可以通過使用者帳號密碼認證的方式,進一步提高安全性。


2:認證方式許可權的控制:

 (1)    建立認證的使用者和密碼:

   htpasswd 是安裝apache服務時內建的工具,產生認證的使用者和密碼資訊

        格式是:htpasswd -c 產生位置  認證使用者   ##第一次產生帶 -c 是格式化輸入的意識 再添加時不需要

[[email protected] ~]# htpasswd -c /usr/local/httpd/conf/htpasswd admin   ##產生認證的使用者New password:     ##填寫密碼Re-type new password:  ##確認密碼Adding password for user admin[[email protected] ~]# htpasswd  /usr/local/httpd/conf/htpasswd user   ##再添加時候,不需要加-c 了 New password: Re-type new password: Adding password for user user[[email protected] ~]# cat /usr/local/httpd/conf/htpasswd admin:dIYknERqXv0Rwuser:Yfy65hE3syNe2##將產生的認證資訊 加入到組裡。這個組裡面的都可以訪問限制的頁面[[email protected] ~]# vi /usr/local/httpd/conf/htgroups[[email protected] ~]# cat /usr/local/httpd/conf/htgroupsadministrator:admin

    (2)    修改設定檔:

            修改httpd的主設定檔以支援認證檔案進行驗證

 

 vi /usr/local/httpd/conf/httpd.conf    428 <Directory "/usr/local/awstats/wwwroot">    429     Options None    430     AllowOverride None    431     Order allow,deny    432     Allow from 192.168.100.10    433     AuthType Basic    434     AuthName "Log analysis system"   ##登入時提示的資訊    435     AuthBasicProvider file    ##指定認證使用者檔案    436     AuthUserFile /usr/local/httpd/conf/htpasswd   #認證使用者檔案位置    437     AuthGroupFile /usr/local/httpd/conf/htgroups  ##認證使用者組    438     Require group administrator       ##認證組的名字    439 </Directory>


    (3)  重啟服務:

[[email protected] ~]# /etc/init.d/httpd restarthttpd is restart ok!

    (4)    測試:

    

當前測試機器的ip地址為192.168.100.200  

訪問192.168.100.150/index.html   正常訪問


650) this.width=650;" src="https://s3.51cto.com/wyfs02/M01/9E/9A/wKiom1mS8djAzjZ_AABKs-XK1pk170.png" style="float:none;" title="11.png" alt="wKiom1mS8djAzjZ_AABKs-XK1pk170.png" />

 訪問192.168.100.150/aws.html       無法訪問,因為我們前面設定了限制ip的策略。

650) this.width=650;" src="https://s3.51cto.com/wyfs02/M01/9E/88/wKioL1mS8diDl0bsAABgd2xCm3o759.png" style="float:none;" title="22.png" alt="wKioL1mS8diDl0bsAABgd2xCm3o759.png" />

現在把測試主機的ip地址切換成192.168.100.10   

訪問 192.168.100.150/index.html


訪問正常

650) this.width=650;" src="https://s5.51cto.com/wyfs02/M00/9E/89/wKioL1mS8qWQrQkKAABKs-XK1pk897.png" style="float:none;" title="11.png" alt="wKioL1mS8qWQrQkKAABKs-XK1pk897.png" />

訪問192.168.100.150/aws.html  

    需要驗證:

    輸入認證使用者和密碼:


650) this.width=650;" src="https://s5.51cto.com/wyfs02/M01/9E/9A/wKiom1mS8qaxBTFcAACglUfLgMA020.png" style="float:none;" title="33.png" alt="wKiom1mS8qaxBTFcAACglUfLgMA020.png" />

到達日誌分析介面   訪問正常

650) this.width=650;" src="https://s3.51cto.com/wyfs02/M02/9E/89/wKioL1mS8yjhLJPmAAG36skmma0584.png" title="ss.png" alt="wKioL1mS8yjhLJPmAAG36skmma0584.png" />




本文出自 “嚮往技術的小白” 部落格,請務必保留此出處http://lesliecheung.blog.51cto.com/12622169/1956566

網頁存取控制

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.