Apache 2.4 存取控制;

來源:互聯網
上載者:User

標籤:ip地址   網路   

2.2當中的存取控制:

AllowOveried    None    //是否禁用控制功能;

Order

Allow Deny    //不允許的都拒絕,Deny Allow表示不拒絕都允許;

Allow

IPADDR    //允許的IP列表;

Deny

IPADDR    //拒絕的IP列表;


PS:列表的IP可以使用IP段或者IP地址;


Apache 2.4存取控制:

通過<RequireAll></RequireAll>來進行控制,一下給出樣本;


<Dricetory /var/www/html>

    <RequireAll>

        Require all granted    //允許所有訪問;

        Require all denied    //拒絕所有訪問;

        Require ip IPADDR    //允許IP列表;

        Require not ip IPADDR    //拒絕IP列表;

        Require host HostName    //允許各別HostName訪問;

    </RequireAll>


以下是轉自網路http://www.cnblogs.com/leoyu/p/apache24_use_require_for_access_control_by_ip_and_useragent.html;


例6:允許所有訪問請求,但拒絕某些User-Agent的訪問請求(通過User-Agent屏蔽垃圾網路爬蟲)

使用mod_setenvif通過Regex匹配來訪請求的User-Agent,並設定內部環境變數BADBOT,最後拒絕BADBOT的訪問請求。

Apache2.4下的配置:

650) this.width=650;" src="http://common.cnblogs.com/images/copycode.gif" alt="複製代碼" />

<Directory xxx/www/yoursite>     SetEnvIfNoCase User-Agent ".*(FeedDemon|JikeSpider|AskTbFXTV|CrawlDaddy|Feedly|Swiftbot|ZmEu|oBot).*" BADBOT    SetEnvIfNoCase User-Agent "brandwatch" BADBOT    SetEnvIfNoCase User-Agent "rogerbot" BADBOT    <RequireAll>        Require all granted        Require not env BADBOT        Require not ip 192.168.100.1    </RequireAll> </Directory>

其它require存取控制指令用法如下:

650) this.width=650;" src="http://common.cnblogs.com/images/copycode.gif" alt="複製代碼" />

Require all granted #允許所有Require all denied #拒絕所有Require env env-var [env-var] ... #允許匹配環境變數中任意一個Require method http-method [http-method] ... #允許特定的HTTP方法(GET/POST/HEAD/OPTIONS)Require expr expression #允許,運算式為trueRequire user userid [ userid ] ... #允許特定使用者Require group group-name [group-name] ... #允許特定使用者組Require valid-user # #允許,有效使用者Require ip 192.100 192.168.100 192.168.100.5 #允許特定IP或IP段,多個IP或IP段間使用空格分隔

Apache 2.4 存取控制;

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.