07/03
2015

博客被攻击闲聊

在 5 月 4 日将博客迁移到 codekk.com 所在 DigitalOcean 服务器上后,一直挺稳定,速度也快了好几倍,加上缓存基本秒开。

 

最近几天不少朋友反映打不开,本以为是 WP 利用 php5-fpm 跑在 Nginx 上的兼容问题。从 Ngxin error 日志来看主要是这两个错误

upstream timed out (110: Connection timed out) while connecting to upstream

 

recv() failed (104: Connection reset by peer) while reading response header from upstream

Google 调整了 n 遍 nginx.conf 以及 fpm conf 的参数,然后 reload nginx 及 php5-fpm restart,每次只有刚重启一会儿访问正常,一会儿之后继续如上 time out。

 

后来查看 Nginx access 日志才发现 185.62.190.79、185.62.190.190、185.62.190.191、185.62.190.203 这四个 ip 以每秒三四个的频率不断 POST 请求过来,几乎,如下:

好吧,尽然被无聊的人攻击了(第一次一定要纪念下!!!),索性把 DDOS 屏蔽加上,哦了。
后来查了下这个是一些 WordPress 常有的 Spam 问题。

 

解决方法为:
(1) 通过 iptables 屏蔽 ip
(2) 禁止访问 xmlrpc.php 文件
在 nginx 的 conf 文件中加入下面配置

location = /xmlrpc.php {
    deny all;
    access_log off; #to prevent from filling up the access log file
    error_log off; #to prevent from filling up the error log file
}

 

PS:
最近收到好几位朋友的微信捐助,感谢你们的支持,服务器的费用还受得了,如果是某些文章对你们有所帮助,很高兴,哈哈

Posted@2015-07-03 00:14:30, Filed under by

您可以使用这些 HTML 标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

6 thoughts on “博客被攻击闲聊