Connection: keep-alive pauses the request
When I proxy a request that sends Connection: keep-alive then the proxy pauses for ~20 seconds before sending the proxied data back to the client. I can get around by doing this:
reverse_proxy "http://example.com", { "CONNECTION" => "close"}
I do not know if this should be handled by the gem by default. There's some code that filters out the connection header from the data that comes back from the proxied side but not here. No idea if that's just an oversight.
Do you know if the server is hanging for the ~20 seconds or is it the gem/client?
I think it is the gem / http client. The app behind the proxy returns immediately (it's a sub 1s response). Adding log statements right before and after the reverse_proxy call in the controller method it seems to hang right there. I also measured in the controller method the time the reverse_proxy method took to rule out caching of log statements and that says 20 seconds as well. Obviously that's not a 100% investigation so I'm not totally sure where the problem is located.
I ran into the same issue described here, fyi.