You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by sp...@posteo.eu on 2016/10/08 07:54:01 UTC
[users@httpd] Perl prg RewriteMap always returns blank
Hello experts!
I'm working with a Perl script that should do geoIP mapping (IP to
two-letter country code). The script works perfectly on the command
line, and follows the rules highlighted in
https://httpd.apache.org/docs/current/rewrite/rewritemap.html#prg
However, running from within Apache it always returns a blank value.
Only one line appears in the Apache error log even at LogLevel trace8
[Sat Oct 08 09:38:52.677116 2016] [rewrite:trace5] [pid 23318]
mod_rewrite.c(476): [client 85.205.37.101:46280] 85.205.37.101 - -
[<vhost>/sid#10092bc18][rid#100d28ca0/initial] map lookup OK: map=geoip
key=85.205.37.101 -> val=
Running the same IPs through the script manually does return values.
~ $ tail -f /var/log/apache/errors/error.log_20161008-09 | grep geoip
[Sat Oct 08 09:38:52.677116 2016] [rewrite:trace5] [pid 23318]
mod_rewrite.c(476): [client 85.205.37.101:46280] 85.205.37.101 - -
[<vhost>/sid#10092bc18][rid#100d28ca0/initial] map lookup OK: map=geoip
key=85.205.37.101 -> val=
[Sat Oct 08 09:38:54.290646 2016] [rewrite:trace5] [pid 23286]
mod_rewrite.c(476): [client 85.205.37.91:38384] 85.205.37.91 - -
[<vhost>/sid#10092bc18][rid#100cfb880/initial] map lookup OK: map=geoip
key=85.205.37.91 -> val=
[Sat Oct 08 09:38:57.889790 2016] [rewrite:trace5] [pid 23282]
mod_rewrite.c(476): [client 213.30.118.102:49939] 213.30.118.102 - -
[<vhost>/sid#10092bc18][rid#100d13940/initial] map lookup OK: map=geoip
key=213.30.118.102 -> val=
^C
~ $ /opt/apps/apache/conf/geoip_check.pl
85.205.37.101
DE
85.205.37.91
DE
213.30.118.102
PT
^C
~ $
I'm running Apache 2.4.18 on Solaris/SPARC and Perl 5.16.0. Compile-time
settings:
$ /opt/apache/current/bin/httpd -V
Server version: Apache/2.4.18-dev (Unix)
Server built: Nov 20 2015 19:38:51
Server's Module Magic Number: 20120211:51
Server loaded: APR 1.5.2, APR-UTIL 1.5.4
Compiled using: APR 1.5.2, APR-UTIL 1.5.4
Architecture: 64-bit
Server MPM: prefork
threaded: no
forked: yes (variable process count)
Server compiled with....
-D APR_HAS_SENDFILE
-D APR_HAS_MMAP
-D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
-D APR_USE_PROC_PTHREAD_SERIALIZE
-D APR_USE_PTHREAD_SERIALIZE
-D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
-D APR_HAS_OTHER_CHILD
-D AP_HAVE_RELIABLE_PIPED_LOGS
-D DYNAMIC_MODULE_LIMIT=256
-D HTTPD_ROOT="/opt/apache/apache-2.4.17-sparc-t64"
-D SUEXEC_BIN="/opt/apache/apache-2.4.17-sparc-t64/bin/suexec"
-D DEFAULT_PIDLOG="logs/httpd.pid"
-D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
-D DEFAULT_ERRORLOG="logs/error_log"
-D AP_TYPES_CONFIG_FILE="conf/mime.types"
-D SERVER_CONFIG_FILE="conf/httpd.conf"
$
Any ideas what could be going on here?
Thanks!
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] Perl prg RewriteMap always returns blank
Posted by sp...@posteo.eu.
Hello experts!
I have an update on this. I found in the main Apache error log the
following error:
ld.so.1: perl: fatal: libgcc_s.so.1: open failed: No such file or directory
So it seems that Apache fails to initialise the script defined for the
RewriteMap.
I checked the LD_LIBRARY_PATH used in the Apache init script and
ligbcc_s.so.1 is there.
I also tried PassEnv LD_LIBRARY_PATH but it doesn't help.
Is there something specific I have to do to defind the LD_LIBRARY_PATH
used when calling the Perl script defined in:
RewriteMap geoip prg:/opt/apps/apache/conf/geoip_check.pl
K.
Am 08.10.2016 um 09:54 schrieb spggwp7q@posteo.eu:
> Hello experts!
>
> I'm working with a Perl script that should do geoIP mapping (IP to
> two-letter country code). The script works perfectly on the command
> line, and follows the rules highlighted in
> https://httpd.apache.org/docs/current/rewrite/rewritemap.html#prg
>
> However, running from within Apache it always returns a blank value.
>
> Only one line appears in the Apache error log even at LogLevel trace8
>
> [Sat Oct 08 09:38:52.677116 2016] [rewrite:trace5] [pid 23318]
> mod_rewrite.c(476): [client 85.205.37.101:46280] 85.205.37.101 - -
> [<vhost>/sid#10092bc18][rid#100d28ca0/initial] map lookup OK: map=geoip
> key=85.205.37.101 -> val=
>
> Running the same IPs through the script manually does return values.
>
> ~ $ tail -f /var/log/apache/errors/error.log_20161008-09 | grep geoip
> [Sat Oct 08 09:38:52.677116 2016] [rewrite:trace5] [pid 23318]
> mod_rewrite.c(476): [client 85.205.37.101:46280] 85.205.37.101 - -
> [<vhost>/sid#10092bc18][rid#100d28ca0/initial] map lookup OK: map=geoip
> key=85.205.37.101 -> val=
> [Sat Oct 08 09:38:54.290646 2016] [rewrite:trace5] [pid 23286]
> mod_rewrite.c(476): [client 85.205.37.91:38384] 85.205.37.91 - -
> [<vhost>/sid#10092bc18][rid#100cfb880/initial] map lookup OK: map=geoip
> key=85.205.37.91 -> val=
> [Sat Oct 08 09:38:57.889790 2016] [rewrite:trace5] [pid 23282]
> mod_rewrite.c(476): [client 213.30.118.102:49939] 213.30.118.102 - -
> [<vhost>/sid#10092bc18][rid#100d13940/initial] map lookup OK: map=geoip
> key=213.30.118.102 -> val=
> ^C
> ~ $ /opt/apps/apache/conf/geoip_check.pl
> 85.205.37.101
> DE
> 85.205.37.91
> DE
> 213.30.118.102
> PT
> ^C
> ~ $
>
> I'm running Apache 2.4.18 on Solaris/SPARC and Perl 5.16.0. Compile-time
> settings:
>
> $ /opt/apache/current/bin/httpd -V
> Server version: Apache/2.4.18-dev (Unix)
> Server built: Nov 20 2015 19:38:51
> Server's Module Magic Number: 20120211:51
> Server loaded: APR 1.5.2, APR-UTIL 1.5.4
> Compiled using: APR 1.5.2, APR-UTIL 1.5.4
> Architecture: 64-bit
> Server MPM: prefork
> threaded: no
> forked: yes (variable process count)
> Server compiled with....
> -D APR_HAS_SENDFILE
> -D APR_HAS_MMAP
> -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
> -D APR_USE_PROC_PTHREAD_SERIALIZE
> -D APR_USE_PTHREAD_SERIALIZE
> -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
> -D APR_HAS_OTHER_CHILD
> -D AP_HAVE_RELIABLE_PIPED_LOGS
> -D DYNAMIC_MODULE_LIMIT=256
> -D HTTPD_ROOT="/opt/apache/apache-2.4.17-sparc-t64"
> -D SUEXEC_BIN="/opt/apache/apache-2.4.17-sparc-t64/bin/suexec"
> -D DEFAULT_PIDLOG="logs/httpd.pid"
> -D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
> -D DEFAULT_ERRORLOG="logs/error_log"
> -D AP_TYPES_CONFIG_FILE="conf/mime.types"
> -D SERVER_CONFIG_FILE="conf/httpd.conf"
> $
>
> Any ideas what could be going on here?
>
> Thanks!
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] Perl prg RewriteMap always returns blank
Posted by Marat Khalili <mk...@rqc.ru>.
On 08/10/16 10:54, spggwp7q@posteo.eu wrote:
> However, running from within Apache it always returns a blank value.
>
> Running the same IPs through the script manually does return values.
>
> Any ideas what could be going on here?
First, I totally agree with Julian about evilness of using user's IP for
selecting user's locale or (worse) geo-blocking. As for the technical
part of the question, I'd start with:
1. Testing the script with exact privileges it receives from Apache. It
can be prevented from working by file modes, chroot (or other jail),
apparmor/selinux etc.
2. Injecting some logging statements into the script (or use wrapper) to
see if it actually tries to return something to Apache or not.
--
With Best Regards,
Marat Khalili
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org