Forum Moderators: phranque

Message Too Old, No Replies

Ban list - by domain

And will this save bandwidth?

         

surfgatinho

3:46 pm on Aug 16, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I'm trying to write an .htaccess file to ban all the spam a blog I set up seems to be attracting. (It originally diplayed referrers links on the page)

I've tried loads of variants but I don't seem to be able to stop my bandwidth dissapearing.

I tried:

Order allow,deny
Allow from all
Deny from domain.com
Deny from .*.st
Deny from .*.ki
Deny from *.cc
Deny from .*.by

But this doesn't seem to work - I've also tried lots of other ways.

Could someone point me in the right direction and will it save my bandwidth?

Thanks in advance,
Chris

jdMorgan

7:14 pm on Aug 16, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Chris,

It's not at all obvious, but access control by domain can be very inefficient. Each "test" requires the server to take the requesting IP address and do a reverse-DNS lookup on it, effectively stalling the request until the domain is returned from the DNS system. As such, you can use it for "emergencies" and in tightly-scoped situations, but I can't recommend that you use it as a matter of course for all file requests. If you do, your server will be issuing as many requests as it receives!

If you wish to proceeed, you can use mod_setenvif [httpd.apache.org] to pass a control variable to mod_access [httpd.apache.org]. Here's a basic outline:


SetEnvIf Remote_Host \.st$ badguy
SetEnvIf Remote_Host \.ki$ badguy
...
Deny from badguy

Some servers are configured to block reverse-DNS lookups, so test a simple version before spending too much time on it.

Jim

Jioffri

3:58 am on Aug 17, 2005 (gmt 0)

10+ Year Member



Jim,

I also had a question on this. I have the following syntax so can you please specify whether it will work under this circumstance?

Jio

--------------------------------

RewriteEngine On
RewriteCond %{HTTP_REFERER}!^$
RewriteCond %{HTTP_REFERER}!^http://example.com [NC]
RewriteCond %{REQUEST_METHOD} ^POST$
RewriteRule ^/POSTprocessing.cgi - [F]

--------------------------------