For a reason beyond my control (an app that cannot be modified), I need to get a server that processes HTTP requests for PHP pages over FastCGI, to honour "Connection: Keep-alive" (sent by said client) with a request also declared as "HTTP/1.0".
This works great for static content, for regular proxied content, etc. (Meaning - if you use:
curl -0v http://server/static.html
you get "Connection: close" as expected, but if you also explicitly request the connection to be kept alive, like this:
curl -H "Connection: keep-alive" -0v http://server/static.html
as long as static.html is either locally on the server, or on another server, proxied by the web server (e.g. proxy_pass in Nginx)).
However, once you add a PHP backend over FastCGI and access http://server/file.php, it seems that all responses will become "Connection: close", no matter what you try... and this behaviour appears to be shared to latest stable Nginx and Apache 2.4.
Note, however, that Apache serving PHP under mod_php does NOT exhibit this issue; I would have used that, but I really need the performance, and unfortunately this app's PHP uses non-threadsafe libs, so can't use thread-based Apache MPMs.
What I already tried in Nginx based on various docs on the Internet and didn't help:
fastcgi_keep_conn on;
(on the PHP location {} block)
upstream fastcgi_backend {
server 127.0.0.1:9000;
keepalive 8;
}
(inside the http {} block)
I sniffed the FastCGI request and saw that it is sending SERVER_PROTOCOL 1.0 over the wire, so I edited /etc/nginx/fastcgi_params, and modified:
fastcgi_param SERVER_PROTOCOL $server_protocol;
to:
fastcgi_param SERVER_PROTOCOL HTTP/1.1;
saw it updating on the sniffer, but to no avail; All requests still return as "Connection: close", no matter what.
I even tried to tinker with the Nginx source code itself (which is an acceptable solution for me if no other solution exists) on various places (without understanding it much :)) to make it "think" that the request was "1.1", but so far without luck.
Any chance anyone ever encountered this and found a solution to this issue?
Thanks!