广告广告
  加入我的最爱 设为首页 风格修改
首页 首尾
 手机版   订阅   地图  繁体 
您是第 6089 个阅读者
 
发表文章 发表投票 回覆文章
  可列印版   加为IE收藏   收藏主题   上一主题 | 下一主题   
月光 手机
个人头像
个人文章 个人相簿 个人日记 个人地图
社区建设奖
头衔:看我代替月亮惩罚你!看我代替月亮惩罚你!
版主
级别: 版主 该用户目前不上站
版区: Unix-like, 网站架设
推文 x42 鲜花 x565
分享: 转寄此文章 Facebook Plurk Twitter 复制连结到剪贴簿 转换为繁体 转换为简体 载入图片
推文 x0
[教学] Apache 防制 DoS 攻击的 mod_dosevasive 模组
吃烧饼没有不掉芝麻的,而开网站的没有不被攻击的… 奇怪了,世界上还真多无聊人士,吃饱就想如何攻击别人的网站,不知道是什么心态. 一种常见的攻击是贴广告或是莫名其妙的留言,这些都是要广告特定的 URL,这种攻击在 WordPress 的网站用 Spam Karma 就可以有效对付;另有一种刻意要瘫痪网站的攻击,常见的作法就是发动很多很多的用户端要求,持续让网站穷于应付,用掉资源(CPU的资源,socket的资源,频宽的资源…),而使得网站无法服务正常的使用者,这就是所谓的 DoS — Denial of Service 攻击,我翻译为阻绝服务攻击。

本格平常好好的经营,也没作什么坏事,但却碰过好几次 DoS 攻击,IP 的来源是中国及俄罗斯 . 针对 DoS 攻击,官方的 Apache 本身并没有提供解决之道,现在找到的是一个 3rd party 的模组,mod_evasive,用以下原理防治: Detection is performed by creating an internal dynamic hash table of IP Addresses and URIs, and denying any single IP address from any of the following:
  • Requesting the same page more than a few times per second
  • Making more than n concurrent requests on the same child per second
  • Making any requests while temporarily blacklisted (on a blocking list)
它的 README 写对付 DDoS — Distributed DoS 也有效,可是由这几点看不出来如何有效。
由于的使用的是在 Vista (Win32)上的 Apache,要把上面的程式 compile 出来也是很麻烦,幸好在 这里 有 mod_dosevasive Win32 binary for Apache 2.2,可以找到一个叫 dosevasive.zip 的档案。
用法也蛮简单的,先载入模组,在 httpd.conf 加入
LoadModule dosevasive22_module modules/mod_dosevasive22.dll
就好了,参数都有预设值,如果要微调,在 httpd.conf 加入:
复制程式
<ifmodule dosevasive22_module>
DOSHashTableSize 3097
DOSPageCount 2
DOSSiteCount 50
DOSPageInterval 1
DOSSiteInterval 1
DOSBlockingPeriod 10
</ifmodule> 
在作各参数微调,请自己看看以下说明,就不逐条翻译了。



DOSHashTableSize
—————-
The hash table size defines the number of top-level nodes for each child’s
hash table. Increasing this number will provide faster performance by
decreasing the number of iterations required to get to the record, but
consume more memory for table space. You should increase this if you have
a busy web server. The value you specify will automatically be tiered up to
the next prime number in the primes list (see mod_evasive.c for a list
of primes used).
DOSPageCount
————
This is the threshhold for the number of requests for the same page (or URI)
per page interval. Once the threshhold for that interval has been exceeded,
the IP address of the client will be added to the blocking list.
DOSSiteCount
————
This is the threshhold for the total number of requests for any object by
the same client on the same listener per site interval. Once the threshhold
for that interval has been exceeded, the IP address of the client will be added
to the blocking list.
DOSPageInterval
—————
The interval for the page count threshhold; defaults to 1 second intervals.
DOSSiteInterval
—————
The interval for the site count threshhold; defaults to 1 second intervals.
DOSBlockingPeriod
—————–
The blocking period is the amount of time (in seconds) that a client will be
blocked for if they are added to the blocking list. During this time, all
subsequent requests from the client will result in a 403 (Forbidden) and
the timer being reset (e.g. another 10 seconds). Since the timer is reset
for every subsequent request, it is not necessary to have a long blocking
period; in the event of a DoS attack, this timer will keep getting reset.
WHITELISTING IP ADDRESSES
IP addresses of trusted clients can be whitelisted to insure they are never
denied. The purpose of whitelisting is to protect software, scripts, local
searchbots, or other automated tools from being denied for requesting large
amounts of data from the server. Whitelisting should *not* be used to add
customer lists or anything of the sort, as this will open the server to abuse.
This module is very difficult to trigger without performing some type of
malicious attack, and for that reason it is more appropriate to allow the
module to decide on its own whether or not an individual customer should be
blocked.
To whitelist an address (or range) add an entry to the Apache configuration
in the following fashion:
DOSWhitelist 127.0.0.1
DOSWhitelist 127.0.0.*
Wildcards can be used on up to the last 3 octets if necessary. Multiple
DOSWhitelist commands may be used in the configuration.



月光论坛
http://bbs.dj...com/


===================================
赞助本站 -- 刊登广告 -- 物超所值虚拟主机租用
献花 x0 回到顶端 [楼 主] From:台湾中华电信HINET | Posted:2008-03-25 06:13 |
lapklaman
个人文章 个人相簿 个人日记 个人地图
小有名气
级别: 小有名气 该用户目前不上站
推文 x3 鲜花 x427
分享: 转寄此文章 Facebook Plurk Twitter 复制连结到剪贴簿 转换为繁体 转换为简体 载入图片

谢谢大大的分享


献花 x0 回到顶端 [1 楼] From:台湾中华电信 | Posted:2010-03-10 16:07 |

首页  发表文章 发表投票 回覆文章
Powered by PHPWind v1.3.6
Copyright © 2003-04 PHPWind
Processed in 0.012922 second(s),query:16 Gzip disabled
本站由 瀛睿律师事务所 担任常年法律顾问 | 免责声明 | 本网站已依台湾网站内容分级规定处理 | 连络我们 | 访客留言