Re: [users@httpd] block IP range with mod_rewrite

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Joshua Slive wrote:
> On 10/17/06, Norman Khine <norman@xxxxxxxxx> wrote:
>> hello again,
>> i have the following rewrite rule,
>>
>> <VirtualHost *:80>
>>   ServerName domain.tld
>>   ServerAlias www.domain.tld
>>   RewriteEngine On
>>   RewriteMap    hosts-deny  txt:/home/user/apache/hosts.deny
>>   RewriteCond   ${hosts-deny:%{REMOTE_HOST}|NOT-FOUND} !=NOT-FOUND [OR]
>>   RewriteCond   ${hosts-deny:%{REMOTE_ADDR}|NOT-FOUND} !=NOT-FOUND
>>   RewriteRule   ^/.*  -  [F]
>>   RewriteRule ^/(.*)
>> http://udomain.tld:4080/VirtualHostBase/http/domain.tld:80/shops/shop1/VirtualHostRoot/$1
>>
>> [L,P]
>>   ErrorLog /var/log/apache2/domain.tld_error.log
>>   CustomLog /var/log/apache2/domain.tld_access.log combined
>>   RewriteLog /var/log/apache2/domain.tld_rewrite_log
>> </VirtualHost>
>>
>> where the
>>
>> RewriteMap    hosts-deny  txt:/home/user/apache/hosts.deny
>>
>> has the enries of the IP's I want to block from accessing my webserver.
>>
>> This does not work as my second RewriteRule is not taken into account.
>> What is the best way to have this look at the IP address if it is in the
>> list to block it, if not then the go to the next RewriteRule?
>>
>> When I run this the server did not respond, even though my IP was not in
>> the list.
>>
>> Using the [F], does this mean the Rewrite Stops there and the second
>> Rule is not taken into account?
>
> What happens if you remove everything but the second RewriteRule?
> Does it work then?  What is in the RewriteLog?
>
> Joshua.
>
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server
> Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
>   "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
> For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx
>
Hi,
I need the second RewriteRule as this is where my application is running
from, and this works fine.

The problem is that the if I add the:

  RewriteMap    hosts-deny  txt:/home/user/apache/hosts.deny
  RewriteCond   ${hosts-deny:%{REMOTE_HOST}|NOT-FOUND} !=NOT-FOUND [OR]
  RewriteCond   ${hosts-deny:%{REMOTE_ADDR}|NOT-FOUND} !=NOT-FOUND
  RewriteRule   ^/.*  -  [F]

to my httpd.conf the browser just hangs and there is no entry in the logs.

How can I have the RewriteRule check against the hosts.deny and if it is
not there to run the second RewriteRule?

Many thanks

Norman


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
   "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx



[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux