I have had a lot of attacks on my server. Most start with a vulnerability scan, followed by waves of POST requests.
I will soon be implementing Cloudflare (WAF and DDos). This means that a DNS lookup on my domain will show the IP address of Cloudflare, rather than my server. So my server's IP address will be hidden in that regard.
However, attacks can still come in by going one-by-one through all the possible IPs in the world. When I look at my server logs, I can see this happens A LOT. (I have 3 IPs tied to my 1 server and the exact same attacks happen on XXX.XXX.XXX.XX1 then XXX.XXX.XXX.XX2 then XXX.XXX.XXX.XX3)
My top-level .htaccess looks like this:
# deny all POST requests
<IfModule mod_rewrite.c>
RewriteCond %{REQUEST_METHOD} POST
RewriteRule .* - [F,L]
</IfModule>
# deny unused request types
<IfModule mod_rewrite.c>
RewriteCond %{REQUEST_METHOD} ^(delete|head|trace|track) [NC]
RewriteRule .* - [F,L]
</IfModule>
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Questions:
What should I add so that [if HTTP_HOST=XXX.XXX.XXX.XX1 OR HTTP_HOST=XXX.XXX.XXX.XX2 OR HTTP_HOST=XXX.XXX.XXX.XX3] then the traffic is immediately blocked?
Can I put this new code at the top of the .htaccess? Will it break what's currently there?