引用 | 编辑
月光
2008-03-25 06:13 |
楼主
▼ |
||
x0
吃烧饼没有不掉芝麻的,而开网站的没有不被攻击的… 奇怪了,世界上还真多无聊人士,吃饱就想如何攻击别人的网站,不知道是什么心态. 一种常见的攻击是贴广告或是莫名其妙的留言,这些都是要广告特定的 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:
由于的使用的是在 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. x0
|