Our site is experiencing a denial of service attack, spam, or getting hacked. How to block IP addresses at the Apache HTTP Server (AEM Dispatcher) level?
Most Web Application Firewalls (WAF), such as mod security, can block lists of IP addresses. However, if you are running Apache HTTP Server and would like to block IP's immediately follow these steps:
Open the file in an editor and add a Location directive that blocks all offending IP's from accessing whatever URLs you want to block.
<LocationMatch "/.*"> Order Allow,Deny Allow from all SetEnvif X-Forwarded-For "10\.42\.137\.123" DenyAccess SetEnvif X-Forwarded-For "122\.6\.218\.101" DenyAccess #repeat the SetEnvlf X-Forwarded-For ... for each IP you want to block Deny from env=DenyAccess </LocationMatch>