IIS permissions to allow outgoing REST http requests from site code

iisiis-7.5

I can't use outgoing http requests in IIS due some security permissions or something

I am trying to use my own REST http service (it is a standalone application) on localhost in my perl CGI site

use LWP::UserAgent;
my $ua = LWP::UserAgent -> new (timeout => 600);
my $response = $ua -> get ('http://127.0.0.1:8000/get');
if ($response -> is_error ()) {
    die join ("\n\n",
        $response -> error_as_HTML ()
        , $response -> code ()
        , $response -> content ()
        , $response -> status_line ()
    );
}

Here what I've got

<html>
<head><title>An Error Occurred</title></head>
<body>
<h1>An Error Occurred</h1>
<p>500 Can't connect to 127.0.0.1:8000</p>
</body>
</html>


500

Can't connect to 127.0.0.1:8000

Invalid argument. at C:/strawberry/perl/site/lib/LWP/Protocol/http.pm line 60.


500 Can't connect to 127.0.0.1:8000 at C:\inetpub\wwwroot\test\lib\Content\_lib.pm line 724.

my 127.0.0.1:8000 service is a standalone application outside of IIS, it is running and gives an alive status when I access http://127.0.0.1:8000/get via browser; I can see it is listening on port 8000; I turned off firewall

same configuration with same application works with lighttpd on linux box, problem occurs only when I run under windows and IIS

I tried to run my perl CGI application pool as Network Service and even Local System account – same result

How should I configure IIS to allow outgoing http REST calls to another standalone webservice on localhost?

UPDATE

After some low-level investigation, it looks like this is common IIS problem

just google IIS Can't create TCP/IP socket (10106)

Best Answer

It's not a security restriction. Perl tries to find some driver's dll's in system registry:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\Tcpip

but path to dll is based on environment variable %SystemRoot%, and IIS do not pass environment through FastCGI

Add following text to your programm:

BEGIN {

    $ENV {SYSTEMROOT} = "C:\\Windows";

};