You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Drew Nichols <dr...@mena.org.au> on 2005/05/23 07:21:00 UTC

[users@httpd] Problem with rewrite round robin lb.pl

Hi,
Hoping someone may help.

I have the following in httpd.conf (changed domain to 'mydomain').

<VirtualHost * >
        ServerName www.mydomain.com
        RewriteEngine On
        RewriteMap    lb      prg:/etc/httpd/conf/lb.pl
        RewriteRule   ^/(.+)$ ${lb:$1}           [P,L]
        #RewriteRule ^/(.*) hello$1 [P,L]
</VirtualHost>

Which will rewrite fine for the commented out 'hello' test (so the rule 
is being hit for the virtual host). So everything is working fine EXCEPT 
the lb.pl script.

I have the lb.pl cut and paste from the apache manual with only minor 
mods (the script executes as a non priv user fine and returns a URL when 
run interactively that when browsed to works just fine).

#!/usr/bin/perl
##
##  lb.pl -- load balancing script
##


$| = 1;

$name   = "b";     # the hostname base
$first  = 1;         # the first server (not 0 here, because 0 is myself)
$last   = 2;         # the last server in the round-robin
$domain = "mydomain.com"; # the domainname
# Zope rewrite
$vhost = 
":8080/VirtualHostBase/http/www.mydomain.com:80/biol2/VirtualHostRoot";

$cnt = 0;
while (<STDIN>) {
     $cnt = (($cnt+1) % ($last+1-$first));
     $server = sprintf("%s%d.%s%s", $name, $cnt+$first, $domain, $vhost);
     print "http://$server/$_";
}
##EOF##


BUT for some reason the lb rewrite rule always proxys to / even though 
the script will return valid, browsable URLs when run from the command line.

In the rewrite log I get
  (2) init rewrite engine with requested uri /
  (3) applying pattern '^/(.+)$' to uri '/'
  (1) pass through /

The 'hello' test rule gets
(1) go-ahead with proxy request 
proxy:http://www.mydomain.com/hellohellohellohellohellohellohellohellohellohellohellohello 
[OK]


Any help would be much appreciated.

Drew Nichols








---------------------------------------------------------------------
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] Problem with rewrite round robin lb.pl

Posted by Joshua Slive <js...@gmail.com>.
On 5/23/05, Drew Nichols <dr...@mena.org.au> wrote:
>        RewriteMap    lb      prg:/etc/httpd/conf/lb.pl
>        RewriteRule   ^/(.+)$ ${lb:$1}           [P,L]
>        #RewriteRule ^/(.*) hello$1 [P,L]

> In the rewrite log I get
>  (2) init rewrite engine with requested uri /
>  (3) applying pattern '^/(.+)$' to uri '/'
>  (1) pass through /

Well, the URI of "/" does not match the regular expression ^/(.+)$, so
no rewriting takes place.  Note that the "+" indicates that there must
be at least one matching character following the /.

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