You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Norman Khine <no...@khine.net> on 2006/10/17 15:07:27 UTC

[users@httpd] block IP range with mod_rewrite

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?

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@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


RE: [users@httpd] broken link checker

Posted by "Douglas B. Jones" <do...@gpc.edu>.
Thanks, sorry about the problems. I did do a Google search,
found some possibilities, but was wonder if there was something
better than what I found, maybe something that could run locally.
Thanks and sorry for the inconvenience. 

-----Original Message-----
From: Matus UHLAR - fantomas [mailto:uhlar@fantomas.sk] 
Sent: Wednesday, October 18, 2006 4:12 PM
To: Douglas B. Jones
Cc: users@httpd.apache.org
Subject: Re: [users@httpd] broken link checker

On 18.10.06 11:37, Douglas B. Jones wrote:
> Not sure if this is proper to post here, but I think these
> might be some of the most knowledgeable people along this line.

It sure does not belong here. Even into this mailing list, even into thread
you posted it into (do never reply old message when posting new question).

> Is there a good program for checking broken links? Preferably
> free, but one that cost can be considered. Thanks!

Have you even tried to search (google) for it?

-- 
Matus UHLAR - fantomas, uhlar@fantomas.sk ; http://www.fantomas.sk/
Warning: I wish NOT to receive e-mail advertising to this address.
Varovanie: na tuto adresu chcem NEDOSTAVAT akukolvek reklamnu postu.
Due to unexpected conditions Windows 2000 will be released
in first quarter of year 1901


---------------------------------------------------------------------
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@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] broken link checker

Posted by Matus UHLAR - fantomas <uh...@fantomas.sk>.
On 18.10.06 11:37, Douglas B. Jones wrote:
> Not sure if this is proper to post here, but I think these
> might be some of the most knowledgeable people along this line.

It sure does not belong here. Even into this mailing list, even into thread
you posted it into (do never reply old message when posting new question).

> Is there a good program for checking broken links? Preferably
> free, but one that cost can be considered. Thanks!

Have you even tried to search (google) for it?

-- 
Matus UHLAR - fantomas, uhlar@fantomas.sk ; http://www.fantomas.sk/
Warning: I wish NOT to receive e-mail advertising to this address.
Varovanie: na tuto adresu chcem NEDOSTAVAT akukolvek reklamnu postu.
Due to unexpected conditions Windows 2000 will be released
in first quarter of year 1901

---------------------------------------------------------------------
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@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


[users@httpd] broken link checker

Posted by "Douglas B. Jones" <do...@gpc.edu>.
Not sure if this is proper to post here, but I think these
might be some of the most knowledgeable people along this line.

Is there a good program for checking broken links? Preferably
free, but one that cost can be considered. Thanks!


---------------------------------------------------------------------
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@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


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

Posted by Joshua Slive <jo...@slive.ca>.
On 10/18/06, Norman Khine <no...@khine.net> wrote:

> 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?

If things are hanging, then that is a different story.  Are you using
the most recent version of apache?  You should identify the hanging
process and get a backtrace as described in
http://httpd.apache.org/dev/debugging.html#backtrace

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@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


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

Posted by Norman Khine <no...@khine.net>.
Joshua Slive wrote:
> On 10/17/06, Norman Khine <no...@khine.net> 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@httpd.apache.org
>   "   from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
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@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


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

Posted by Joshua Slive <jo...@slive.ca>.
On 10/17/06, Norman Khine <no...@khine.net> 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@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org