Welcome! Log In Create A New Profile

Advanced

Re: keepalive seems not to work

Marcin Wanat
October 08, 2020 05:44AM
On Thu, Oct 8, 2020 at 11:36 AM Łukasz Tasz <lukasz@tasz.eu> wrote:

> Hi all,
>
> can I expect that proxy_pass will keep connection to remote server that is
> being proxied?
>
> when I'm using setup client -> proxy -> server it looks to work
> but when I'm using:
> client -> 1stProxy_upstream -> proxy -> server
> connection between 1stProxy and proxy is being kept thanks to keepalive
> 100, but proxy makes new connection every new request, very simple setup:
>
> http {
> server {
> listen 8080;
> location / {
> keepalive_disable none;
> keepalive_requests 1000;
> keepalive_timeout 300s;
> proxy_cache proxy-cache;
> proxy_cache_valid 200 302 301 30m;
> proxy_cache_valid any 1m;
> proxy_cache_key $scheme://$http_host$request_uri;
> proxy_pass $scheme://$http_host$request_uri;
> proxy_http_version 1.1;
> proxy_set_header Connection "";
> }
> }
> }
> I would expect that when client connects proxy and it works then it should
> also works when proxy connects upstream proxy....
>

For keepalive in upstream proxy you shoud use upstream configuration block
and configure keepalive in it:

upstream backend {
zone backend 1m;
server your-server.com;
keepalive 128;
}

server {
listen 8080;
location / {
proxy_cache proxy-cache;
proxy_cache_valid 200 302 301 30m;
proxy_cache_valid any 1m;
proxy_cache_key $scheme://$http_host$request_uri;
proxy_pass $scheme://backend$request_uri;
proxy_http_version 1.1;
proxy_set_header Connection "";
}
}

--
Marcin Wanat
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

keepalive seems not to work

Łukasz Tasz October 08, 2020 05:36AM

Re: keepalive seems not to work

Marcin Wanat October 08, 2020 05:44AM

Re: keepalive seems not to work

Łukasz Tasz October 08, 2020 06:18AM

Re: keepalive seems not to work

Łukasz Tasz October 19, 2020 03:34AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 65
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready