Forum Moderators: phranque

Message Too Old, No Replies

Proper use of allow/deny

Banned domains seem to be getting past the filter

         

anax

5:38 am on Feb 5, 2006 (gmt 0)

10+ Year Member



I have the lines below (real names changed) in my .htaccess file to block visitors from certain domains and IP addresses. From my log files, however, it looks like people are still getting through. Is there something wrong with this syntax? Does it matter where the block is located in the .htaccess file? (I've got it at the bottom, after a bunch of redirect rules.)

<Limit GET POST>
order allow,deny
allow from all
deny from .servera.badco.com
deny from .badtown.ab.da.uu.net
deny from .nogood.org
deny from 234.56
</Limit>

(Sure would be great if there were an automatied .htaccess validator out there somewhere. Is there?)

Many thanks.

jdMorgan

3:10 pm on Feb 5, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



At least two possibilities:

1) Maybe your server is configured such that it does not allow reverse-DNS lookups. Reverse-DNS lookups are required for this to work, since the only info the server has is the requesting IP address; It has to send that IP address to the DNS system to get the remote hostname to compare against your deny directives.

Many hosting companies disable reverse-DNS lookups because they can cause server performance problems -- Each incoming request to your server that is processed through your code creates an additional outgoing connection from your server to the DNS system, and your server must wait for that DNS response before it can complete your visitor's HTTP request. This can be very slow, and cause a large number of queued requests to your server.

2) Perhaps the problem is that your code only controls the GET, HEAD, and PUT HTTP methods. Anyone can still use other methods, such as TRACE, MOVE, DELETE, PROPFIND, etc.

Jim

anax

7:20 pm on Feb 5, 2006 (gmt 0)

10+ Year Member



1) Maybe your server is configured such that it does not allow reverse-DNS lookups. Reverse-DNS lookups are required for this to work, since the only info the server has is the requesting IP address; It has to send that IP address to the DNS system to get the remote hostname to compare against your deny directives.

Hmm, I don't think #2 is likely, but this reverse DNS thing may be the cause. Does that mean if I replace the domain name fragments with the corresponding IP address fragments it should work?

jdMorgan

4:52 pm on Feb 6, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes, it should certainly work -- try it and let us know... :)

Jim