RewriteMap to Block IP Addresses
3 posts
• Page 1 of 1
RewriteMap to Block IP Addresses
Hello,
My hosting provider says that Helicontech, the company that makes ISAPI Rewrite suggests that you have no more than 100 rules in the file; instead using map files for rules. Larger rule sets may not work or they may slow the site's response down. I don't understand how to do the RewriteMap file thing to block ip addresses in a text file that is referred to by the .htaccess file. Can you show me how to convert what I have?
In the .htaccess file, I have been trying to block large numbers of IP addresses from entering our site like this:
RewriteCond %{REMOTE_ADDR} 27\.135\.76\..*
RewriteRule (.*) $1 [F]
RewriteCond %{REMOTE_ADDR} 38\.124\.20\.4
RewriteRule (.*) $1 [F]
RewriteCond %{REMOTE_ADDR} 50\.57\.54\.70
RewriteRule (.*) $1 [F]
RewriteCond %{REMOTE_ADDR} 94\.23\..*\..*
RewriteRule (.*) $1 [F]
RewriteCond %{REMOTE_ADDR} 94\.75\.207\.36
RewriteRule (.*) $1 [F]
RewriteCond %{REMOTE_ADDR} 97\.86\.242\.27
RewriteRule (.*) $1 [F]
RewriteCond %{REMOTE_ADDR} 130\.85\.43\.6
RewriteRule (.*) $1 [F]
RewriteCond %{REMOTE_ADDR} 173\.77\.164\.121
RewriteRule (.*) $1 [F]
RewriteCond %{REMOTE_ADDR} 204\.111\.88\.173
RewriteRule (.*) $1 [F]
RewriteCond %{REMOTE_ADDR} 204\.111\.176\.83
RewriteRule (.*) $1 [F]
RewriteCond %{REMOTE_ADDR} 205\.155\.228\.150
RewriteRule (.*) $1 [F]
RewriteCond %{REMOTE_ADDR} 209\.59\.216\.109
RewriteRule (.*) $1 [F]
RewriteCond %{REMOTE_ADDR} 209\.172\.33\.230
RewriteRule (.*) $1 [F]
RewriteCond %{REMOTE_ADDR} 216\.129\.119\.41
RewriteRule (.*) $1 [F]
RewriteCond %{REMOTE_ADDR} 20\.133\.4\..*
RewriteRule (.*) $1 [F]
RewriteCond %{REMOTE_ADDR} 41\..*\..*\..*
RewriteRule (.*) $1 [F]
What would I need to put in the htaccess file and map file to replace this?
Thanks!
Shawn
My hosting provider says that Helicontech, the company that makes ISAPI Rewrite suggests that you have no more than 100 rules in the file; instead using map files for rules. Larger rule sets may not work or they may slow the site's response down. I don't understand how to do the RewriteMap file thing to block ip addresses in a text file that is referred to by the .htaccess file. Can you show me how to convert what I have?
In the .htaccess file, I have been trying to block large numbers of IP addresses from entering our site like this:
RewriteCond %{REMOTE_ADDR} 27\.135\.76\..*
RewriteRule (.*) $1 [F]
RewriteCond %{REMOTE_ADDR} 38\.124\.20\.4
RewriteRule (.*) $1 [F]
RewriteCond %{REMOTE_ADDR} 50\.57\.54\.70
RewriteRule (.*) $1 [F]
RewriteCond %{REMOTE_ADDR} 94\.23\..*\..*
RewriteRule (.*) $1 [F]
RewriteCond %{REMOTE_ADDR} 94\.75\.207\.36
RewriteRule (.*) $1 [F]
RewriteCond %{REMOTE_ADDR} 97\.86\.242\.27
RewriteRule (.*) $1 [F]
RewriteCond %{REMOTE_ADDR} 130\.85\.43\.6
RewriteRule (.*) $1 [F]
RewriteCond %{REMOTE_ADDR} 173\.77\.164\.121
RewriteRule (.*) $1 [F]
RewriteCond %{REMOTE_ADDR} 204\.111\.88\.173
RewriteRule (.*) $1 [F]
RewriteCond %{REMOTE_ADDR} 204\.111\.176\.83
RewriteRule (.*) $1 [F]
RewriteCond %{REMOTE_ADDR} 205\.155\.228\.150
RewriteRule (.*) $1 [F]
RewriteCond %{REMOTE_ADDR} 209\.59\.216\.109
RewriteRule (.*) $1 [F]
RewriteCond %{REMOTE_ADDR} 209\.172\.33\.230
RewriteRule (.*) $1 [F]
RewriteCond %{REMOTE_ADDR} 216\.129\.119\.41
RewriteRule (.*) $1 [F]
RewriteCond %{REMOTE_ADDR} 20\.133\.4\..*
RewriteRule (.*) $1 [F]
RewriteCond %{REMOTE_ADDR} 41\..*\..*\..*
RewriteRule (.*) $1 [F]
What would I need to put in the htaccess file and map file to replace this?
Thanks!
Shawn
- HeliconAndrew
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: RewriteMap to Block IP Addresses
Well, there's also another option. So you have 2 options:
NOTE: you mapfile should contain the following:
Problem is that mapfile doesn't carry the regexp, so you won't be able to use expression like 27.135.76..*. Also, 100 rules is not a limit. Depending on the server load is could be over 1000.
Regards
Andrew
- Code: Select all
# option #1 without mapfile
RewriteCond %{REMOTE_ADDR} (?:50\.57\.54\.70|94\.75\.207\.36|205\.155\.228\.150|209\.172\.33\.230)
RewriteRule (.*) $1 [F]
- Code: Select all
# option #2
RewriteCond %{REMOTE_ADDR} (.*)
RewriteCond ${mapfile:%1|NOT_FOUND} !NOT_FOUND
RewriteRule .? - [F]
NOTE: you mapfile should contain the following:
- Code: Select all
94.75.207.36 94.75.207.36
204.111.88.173 204.111.88.173
209.59.216.109 209.59.216.109
Problem is that mapfile doesn't carry the regexp, so you won't be able to use expression like 27.135.76..*. Also, 100 rules is not a limit. Depending on the server load is could be over 1000.
Regards
Andrew
3 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 3 guests