防止網站被抓

來源:互聯網
上載者:User

標籤:blog   http   io   os   使用   ar   檔案   sp   cti   

網站可能被同行朋友來抓站,或者ddos攻擊所以必須做出相應的策略

 

1. 使用 fail2ban

fail2ban是通過掃描log來非同步判斷是否用iptable封鎖的,所以對原系統影響比較小,而且不需要重新設定nginx。不過不知道訪問量太大是否撐得住。

首先在/etc/fail2ban/jail.conf裡加入

[http-get-dos]enabled = trueport = http,httpsfilter = nginx-bansnifferlogpath = /usr/local/nginx/logs/segmentfault.logmaxretry = 120findtime = 120bantime = 3600action = iptables[name=HTTP, port=http, protocol=tcp]

然後建立/etc/fail2ban/filter.d/nginx-bansniffer.conf,原來一個nginx的設定檔和這個類似

[Definition]failregex = <HOST> -.*- .*HTTP/1.* .* .*$ignoreregex =

最後重啟fail2ban服務即可,在上面的配置中,我們對每120秒有超過120次訪問的ip,封鎖1小時。

 

 

2. ngx-lu-waf指令碼  https://github.com/loveshell/ngx_lua_waf

nginx需要重新安裝使之支援ngx-lua模組

部署地址 http://www.ttlsa.com/nginx/nginx-modules-ngx_lua/

            http://blog.slogra.com/post-497.html

防止網站被抓

聯繫我們

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