Subject: | Net::Domain::hostname() returns 'localhost' under mod_perl |
Net::Domain::hostname() correctly returns my computer's hostname (HPXP)
in a simple command-line program, but returns 'localhost' when used in a
mod_perl handler. Net::Domain::hostfqdn() also has the same problem, but
Sys::Hostname::hostname() works fine.
The attached handler module outputs:
Net::Domain::hostname() = localhost
Net::Domain::hostfqdn() = localhost
Sys::Hostname::hostname() = HPXP
It is configured as:
<Location /hostnametest>
SetHandler modperl
PerlResponseHandler HostnameTest
</Location>
This is using perl-5.12.2 with its original libnet (1.22),
mod_perl-2.0.5 and Apache httpd-2.2.17, built with MS Visual Studio 2010
SP1 and running on Windows XP SP3.
Subject: | HostnameTest.pm |
package HostnameTest;
use 5.012002;
use strict;
use warnings;
use Apache2::Const qw(OK);
use Net::Domain qw();
use Sys::Hostname qw();
sub handler : method {
my($class, $r) = @_;
$r->print("Net::Domain::hostname() = ", Net::Domain::hostname(), "\n");
$r->print("Net::Domain::hostfqdn() = ", Net::Domain::hostfqdn(), "\n");
$r->print("Sys::Hostname::hostname() = ", Sys::Hostname::hostname(), "\n");
return Apache2::Const::OK;
}
1;