sexta-feira, 13 de dezembro de 2013

Can't locate object method "header_in" via package "Apache2::RequestRec" AdjustRemoteAddrAccordingToHeader.pm line 9

Ao migrar o Oracle Portal para versão 11G, o script AdjustRemoteAddrAccordingToHeader.pm começou a apresentar o seguinte erro:

 Can't locate object method "header_in" via package "Apache2::RequestRec" at /u01/app/oracle/product/Middleware/asinst_1/config/OHS/ohs1/AdjustRemoteAddrAccordingToHeader.pm line 9

Para resolver este problema, basta acrescentar o seguinte:

use Apache2::compat;

AdjustRemoteAddrAccordingToHeader.pm:

package Apache::AdjustRemoteAddrAccordingToHeader;

use Apache2::compat;

sub handler
{
        my $r = shift;
        my $configuredValue = $r->dir_config ("UseIPFromHeader");
        if ($configuredValue)
        {
                my $ip = $r->header_in($configuredValue);
                if ($ip)
                {
                        $r->connection->remote_ip($ip);
                }
        }
        else
        {
                print STDERR "AdjustRemoteAddrAccordingToHeader: PerlSetVar UseIPFromHeader is not set, so I did not do anything\n";
        }

        # Adjust for Oracle HTTP Server and REMOTE_ADDR
        # Remove this line if not necessary
        $r->header_in("ClientIP", $r->connection->remote_ip());

        return OK;
}

return 1;



httpd.conf:

PerlRequire /u01/app/oracle/product/Middleware/asinst_1/config/OHS/ohs1/AdjustRemoteAddrAccordingToHeader.pm
PerlPostReadRequestHandler Apache::AdjustRemoteAddrAccordingToHeader
PerlSetVar UseIPFromHeader X-Forwarded-For

0 comentários: