Welcome! Log In Create A New Profile

Advanced

Re: Nginx as forward proxy and maintaining persistent connections

Maxim Dounin
March 24, 2018 11:08AM
Hello!

On Fri, Mar 23, 2018 at 08:17:09PM -0400, vi54 wrote:

> am trying to configure nginx as a forward proxy and establish persistent

Note that nginx is not a forward proxy. You may have better luck
with other programs which are designed to be used as a forward
proxy.

> 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?

Yes, to maintain keepalive connections with an upstream server you
have to define and upstream{} block with keepalive cache
configured.

> 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?

That's expected, you cannot use variables in the "server"
directive in the upstream block.

That is, what you are trying to do won't work. You can only
maintain persistent connections with upstream servers you know
about and configured in advance.

--
Maxim Dounin
http://mdounin.ru/
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Nginx as forward proxy and maintaining persistent connections

vi54 March 23, 2018 08:17PM

Re: Nginx as forward proxy and maintaining persistent connections

Maxim Dounin March 24, 2018 11:08AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 287
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready