0

I'm trying to figure out why an nph- script in Perl is corrupting from the browser. This is the code:

#!/usr/bin/perl

print "Content-Type: text/plain\n\n";

print "FOO";

I name it nph-test.cgi, and then run from the browser, I get:

enter image description here

If I copy the exact same code, and name it test.cgi, it comes out fine:

enter image description here

The apache config is:

<Directory "/home/foo/web/example.org/*">

    Options +ExecCGI +FollowSymLinks +MultiViews
    AllowOverride AuthConfig

    PerlResponseHandler ModPerl::Registry
    AddHandler perl-script .cgi .pl
    Options +ExecCGI
    PerlOptions +ParseHeaders
    AllowOverride All
    Require all granted

</Directory>

What am I doing wrong?

Versions are:

Apache 2.4.18 Perl 5.22.1

Andrew Newby
  • 1,154
  • Are you loading mod_asis? https://httpd.apache.org/docs/current/mod/mod_asis.html – chicks Oct 18 '17 at 00:34
  • @chicks - It doesn't appear so. Should I? What exactly does it do? Thanks! – Andrew Newby Oct 18 '17 at 05:53
  • @chicks - I'm not too sure that does what I'm after.. I enabled it, and then added this into the .conf: AddHandler send-as-is cgi , rebooted Apache, and then when I run that script it downloads with the contents: 1f8b 0800 0000 0000 0003 73f3 f707 00ab 27d4 1a03 0000 00 – Andrew Newby Oct 18 '17 at 09:24

1 Answers1

0

OK, well this isn't quite the solution I was expecting but has done the trick. All my nph- scripts are in a /cgi-bin/admin folder, so what I did was add this as part of my Apache config, to take it off mod_perl:

<Directory "/home/user/web/example.com/public_html/cgi-bin/admin">

        Options MultiViews FollowSymLinks
        AllowOverride All
        Require all granted
        AddHandler cgi-script .cgi .pl
        Options +ExecCGI
        Options FollowSymLinks
</Directory>

It appears to be mod_perl that screws something up with non-parsed headers, but it's a bit above my pay grade. As long as this works, I guess its ok :) (just thought I would post it in case anyone else has the same problem)

Andrew Newby
  • 1,154