<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(69, 69, 69); font-family: Tahoma, Arial, Helvetica, STHeiti; font-size: 14px; line-height: 25px; ">连续几天遭遇小规模的cc攻击,虽然危害不大,但每次受到攻击都要登陆到服务器上,把一套措施重新走一遍。一次是晚上11点,一次周六,影响休息,烦人至极。<br />这几次的cc攻击,应该是来自同一个组织,因为,正巧发现这几次cc攻击在access log中留下的客户端类型都一样</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(69, 69, 69); font-family: Tahoma, Arial, Helvetica, STHeiti; font-size: 14px; line-height: 25px; ">“Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0; MyIE 3.01)Cache-Control: no-store, must-revalidate”</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(69, 69, 69); font-family: Tahoma, Arial, Helvetica, STHeiti; font-size: 14px; line-height: 25px; ">于是突发奇想,把这个类型的客户端禁止了不就可以了吗?<br />web服务器用的是nginx<br />用must-revalidate做为关键词,在nginx.conf中的 server段中添加几句</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(69, 69, 69); font-family: Tahoma, Arial, Helvetica, STHeiti; font-size: 14px; line-height: 25px; ">if ($http_user_agent ~ must-revalidate) {<br />return 503;<br />}</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(69, 69, 69); font-family: Tahoma, Arial, Helvetica, STHeiti; font-size: 14px; line-height: 25px; ">重启nginx。模拟客户端访问了一下</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(69, 69, 69); font-family: Tahoma, Arial, Helvetica, STHeiti; font-size: 14px; line-height: 25px; ">curl www.admin99.net -A “Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0; MyIE 3.01)Cache-Control: no-store, must-revalidate”</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(69, 69, 69); font-family: Tahoma, Arial, Helvetica, STHeiti; font-size: 14px; line-height: 25px; ">返回 503 Service Temporarily Unavailable<br />之所以 return 503 而不 return 403 ,是为了迷惑敌人而已。<br />返回一个503,对服务器来说影响不大,只占用一个nginx的线程而已。相对来说还是很划算的。</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(69, 69, 69); font-family: Tahoma, Arial, Helvetica, STHeiti; font-size: 14px; line-height: 25px; ">来自:http://www.admin99.net/read.php/385.htm</p>