Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dynamic IP .htaccess blocklist?

Is it possible to block users from IP adresses with a dynamic file-based blocklist?

So, suppose the .htaccess looks like:

order Deny,Allow
Deny from 123.156.0.1
Deny from 10.0.0.10
Allow from all

Can this list be made dynamic, for example:

order Deny,Allow
[include Deny list here]
Allow from all

Another option would of course be to fix it with PHP, but it is preferable to let Apache handle this.

like image 302
wspruijt Avatar asked Jul 02 '10 12:07

wspruijt


People also ask

Can dynamic IP be blocked?

SecureAuth Dynamic IP Blocking technology prevents the originating IP address from submitting requests after a specified number of failed login attempts using different usernames within a specified period of time. Instead of locking user accounts, it blocks login attempts coming from the IP address.

How to block ip in. htaccess?

Block a specific IP address Just change the IP address to the one that you want to block, and then add the code to your site's root . htaccess file.


1 Answers

According to the Apache docs, it doesn't seem to be possible to read values from a text file.

However, you could include a configuration file containing the IP addresses. They would have to be in Apache's conf file format, though.

This should work:

order Deny,Allow
include conf/IPList.conf
Allow from all

It's even possible to include whole directories, even though it's not recommended.

like image 92
Unicron Avatar answered Oct 26 '22 02:10

Unicron