[users@httpd] Problem With mod_rewrite As Reverse Proxy and Extra Carriage Returns

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

 



Hello,

I am using Apache 2.0.50 on Windows 2000 and have tried to configure mod_rewrite to reverse-proxy requests through an external Perl script. Everything works well, except that the URL that the back-end servers receive contains an extra carriage return (seen as "%0D"):

   192.168.1.1 - - [19/Apr/2005:14:10:42 +0200] "GET /inis/php/getResults.php%0D?PHPSESSID...

The carriage return can also be seen in the rewrite logs at the position indicated below as [CR APPEARS HERE]:

<--- BEGIN: Rewrite Log --->
192.168.1.2 - - [19/Apr/2005:14:10:56 +0200] [server4.xxxx.org/sid#23bd38][rid#f9b2f8/initial] (2) init rewrite engine with requested uri /inis/php/getResults.php
192.168.1.2 - - [19/Apr/2005:14:10:56 +0200] [server4.xxxx.org/sid#23bd38][rid#f9b2f8/initial] (3) applying pattern '^/(.*getResults\.php)$' to uri '/inis/php/getResults.php'
192.168.1.2 - - [19/Apr/2005:14:10:56 +0200] [server4.xxxx.org/sid#23bd38][rid#f9b2f8/initial] (4) RewriteCond: input='161.5.151.85' pattern='!^161\.5\.2\.226' => matched
192.168.1.2 - - [19/Apr/2005:14:10:56 +0200] [server4.xxxx.org/sid#23bd38][rid#f9b2f8/initial] (5) map lookup OK: map=lb key=inis/php/getResults.php -> val=http://server6.xxxx.org:86/inis/php/getResults.php
192.168.1.2 - - [19/Apr/2005:14:10:56 +0200] [server4.xxxx.org/sid#23bd38][rid#f9b2f8/initial] (2) rewrite /inis/php/getResults.php -> http://server6.xxxx.org:86/inis/php/getResults.php
192.168.1.2 - - [19/Apr/2005:14:10:56 +0200] [server4.xxxx.org/sid#23bd38][rid#f9b2f8/initial] (2) forcing proxy-throughput with http://server6.xxxx.org:86/inis/php/getResults.php
192.168.1.2 - - [19/Apr/2005:14:10:56 +0200] [server4.xxxx.org/sid#23bd38][rid#f9b2f8/initial] (1) go-ahead with proxy request proxy:http://inis-a6.dmz.iaea.org:86/inis/php/getResults.php[CR APPEARS HERE] [OK]
<--- END: Rewrite Log --->

My configuration looks as follows:

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteLock  F:/Apache2/bin/lb.lock
    RewriteLog   F:/Apache2/logs/lb.log
    RewriteLogLevel   9
    RewriteMap   lb                        "prg:F:/Perl/bin/perl.exe F:/Apache2/bin/lb.pl"
    RewriteCond  %{REMOTE_ADDR}            !^192\.168\.1\.1
    RewriteRule  ^/(.*getResults\.php)$    ${lb:$1}     [P,L]
</IfModule>

and the external script is taken from the ReWrite documentation:

   #!/Perl/bin/perl
   $| = 1;

   $hostName   = "server6.xxxx.org";
   $firstPort  = 83;
   $lastPort   = 86;

   $cnt = 0;
   while (<STDIN>) {
       $cnt = (($cnt+1) % ($lastPort+1-$firstPort));
       $server = sprintf("%s:%d", $hostName, $cnt+$firstPort);
       print "http://$server/$_";;
   }

I have tried to modify the script by removing the default CR/LF combinations at the end of the returned value, but, as the documentation mentions, the value needs to end in a newline (LF) for the RewriteRule to work.

Any help in solving this problem would greatly be appreciated. I have noticed a report of this problem in the list's archives, dating back to 2003:

   http://marc.theaimsgroup.com/?l=apache-httpd-users&m=107170391415958&w=2

whereby the solution was to add the -u switch to an external Python script. Is there anything similar for Perl?

Thanks in advance,

 Curro

This email message is intended only for the use of the named recipient.
Information contained in this email message and its attachments may be
privileged, confidential and protected from disclosure. If you are not the
intended recipient, please do not read, copy, use or disclose this
communication to others. Also please notify the sender by replying to this
message and then delete it from your system.


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