njs and subrequests

Dmitry Volyntsev xeioex at nginx.com
Mon Nov 19 13:28:09 UTC 2018

Hi Antoine,

 >Is there any plan to have subrequest from ngx_http_js_module support
 > external URLs ?

Nothing prevents you from making subrequests to external URLs.


 >The address can be specified as a domain name or IP address
 >In this case, if an address is specified as a domain name, the name is 
searched among the described server groups, and, if not found, is 
determined using a resolver.

You still need a location to make a proxy_pass for you (what you already 

As Valentine said, there is nothing special in ngx_http_js_module about 
subrequests. The module simply uses internal NGINX API for subrequests 

You, can find a more complex example of using njs subrequests here: 

More information about the nginx mailing list