You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Roberto Bouza <bo...@gmail.com> on 2007/04/20 00:08:14 UTC

[users@httpd] Problems load balancing with lb.pl and RewriteMap

Hello,

I hope everyone can give me some help here. I've battling for a while 
without any luck.

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

<VirtualHost www.domain.com:80>

       DocumentRoot /var/www/www.domain.com
       ServerName www-test.domain.com

       LogLevel debug
       ErrorLog /var/log/httpd/www.domain.com/error_log
       CustomLog /var/log/httpd/www.domain.com/access_log combined

       RewriteEngine On
       RewriteLog /tmp/rewrite.log
       RewriteLogLevel 10

       RewriteMap servers prg:/etc/httpd/conf/loadbalancing/lb.pl
       RewriteRule ^/(.*)$ ${servers:$1} [P,L]
       #RewriteRule    ^/(.*)$ http://www.anotherdomain.com/$1        
[P,L]  ----> This line here works as a charm

</VirtualHost>


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

Here is the lb.pl

------
#!/usr/bin/perl -w

$| = 1;
while (<STDIN>) {
       print "http://www.anotherdomain.com/$_\n";
}
---------

Pretty basic with no science at all. When ran from the command line it 
returs the URL without any problem. It has the right permissions. 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.

Here is the rewrite log:

(1) go-ahead with proxy request proxy:http://www-test.mydomain.com/ [OK]
(2) init rewrite engine with requested uri /
(3) applying pattern '^/(.*)$' to uri '/'
(5) map lookup OK: map=servers key= -> val=
(2) rewrite / ->
(2) forcing proxy-throughput with http://www-test.mydomain.com/

Now I tested this same config on Fedora using Apache 2.0.59 and it works 
perfect. Now the problem here is on RedHat with Apache 2.0.52.

Do I need to be aware of any extra modules?

Any help would be much appreciated.

Roberto Bouza.
---

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