HTTP/1.0 Connection: keep-alive, but Apache replies with HTTP/1.1 Connection: close?
Hi, Apache config question here. I'm dealing with an unusual project where I need to interface a WHM v104.0 w/ Apache 2.4 server with an old piece of technology from the early 90's with the simplest HTTP requests possible, so I have a socket on the old computer connected to the WHM server and I send a header like this:
HOST: somehost.com
GET /myscript.php HTTP/1.0
Connection: keep-alive
...but I'm getting back this response from Apache: (simplified here for readability)
HTTP/1.1 200 OK
Connection: close
It's halfway decent as it's not chunked (even though it's HTTP/1.1?!) and the content comes in clean so this is very good, but the issue is that it closes the connection IMMEDIATELY after the SERVER sent its last page bytes. The client is so old and slow that it randomly cannot grab the last few kilobytes before the connection is closed.
I went in WHM > Apache Configuration > Global Configuration and I see everything that's needed for a keep alive connection enabled, yet Apache seems to revert to "Connection: close" by itself.
Keep-Alive -> On
Keep-Alive Timeout -> 10
Max Keep-Alive Requests -> 200
Timeout -> 120
I have also tried adding this to a .htaccess file in the directory where the requested script is:
Header set Connection keep-alive
...but I'm getting back this response from Apache: (simplified here for readability)
HTTP/1.1 200 OK
Connection: keep-alive, close
... and it still closes the connection before the last few kilobytes are saved in the old computer (exactly the same).
Is WHM ignoring its own Global Configuration settings? I understand non-SSL HTTP/1.x requests are extremely old and not secure and should not be used in 2022 etc, but I'd like to know how to make it work in a way that old/slow technology can have at least a couple seconds to register the last few kilobytes of DATA sent by Apache before the door is slammed in its face and the connection is closed :mad:
-
Hi, answers to your questions: It's a busy server, but not to the point of being slow. The response header and the first few kilobytes from this WHM server are pretty much instantaneous. The server is not overloaded at all. If I disable Keep-Alive under WHM > Apache Configuration > Global Configuration, I'll have to rebuild Apache, on a production server. Are you sure DISABLING Keep-Alive would make it work? I forgot to tell, but this WHM server also runs CSF Firewall, but I've tried to disable it for a minute and run tests and the outcome is exactly the same. Though, I have tried getting a static file instead of a PHP script (e.g. a .PDF file) and Apache correctly issues a "Connection: keep-alive" style of response header and this reliably downloads in full before the connection is closed. So it seems to only issue a "Connection: close" response header and abruptly shut down the connection near the end, before the last few KB, when it's a PHP script. For static files it works fine. Weird? 0 -
No, I'm not sure disabling keep-alive would make it work, but it was just another idea I had. Apache wouldn't need a full rebuild for that change, just a restart. 0 -
Sorry, I misread earlier, it says "Apache configuration must be rebuilt and Apache restarted." but given that having it ON works for static files, I don't think turning it OFF would fix the issue that PHP scripts are not served on a Keep-Alive connection, at least I don't see the logic in this change. I wonder if it could have anything to do with a setting in suphp? The server is on suphp 7.4 at the moment, built of course with WHM's EasyApache 4. 0 -
I don't think there's anything in cPanel that would change the behavior. If you'd like to make a ticket we can check it out on our end and see if we have any official recommendations. 0
Please sign in to leave a comment.
Comments
5 comments