Scale up as you grow — whether you're running one virtual machine or ten thousand.

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.

This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Any problems with use of htaccess method?
<files xmlrpc.php> order allow,deny deny from all </files>
[]'s
XML-RPC DDoS Protection for Web Servers with ModSecurity and Iptables
Victim’s Web Server under XML-RPC DDoS attack:
213.189.55.149 victim.com- [29/Jun/2015:12:50:35 +0700] "GET /index.php HTTP/1.0" 400 1905 "-" "WordPress/3.9.6; http://www.gamesbase24.com; verifying pingback from 54.169.67.213" 5.001
194.58.92.216 victim.com - [29/Jun/2015:13:11:51 +0700] "GET / HTTP/1.0" 400 1905 "-" "WordPress/3.5; http://mygoldpartners.ru" 5.001
Mitigation
ModSecurity rule:
SecAction "id:1,phase:1,t:none,pass,nolog,initcol:global=global,initcol:ip=%{remote_addr}"
SecRule REQUEST_HEADERS:User-Agent "(wordpress|pingback)" "id:12,phase:1,t:lowercase,exec:/etc/exec/pingback.sh,deny,status:400"
#!/bin/bash
/bin/echo +$REMOTE_ADDR >/proc/net/xt_recent/PINGBACK
Iptables rule:
-A INPUT -p tcp -m tcp --dport 80 -m recent --update --seconds 2592000 --hitcount 1 --name PINGBACK --rsource -j DROP
If you are using Nginx, add it to VirtualHost config
if ($http_user_agent ~* (WorPress|pingback) ) {
return 444;
}
Blocking XML-RPC is a great move for 99% of WordPress sites. However, installing the Jetpack plugin is generally a bad idea and will cause added performance and security issues.
https://www.littlebizzy.com/blog/disable-xml-rpc
location = /xmlrpc.php {
deny all;
}
The above “equals” sign may be necessary to deny requests to the xmlrpc.php file, and is truly the only smart way to disable it. Plugins and application-level blocking is only asking for trouble as it can be circumvented, depends on your site stability, and so forth.
So far our site was attacked from a small number of IPs, not a full-scale botnet, and we’ve had one short interval of downtime. So instead, I blocked more than 2 consecutive retries using fail2ban with a long bantime, only slightly modified from an answer on stackoverflow or somewhere similar:
/etc/fail2ban/filter.d/xmlrpc.conf (new file)
[Definition]
failregex = ^<HOST> .*POST .*xmlrpc\.php.*
ignoreregex =
/etc/fail2ban/jail.local (appended to the existing file)
[xmlrpc]
enabled = true
filter = xmlrpc
action = iptables[name=xmlrpc, port=http, protocol=tcp]
logpath = /var/log/apache2/access.log
bantime = 600000
maxretry = 2
findtime = 6000
This works like a charm. The question is: is this a robust enough solution if our traffic scales up? I wnated to avoid blocking the file completely as it might be important for WP functionality.
Hi,
I suspect the method 2 “Enabling block-xmlrpc with a2enconf” does not work!
These are the steps I did. Step 1. Rebuilt my droplet with “One-Click Install WordPress on Ubuntu 14.04”. Step 2. Updated Ubuntu Step 3. Setup wordpress Step 4. Run “sudo a2enconf block-xmlrpc”, I got these warnings:
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LC_CTYPE = "UTF-8",
LANG = "en_US.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
Enabling conf block-xmlrpc.
To activate the new configuration, you need to run:
service apache2 reload
Please note that there is “Enabling conf block-xmlpc”.
Step 5. After some hours, I still got http status code of 200. First 6 entries are listed below. Two of them are 200. Others are 301.
5.178.68.254 - - [10/Mar/2016:11:46:01 -0500] "POST /xmlrpc.php HTTP/1.1" 301 573 "http://bb.com/xmlrpc.php" "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.11) Gecko/20070502 Firefox/1.5.0.11 Flock/0.7.13.1"
5.178.68.254 - - [10/Mar/2016:11:46:42 -0500] "POST / HTTP/1.1" 200 6163 "http://bb.com/xmlrpc.php" "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.11) Gecko/20070502 Firefox/1.5.0.11 Flock/0.7.13.1"
89.47.29.92 - - [10/Mar/2016:12:21:53 -0500] "POST /xmlrpc.php HTTP/1.0" 301 524 "http://www.hh.com/" "PHP/5.2.03"
75.103.70.22 - - [10/Mar/2016:15:20:45 -0500] "POST /xmlrpc.php HTTP/1.0" 301 512 "-" "-"
5.178.68.254 - - [10/Mar/2016:15:38:58 -0500] "POST /xmlrpc.php HTTP/1.1" 301 573 "http://bb.com/xmlrpc.php" "Mozilla/5.0 (X11; U; Linux x86_64; es-ES; rv:1.9.1.8) Gecko/20100216 Fedora/3.5.8-1.fc11 Firefox/3.5.8"
5.178.68.254 - - [10/Mar/2016:15:39:44 -0500] "POST / HTTP/1.1" 200 6165 "http://bb.com/xmlrpc.php" "Mozilla/5.0 (X11; U; Linux x86_64; es-ES; rv:1.9.1.8) Gecko/20100216 Fedora/3.5.8-1.fc11 Firefox/3.5.8"
(I changed the domain names above for privacy reason.)
Step 6. Finally I rebuilt the droplet again, and this time with method 3 “Manually Blocking All XML-RPC Traffic”. Now all I got are 403.
My question is: Does method 2 work? It seems it is NOT working! I created a ticket for support and they also believe it is not working too.
ps: I tried many fixes to locale warning, but the problem is still there.
You can also install the iQ Block Country plugin. This allows you to deny requests to xmlrpc.php but also to your entire backend. You can allow only your own country for instance. Or block all countries and only allow your own ip address(es).
You can also block countries from visiting your frontend. So if you need some kind of geo fencing around your content you can do this. Or perhaps you just get a lot of spammy comments on your blogs from certain countries then you can block these as well.
I have followed the step 3 and I still having the same issue :S. I have the problem as I can see in my log file, and also everytime I restart the server the website works for some seconds but back the message “Error establishing a database connection”. Any idea what is going on with this?
An easy temporary fix is to IP ban all the offenders.
First get their IPs:
fgrep '"POST /xmlrpc.php HTTP/1.0" 200 791 "-" "Mozilla/4.0 (compatible: MSIE 7.0; Windows NT 6.0)"' /var/log/apache2/access.log | cut -d' ' -f1 | sort | uniq
159.122.224.173 185.103.252.170 185.130.4.120 185.130.4.197 185.82.202.52 5.196.199.230
Then ban them:
iptables -I INPUT -s 159.122.224.173 -j DROP
etc
Method 3 worked great for me, thanks! I am not too linux savvy but the one additional step I had to do to get it to work was restart MySQL altogether…“service mysql stop” then “service mysql start”.
Thank god for this tutorial, I was losing a bunch of money with my web site down.
hi dear i can’t access my droplet it shows as power on but in ping status of server ip address giving request time out :( please help me to how to fix it as soon as possible :(