WordPress installations are very common targets of brute force attacks. With this attacks, attacker tries countless username and password variations in order to guess login informations. As you can imagine that such abusive behavior on your WordPress can cause collapse of server. Very common are attacks on wp-login.php and xmlrpc.php. There is a simple way to limit allowed number of requests on specific file with limit_req. This module can limit processing rate of requests coming from a single IP address on your web server.
In order to protect your WordPress administration you can do something like this:
# prevent brute force attacks on wp-login.php location = /wp-login.php { limit_req zone=one burst=5 nodelay; include fastcgi_params; fastcgi_pass 127.0.0.1:9000; }
This will allow 5 request in 5 second “window”. When there’ll be more than 5 request in 5 seconds, Nginx will return 503 error until request rate slows down:
$ curl -I https://www.yourwebsite.com/wp-login.php HTTP/1.1 503 Service Temporarily Unavailable Server: nginx Of course, you can use limit_req to protect other systems besides WordPress to.
Recent Comments