- Server operating system version
- Linux 4.19.0
- Plesk version and microupdate number
- Version 18.0.61 Update #5
I am setting up a new plesk webserver and moving some websites from an existing plesk webserver which has been running for about five years with no problems. All was going well until I started hitting strange 502 Gateway errors, Narrowing this down, I found it seems to be connected with whether I am using HTTP GET or POST requests. To demonstrate this problem, I am using this minimalist perl program:
test.cgi
#!/usr/bin/perl
print "Content-Type: text/html\n\n" ;
print "<p>Hello World\n" ;
exit ;
Running it from the browser address bar works fine, the permissions are set to 0755, there is a handler set up in the Apache config for cgi-script .cgi and so on. When I run it by typing the address directly into the browser I get Hello World just as expected. I can also run it from a HTML form using GET, like this:
<!DOCTYPE HTML>
<html lang=EN>
<body>
<h1>Testing with GET</h1>
<form class=modern action="test.cgi" method=GET>
<button type=submit>Submit form using GET</button>
</form>
</body>
</html>
but if I change that HTML page to use POST, like this,
<!DOCTYPE HTML>
<html lang=EN>
<body>
<h1>Testing with POST</h1>
<form action="test.cgi" method=POST enctype="multipart/form-data">
<button type=submit>Submit form using POST method</button>
</form>
</body>
</html>
Then it instantly comes up with 502 Bad Gateway and the proxy_error_log says
upstream prematurely closed connection while reading response header from upstream, client: ...., server: www......co.uk,
request: "POST /test/test.cgi HTTP/2.0",
upstream: "https://127.0.0.1:7081/test/test.cgi",
host: "www.....co.uk",
referrer: "https://www.....co.uk/test/test2.shtml"
So it is the exact same program, zero complexity, and the only difference is the HTTP method used. I have tried it with the other enctypes for the post method with the same results. What am I missing? Is there a firewall web rule somewhere that I need to disable, or an nginx setting? It would be much appreciated if anyone has any ideas on this and can point me to whatever Plesk setting I need to tweak.
test.cgi
#!/usr/bin/perl
print "Content-Type: text/html\n\n" ;
print "<p>Hello World\n" ;
exit ;
Running it from the browser address bar works fine, the permissions are set to 0755, there is a handler set up in the Apache config for cgi-script .cgi and so on. When I run it by typing the address directly into the browser I get Hello World just as expected. I can also run it from a HTML form using GET, like this:
<!DOCTYPE HTML>
<html lang=EN>
<body>
<h1>Testing with GET</h1>
<form class=modern action="test.cgi" method=GET>
<button type=submit>Submit form using GET</button>
</form>
</body>
</html>
but if I change that HTML page to use POST, like this,
<!DOCTYPE HTML>
<html lang=EN>
<body>
<h1>Testing with POST</h1>
<form action="test.cgi" method=POST enctype="multipart/form-data">
<button type=submit>Submit form using POST method</button>
</form>
</body>
</html>
Then it instantly comes up with 502 Bad Gateway and the proxy_error_log says
upstream prematurely closed connection while reading response header from upstream, client: ...., server: www......co.uk,
request: "POST /test/test.cgi HTTP/2.0",
upstream: "https://127.0.0.1:7081/test/test.cgi",
host: "www.....co.uk",
referrer: "https://www.....co.uk/test/test2.shtml"
So it is the exact same program, zero complexity, and the only difference is the HTTP method used. I have tried it with the other enctypes for the post method with the same results. What am I missing? Is there a firewall web rule somewhere that I need to disable, or an nginx setting? It would be much appreciated if anyone has any ideas on this and can point me to whatever Plesk setting I need to tweak.