Hi, I've setup a server and installed HestiaCP as a server management tool to install & control NGINX, Apache, Databases, .... It's an Ubuntu 22.04 server Unfortunately HestiaCP doesn't support Perl, so I installed the package for Mod_Perl myself and changed the Apache configuration accordingly. Now I started migrating stuff from my old webhoster to the new server. And... now I'm facing lots of problems. The problems seem to only occur when I use self-written modules. Using pre-existing modules doesn't cause any problems. The scripts and modules were running perfectly fine on my old webhoster. I just needed to change a few paths in the scripts/modules to refelct the new locations. So I am pretty sure that I do not have a syntax error or something like that. Around 50% of the time I can see in the web server log messages like these:

2023/02/24 14:36:45 [error] 1467#1467: *1180 upstream prematurely clos +ed connection while reading response header from upstream, client: 87 +.122.231.239, server: digioso.tk, request: "GET /test.pl HTTP/2.0", u +pstream: "https://10.0.0.113:8443/test.pl", host: "digioso.tk"

So... 50% of the time the page loads, 50% it doesn't. The upstream errors point to NGINX (at least all the search results I found on Google point there), but I couldn't find anything even remotely connected to my issue.

Links to test:
https://digioso.tk/test.pl <- I am using a self-writte module here and the issue occurs like 50% of the time. The website runs into error 500 and I can see the above upstream message in my webserver logfile. If you don't get error 500 immediately - please refresh the page a couple of times.
https://digioso.tk/test2.pl <- No self-written modules. Runs perfectly fine.

Source code:
test.pl
#!/usr/bin/perl -w use strict; use CGI; use CGI::Carp qw(fatalsToBrowser warningsToBrowser); use lib "/home/digioso/web/digioso.tk/stuff"; use Navi; Navi::print_navi(); print "test"; Navi::end_navi();
test2.pl
#!/usr/bin/perl -w use strict; use CGI; use CGI::Carp qw(fatalsToBrowser warningsToBrowser); my $cgi = new CGI; binmode STDOUT, ":utf8"; print $cgi->header (-type => 'text/html', -charset => 'UTF-8'); print "test2"; print $cgi->end_html;
Navi.pm (located in /home/digioso/web/digioso.tk/stuff):
#!/usr/bin/perl -w use strict; use warnings; use CGI; use CGI::Carp qw(fatalsToBrowser warningsToBrowser); package Navi; my $cgi = new CGI; binmode STDOUT, ":utf8"; sub print_navi { print $cgi->header (-type => 'text/html', -charset => 'UTF-8'); } sub end_navi() { print $cgi->end_html; }

So basically test1 outputs the same as test2. Only difference is that starting and ending HTML is done via a module. The original Navi.pm contains many more things (eg including CSS and so on), but for demonstration purposes I thinned it down to the above.


In reply to upstream prematurely closed connection while reading response header from upstream by Digioso

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.