Hello!
Well, you can also configure things in Lua, as in
https://github.com/openresty/lua-resty-upstream-healthcheck#synopsis
And yeah, it's kinda ugly due to the escaping things. I'm going to
implement a Lua block for ngx_lua, such that we can get rid of those
ugly escaping gotchas, as in
content_by_lua_block {
ngx.say("hello world\r\n")
}
which is equivalent to
content_by_lua "
ngx.say("hello world\\r\\n")
";
Essentially there is an interleaving Lua parser in the nginx config
file parser ;)
> And as it's on
> the core of Nginx, the quality will be really good (it's so essential in
> nginx architecture).
Just to be clear, the ngx_lua's cosocket implementation is essentially
the same as the ngx_http_upstream mechanism used by ngx_proxy on the C
level, but the former is specifically designed to be more general and
more flexible :)
We can even get more speed from the existing lua-resty-* client
libraries by actually JITting the cosocket API in the near future :)
Right now the cosocket part is always interpreted even by LuaJIT (due
to its use of the classic lua_CFunction API).
> That's why I have been thinking about trying to make
> some small http-lib in Lua that utilizes this proxy thing (with internal
> locations) for actual requests.
>
IMHO, the subrequest route is a dead end due to the limited
implementation in the nginx core. For example, it's VERY hard to do
streaming processing with a subrequest or aborting a running
subrequest safely without terminating the whole main request. I
already have no plan to add fancy features to the existing subrequest
API but I'll still maintain this thing to ensure it works as specified
:)
Also, communicating with general nginx C modules without special
optimizations for ngx_lua is somewhat inefficient per se (i.e.,
through nginx variables or subrequest interfaces).
Best regards,
-agentzh