You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Steve van der Burg <st...@lhsc.on.ca> on 2000/06/23 17:33:47 UTC
Re: Simple program _setting_ REMOTE_ADDR - SOLUTION
>Like that but work-around earlier today for Apache::Request to work
>around a MIME formatting but in IE on the Mac. Lame.
Taking your remote_ip hint, and reading the Eagle a bit more closely, I came up with this:
In httpd.conf:
<Location /cgi-bin/VENDOR>
PerlAccessHandler LHSC::FakeRemoteIP
</Location>
Here's the handler:
#!/bin/perl
package LHSC::FakeRemoteIP;
use Apache::Constants qw /:common/;
use strict;
sub handler {
my $r = shift;
$r->connection->remote_ip("1.2.3.4");
return OK;
}
1;
I've tested it and it works perfectly.
...Steve
--
Steve van der Burg
Information Services
London Health Sciences Centre
(519) 685-8300 ext 35559
steve.vanderburg@lhsc.on.ca
Re: Simple program _setting_ REMOTE_ADDR - SOLUTION
Posted by Dan Rench <dr...@i-works.com>.
On Fri, 23 Jun 2000, Steve van der Burg wrote:
> Taking your remote_ip hint, and reading the Eagle a bit more closely,
> I came up with this:
>
> In httpd.conf:
>
> <Location /cgi-bin/VENDOR>
> PerlAccessHandler LHSC::FakeRemoteIP
> </Location>
Why an Access handler? I realize it works, but a more appropriate
phase would be PerlFixupHandler, since you aren't doing any access
control in your module. A couple other nitpicky points: you probably
should return 'DECLINED' at the end, not 'OK', in case there are more
handlers that want to do something during that phase and it also probably
would be a good idea to restore the "real" address after so your logs
show the actual client IP. Something like this:
package FakeIP;
use strict;
use Apache::Constants 'DECLINED';
sub handler {
my $r = shift;
$r->notes('true_client_ip', $r->connection->remote_ip);
$r->connection->remote_ip('1.2.3.4');
$r->push_handlers('PerlLogHandler' =>
sub {
my $r = shift;
$r->connection->remote_ip($r->notes('true_client_ip'));
return DECLINED;
}
);
return DECLINED;
}
1;