Ban IPs from a Black List in .htaccess

So, my question’s identical to the following one

Ban IPs from text file using htaccess

and I read over and tried the solution presented there but perhaps I’m missing something.

(1) My blacklist.txt contains hundreds of thousands of banned IPs. I tried to add them into .htaccess by copying and pasting them like so

Deny from 1.0.107.27
Deny from 1.0.131.123
Deny from 1.0.138.51
Deny from 1.0.193.105
...

However, the .htaccess file exceeded 5 MB and when I saved it, it caused an Error 500.

(2)

(a) So from the earlier question, it’s mentioned to add the following lines

RewriteEngine On
RewriteMap access txt:/path/to/blacklist.txt

But I guess I’m not sure where. In blacklist.txt or .htaccess?

(b) Also, I don’t really understand this code too well

RewriteEngine On 
RewriteCond ${access:%{REMOTE_ADDR}} deny [NC]
RewriteRule ^ - [L,F]

(c) My blacklist.txt is of the form

Deny from IPAddress

So what do I need to do to get my blacklist.txt working from .htaccess without getting the server to crash? I guess I’m still hazy on the complete picture.


Source: .htaccess

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.