Merge commit 'github/master'
[catagits/fcgi2.git] / perl / remote.PL
CommitLineData
637b713f 1use Config;
2
3open OUT, ">remote.fpl";
4print OUT "#!$Config{perlpath}\n";
5print OUT while <DATA>;
6close OUT;
7chmod 0755, "remote.fpl";
8__END__
9# An example of using a remote script with an Apache webserver.
10# Run this Perl program on "otherhost" to bind port 8888 and wait
11# for FCGI requests from the webserver.
12
13## Sample Apache configuration on the webserver to refer to the
14## remote script on "otherhost"
15# <IFModule mod_fastcgi.c>
16# AddHandler fastcgi-script fcgi
17# FastCgiExternalServer /path-to/cgi-bin/external.fcgi -host otherhost:8888
18# </IfModule>
19
20# Access the URL: http://webserver/cgi-bin/external.fcgi
21
22# Contributed by Don Bindner <dbindner@truman.edu>
23
24use FCGI;
25
26my $socket = FCGI::OpenSocket( ":8888", 5 );
27my $request = FCGI::Request( \*STDIN, \*STDOUT, \*STDERR,
28 \%ENV, $socket );
29
30my $count;
31while( $request->Accept() >= 0 ) {
32 print "Content-type: text/html\r\n\r\n";
33 print ++$count;
34}
35
36FCGI::CloseSocket( $socket );