我如何从 OpenResty 向另一台服务器发送请求?

How I can send a request to another server from OpenResty?

我有 OpenResty,如何向另一台服务器发送请求并解析答案?

最好的方法是使用其中一个库,例如。 lua-resty-http or lua-resty-requests。两者都可以通过 OPM 或 LuaRocks 安装。

另一个更高级/更老套的解决方案是(ab)使用ngx.location.capture with appropriate upstream definition or rolling your own support by direct use of ngx.socket.tcp(所有图书馆都在下面使用)。

您可以在此列表中找到更多有用的资源:https://github.com/bungle/awesome-resty