From: Dmitry Volyntsev Date: Thu, 28 May 2026 05:19:46 +0000 (-0700) Subject: Fetch: disable keepalive for dynamic proxy X-Git-Tag: 1.0.0~36 X-Git-Url: http://git.kaiwu.me/postgresql/log/contrib/postgres_fdw/stylesheets/stylesheet.css?a=commitdiff_plain;h=22fb6ba62f28379ba1a3a6cfb6027a9fef5d1fd3;p=njs.git Fetch: disable keepalive for dynamic proxy --- diff --git a/nginx/ngx_js_fetch.c b/nginx/ngx_js_fetch.c index ac19d704..3b6db4a2 100644 --- a/nginx/ngx_js_fetch.c +++ b/nginx/ngx_js_fetch.c @@ -1087,7 +1087,8 @@ ngx_js_fetch_alloc(njs_vm_t *vm, ngx_pool_t *pool, ngx_log_t *log, http->conf = conf; http->content_length_n = -1; - http->keepalive = (conf->fetch_keepalive > 0); + http->keepalive = (conf->fetch_keepalive > 0 + && !ngx_js_conf_dynamic_proxy(conf)); http->append_headers = ngx_js_fetch_append_headers; http->ready_handler = ngx_js_fetch_process_done; diff --git a/nginx/ngx_qjs_fetch.c b/nginx/ngx_qjs_fetch.c index 6f97e7f3..0d510adb 100644 --- a/nginx/ngx_qjs_fetch.c +++ b/nginx/ngx_qjs_fetch.c @@ -1149,7 +1149,8 @@ ngx_qjs_fetch_alloc(JSContext *cx, ngx_pool_t *pool, ngx_log_t *log, http->conf = conf; http->content_length_n = -1; - http->keepalive = (conf->fetch_keepalive > 0); + http->keepalive = (conf->fetch_keepalive > 0 + && !ngx_js_conf_dynamic_proxy(conf)); ngx_qjs_arg(http->response.header_value) = JS_UNDEFINED; diff --git a/nginx/t/js_fetch_proxy_keepalive.t b/nginx/t/js_fetch_proxy_keepalive.t index 422cf1b7..7f119989 100644 --- a/nginx/t/js_fetch_proxy_keepalive.t +++ b/nginx/t/js_fetch_proxy_keepalive.t @@ -58,6 +58,13 @@ http { js_fetch_proxy http://user:pass@127.0.0.1:%%PORT_8082%%; js_content test.https_fetch; } + + location /https_via_dynamic_proxy_keepalive { + set $proxy_url http://user:pass@127.0.0.1:%%PORT_8082%%; + js_fetch_keepalive 4; + js_fetch_proxy $proxy_url; + js_content test.https_fetch; + } } server { @@ -185,7 +192,7 @@ foreach my $name ('example.com', 'example.org') { . $t->read_file('intermediate.crt')); } -$t->try_run('no js_fetch_proxy')->plan(4); +$t->try_run('no js_fetch_proxy')->plan(6); $t->run_daemon(\&https_proxy_daemon, $p2); $t->run_daemon(\&dns_daemon, port(8981), $t); @@ -202,6 +209,10 @@ like(http_get('/https_via_proxy_keepalive?domain=example.com'), qr/COM:2$/, 'https keepalive through proxy 2'); like(http_get("/https_via_proxy_keepalive?domain=example.org&port=$p4"), qr/ORG:2$/, 'https keepalive through proxy different hostnames 2'); +like(http_get('/https_via_dynamic_proxy_keepalive?domain=example.com'), + qr/COM:1$/, 'https dynamic proxy keepalive disabled 1'); +like(http_get('/https_via_dynamic_proxy_keepalive?domain=example.com'), + qr/COM:1$/, 'https dynamic proxy keepalive disabled 2'); ###############################################################################