Hello Valentin, 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 ?
Basically, I think I am asking what is the extension model of njs... Thanks for your help, Antoine. On Sat, Nov 17, 2018 at 4:17 PM Valentin V. Bartenev <[email protected]> wrote: > On Saturday, 17 November 2018 17:06:12 MSK Antoine Bonavita wrote: > > Hello, > > > > For a pet project of mine I'm trying to use njs to retrieve data from a > > number of different sources (URLs really) and assemble them into one > single > > response. I tried to implement a proof of concept using subrequest (from > > ngx_http_js_module) to do so. I quickly realized that it works only for > > internal subrequests (i.e. not to external servers). > > > > I worked around this with the following location: > > location = /fwd-proxy { > > proxy_pass $arg_tgt; > > } > > > > We all know nginx is not really a forward proxy and this approach does > not > > seem very nice for the long term. > > > > So, I have a few cascading questions: > > 1 - Is there any plan to have subrequest from ngx_http_js_module support > > external URLs ? > > 2 - If answer to 1 is no, is there any plan to have another official js > > module implement it ? > > 3 - If no, what would make most sense: implement it as a 3rd-party module > > or completely move to something different (nginx Unit with Node.js comes > to > > mind) ? And why one rather than the other ? > > > > Thank you for reading so far and evne more thanks if you are kind enough > to > > hit the reply button. > > > > Just to make it clear, "subrequest" is not a js module part. It's a > generic > nginx mechanism used by many modules (including ssi, auth_request, > addition) > to request _internal_ resources. The js module just provides you an API > for this mechanism to make ssi-like subrequests. > > You're looking for a different thing, in fact you need an http client in > the > js module to request external resources. That's not something provided > right > now, but will be nice to have in the future. > > wbr, Valentin V. Bartenev > > > > _______________________________________________ > nginx mailing list > [email protected] > http://mailman.nginx.org/mailman/listinfo/nginx >
_______________________________________________ nginx mailing list [email protected] http://mailman.nginx.org/mailman/listinfo/nginx
