<div dir="ltr"><div>Hello Valentin,</div><div><br></div><div>And thank you for your prompt answer. Writing such a http client and making it available is probably a pretty big work. But if I were to write a "limited" one that would fit my simple needs (GET only, only HTTP/1.1, response in memory, etc.) trying to re-use what already exists in nginx code base (asynchronous resolver comes to mind first), how should I proceed ? Which parts of the code should I start looking at/take as sample ?</div><div><br></div><div>Basically, I think I am asking what is the extension model of njs...</div><div><br></div><div>Thanks for your help,</div><div><br></div><div>Antoine.<br></div></div><br><div class="gmail_quote"><div dir="ltr">On Sat, Nov 17, 2018 at 4:17 PM Valentin V. Bartenev <<a href="mailto:vbart@nginx.com">vbart@nginx.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Saturday, 17 November 2018 17:06:12 MSK Antoine Bonavita wrote:<br>
> Hello,<br>
> <br>
> For a pet project of mine I'm trying to use njs to retrieve data from a<br>
> number of different sources (URLs really) and assemble them into one single<br>
> response. I tried to implement a proof of concept using subrequest (from<br>
> ngx_http_js_module) to do so. I quickly realized that it works only for<br>
> internal subrequests (i.e. not to external servers).<br>
> <br>
> I worked around this with the following location:<br>
>     location = /fwd-proxy {<br>
>         proxy_pass $arg_tgt;<br>
>     }<br>
> <br>
> We all know nginx is not really a forward proxy and this approach does not<br>
> seem very nice for the long term.<br>
> <br>
> So, I have a few cascading questions:<br>
> 1 - Is there any plan to have subrequest from ngx_http_js_module support<br>
> external URLs ?<br>
> 2 - If answer to 1 is no, is there any plan to have another official js<br>
> module implement it ?<br>
> 3 - If no, what would make most sense: implement it as a 3rd-party module<br>
> or completely move to something different (nginx Unit with Node.js comes to<br>
> mind) ? And why one rather than the other ?<br>
> <br>
> Thank you for reading so far and evne more thanks if you are kind enough to<br>
> hit the reply button.<br>
> <br>
<br>
Just to make it clear, "subrequest" is not a js module part.  It's a generic<br>
nginx mechanism used by many modules (including ssi, auth_request, addition)<br>
to request _internal_ resources.  The js module just provides you an API<br>
for this mechanism to make ssi-like subrequests.<br>
<br>
You're looking for a different thing, in fact you need an http client in the<br>
js module to request external resources.  That's not something provided right<br>
now, but will be nice to have in the future.<br>
<br>
  wbr, Valentin V. Bartenev<br>
<br>
<br>
<br>
_______________________________________________<br>
nginx mailing list<br>
<a href="mailto:nginx@nginx.org" target="_blank">nginx@nginx.org</a><br>
<a href="http://mailman.nginx.org/mailman/listinfo/nginx" rel="noreferrer" target="_blank">http://mailman.nginx.org/mailman/listinfo/nginx</a><br>
</blockquote></div>