Nginx high upstream_connect_time

I solved this one by adding

proxy_http_version 1.1; 
proxy_set_header Connection ""; 

Without these, keepalive means nothing so my tyning of keepalive parameter had no effects.

If I understand correctly, http 1.1 enables using the same connection for simultaionus responses and requests and adding Connection "" in the header is used to keep the connection opened.

In Layman terms, previously I was saying to Nginx that it is allowed to use keepalives upstream, but I didn't configure it to know how to keep the connection opened (there comes the http 1.1 and header Connection part) so no keepalives where used.

In the end, with those two parameters set right, keepalive 500 was enough for "normal" performances but keepalive 1000 was kept to account for the high traffik situations.