Block IP addresses in Apache 2.4

Apache 2.4 has a different syntax for blocking IP addresses of scammers and spammers than old 2.2, and using the old syntax does even cause ”Internal Server Error” on some hosts. So don’t write like ”deny from 14.102.146.52” and do like below instead.

Even unsuccessful spam/exploit attempts drain server resources, so a good blacklist gives a potential performance boost that also helps SEO.

Since I give zero fucks about the feelings of scammers and spammers, the following is a live example that works on Loopia.

<RequireAll>
	Require all granted
	Require not ip 23.99.229.218
	Require not ip 34.65.234.0
	Require not ip 45.120.69.121
	Require not ip 51.91.220.143
	Require not ip 52.166.3.59
	Require not ip 67.205.39.9
	Require not ip 89.34.17.35
	Require not ip 104.41.221.5
	Require not ip 106.15.38.206
	Require not ip 138.68.140.0
	Require not ip 159.203.120.246
	Require not ip 159.223.170.181
	Require not ip 167.71.141.164
	Require not ip 171.244.0.91
	Require not ip 185.2.4.134
	Require not ip 187.32.211.193
	Require not ip 188.165.198.224
	Require not ip 2001:41d0:303:ce33::
	Require not ip 2400:6180:0:d0::100e:b001
	Require not ip 2400:6180:100:d0::87b:3001
	Require not ip 2607:f298:5:102f::ce4:31b9
	Require not ip 2a00:1a28:155d:1f5::1
</RequireAll>

Publicerat av Lukas Mattsson

Yogi and developer