]> git.kaiwu.me - njs.git/commit
Fetch: added forward proxy support with HTTPS tunneling.
authorDmitry Volyntsev <xeioex@nginx.com>
Thu, 9 Oct 2025 23:28:24 +0000 (16:28 -0700)
committerDmitry Volyntsev <xeioexception@gmail.com>
Mon, 27 Oct 2025 16:03:09 +0000 (09:03 -0700)
commitdea831892cee6ad3a6e7420e2174157a1a73b92d
tree906a1823395e9a611fb912a42a4881c6a7ca711d
parent4d54ee505ab27845255b7ddc7983f02ad5056085
Fetch: added forward proxy support with HTTPS tunneling.

Supports Basic authentication via Proxy-Authorization header.

- js_fetch_proxy - configures forward proxy URL. It takes proxy URL
    as a parameter. The URL may optionally contain user and password.
     Parameter value can contain variables. If value is empty,
     forward proxy is disabled.

example.conf:
...
  http {
      js_import main.js;

      server {
          listen 8080;

          resolver   127.0.0.1:5353;

          location /api {
              js_fetch_proxy http://user:pass@proxy.example.com:3128;
              js_content main.fetch_handler;
          }
      }
  }

This implements #956 feature request on Github.
14 files changed:
nginx/ngx_http_js_module.c
nginx/ngx_js.c
nginx/ngx_js.h
nginx/ngx_js_fetch.c
nginx/ngx_js_http.c
nginx/ngx_js_http.h
nginx/ngx_qjs_fetch.c
nginx/ngx_stream_js_module.c
nginx/t/js_fetch.t
nginx/t/js_fetch_proxy.t [new file with mode: 0644]
nginx/t/js_fetch_proxy_https.t [new file with mode: 0644]
nginx/t/js_fetch_proxy_keepalive.t [new file with mode: 0644]
nginx/t/js_fetch_proxy_variable.t [new file with mode: 0644]
nginx/t/stream_js_fetch_proxy.t [new file with mode: 0644]