Nginx as forward proxy and maintaining persistent connections

vi54 nginx-forum at forum.nginx.org
Sat Mar 24 00:17:09 UTC 2018


am trying to configure nginx as a forward proxy and establish persistent
connection between the nginx and the upstream server. When I set

server {
     location / {
     proxy_pass http://$http_host$request_uri;
     proxy_http_version 1.1;
     proxy_set_header Connection "";
     ...
    }
}
in the location context, it has no effect until I have a upstream module
that has keepalive directive in it. Is it mandatory to specify the upstream
module with keepalive directive? If I do that way,

http
{
    upstream up {
      server $http_host;
      keepalive 20;
    }
    server {
      proxy_pass http://up$request_uri;
    }
}
I get the error host not found in upstream "$http_host". Looks like the
server directive is not using it as variable but merely looking for a server
named $http_host? I tried finding hints in online resources but couldn't get
help. I need someone to point me how this goes wrong?

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,279187,279187#msg-279187



More information about the nginx mailing list