paalare has asked for the wisdom of the Perl Monks concerning the following question:

Hi, we have a web-application implemented in Perl. And we just changed our host, and moved application to a new server (CentOS 5.6).

We now have a problem performing requests to external resources from within our application. Running a simple script (just for testing) from command-line works well, but running this lines within our application, through Apache (v2.2), there is an Internal Response telling me that Permission is Denied. Probably the problem is related to Apache, but you guys might as well help me with that? If not, suggestions on who could?

The script:
#!/usr/bin/perl use Data::Dumper; use LWP::UserAgent; my $ua = LWP::UserAgent->new; my $response = $ua->get('http://search.cpan.org/'); if ($response->is_success) { print $response->decoded_content; } else { print $response->status_line; } print Dumper $response;

Running script from command line prints the content of search.cpan.org, like expected.

Putting code into our system the Dumper line will return:
$VAR1 = bless( { '_content' => 'Can\'t connect to search.cpan.org:80 ( +Permission denied) LWP::Protocol::http::Socket: connect: Permission denied at /usr/lib/pe +rl5/5.8.8/CGI/Carp.pm line 314.', '_rc' => 500, '_headers' => bless( { 'client-warning' => 'Internal +response', 'client-date' => 'Mon, 13 Feb +2012 19:44:22 GMT', 'content-type' => 'text/plain' }, 'HTTP::Headers' ), '_msg' => 'Can\'t connect to search.cpan.org:80 (Perm +ission denied)', '_request' => bless( { '_content' => '', '_uri' => bless( do{\(my $o = +'http://search.cpan.org/')}, 'URI::http' ), '_headers' => bless( { 'user-a +gent' => 'libwww-perl/6.03' }, 'HTTP: +:Headers' ), '_method' => 'GET' }, 'HTTP::Request' ) }, 'HTTP::Response' );
Any idea what the problem could be? Thanks!

Replies are listed 'Best First'.
Re: Permission denied for external requests
by Eliya (Vicar) on Feb 14, 2012 at 08:29 UTC
      Thank you, Eliya! If I set selinux in permissive mode, my requests are allowed! I should probably add some policies instead of making all permissive, but that would be next step... Again, thanks! :)