Apache "SetEnvIF" list of IP Addresses read from separate file?

177 views Asked by At

I'm using Apache and .htaccess to BLOCK the IP Addresses, like this, as an example:

SetEnvIF X-Forwarded-For "110.100.*.*" DenyIP
SetEnvIF X-Forwarded-For "120.100.*.*" DenyIP
SetEnvIF X-Forwarded-For "130.100.*.*" DenyIP
SetEnvIF X-Forwarded-For "210.200.*.*" DenyIP
SetEnvIF X-Forwarded-For "220.200.*.*" DenyIP
SetEnvIF X-Forwarded-For "230.200.*.*" DenyIP
..
..
Order Deny,Allow
Deny from env=DenyIP

These are quite a lot actually, in the real file.

( Please let's don't discuss about why i'm using such approach to block the IPs via Apache. There are many reasons behind. )

Is there a way i can list the IP(s) down inside a .txt file, and then point to that file from .htaccess?


Something like this:

SetEnvIF X-Forwarded-For /var/www/html/ips.txt DenyIP

I would then be able to put the IP(s) simply line by line, in ips.txt file like this:

110.100.*.*
120.100.*.*
130.100.*.*
210.200.*.*
220.200.*.*
230.200.*.*

Because, like this is more easy (and possible) to automate the IP entries, into the .txt file.


Is this even possible? Or what is the proper approach for this please?

Thanks all :)

0

There are 0 answers