Welcome! Log In Create A New Profile

Advanced

Re: njs and subrequests

Antoine Bonavita
November 21, 2018 02:40PM
Hello Dmitry,

Thanks for your answer. I understand locations can be configured to proxy
to external locations and therefore be used in subrequests from njs. That
is what I am doing for now. I consider this to be a workaround. Before I
explain why, I should explain the basics of my pet project. You can think
of it as a service to which you post the URL of an RSS feed and I expect
the server to retrieve the feed, collect all the articles in parallel
(using subrequests) and concatenating the result in my response.
Therefore, the URLs I need to query are not known in advance. And, if I am
not mistaken, that forces me to use a variable as argument for my
proxy_pass, just like I mentioned in my first email:
location = /fwd-proxy {
proxy_pass $arg_tgt;
}
Because of that, my understanding is that the external requests are
performed using HTTP/1.0 and in particular the connection(s) to the
external sources are not kept alive, making the initiator "pay" for the TCP
connection establishment on every single request. Am I mistaken in my
understanding ?

Of course, all this is fine as long as I play in my sandbox and with
servers that I can reach with low latency, but I'm concerned if this
becomes an actual service one day.

Thanks for your precious help,

Antoine.

On Mon, Nov 19, 2018 at 2:28 PM Dmitry Volyntsev <xeioex@nginx.com> wrote:

>
> 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.
>
> https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_pass
> https://nginx.org/en/docs/http/ngx_http_core_module.html#resolver
>
> >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
> have).
>
> As Valentine said, there is nothing special in ngx_http_js_module about
> subrequests. The module simply uses internal NGINX API for subrequests
> (http://hg.nginx.org/njs/file/tip/nginx/ngx_http_js_module.c#l2099).
>
> You, can find a more complex example of using njs subrequests here:
> https://github.com/nginxinc/nginx-openid-connect
>
>
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

njs and subrequests

Antoine Bonavita November 17, 2018 09:08AM

Re: njs and subrequests

Valentin V. Bartenev November 17, 2018 10:18AM

Re: njs and subrequests

Antoine Bonavita November 18, 2018 10:08AM

Re: njs and subrequests

Valentin V. Bartenev November 22, 2018 03:12PM

Re: njs and subrequests

Antoine Bonavita November 26, 2018 04:32AM

Re: njs and subrequests

Dmitry Volyntsev November 19, 2018 08:30AM

Re: njs and subrequests

Antoine Bonavita November 21, 2018 02:40PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 264
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