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?