I have the same issue. I use Lua and Redis for the reverse proxy lookup and don't use upstream. How to use keepalive then? Posted at Nginx Forum: https://forum.nginx.org/read.php?2,248924,263445#msg-263445