lua的content_by_lua_block 可以写nginx的proxy_pass吗
可以,可以在 content_by_lua_block 中使用 ngx.location.capture 或 ngx.location.capture_multi 函数来实现类似于 proxy_pass 的功能。例如:
location /api {
content_by_lua_block {
local res = ngx.location.capture("/backend/api")
ngx.say(res.body)
}
}
这个配置将会把来自 /api 的请求转发到 /backend/api,并将后端返回的响应输出给客户端。
原文地址: https://www.cveoy.top/t/topic/crzu 著作权归作者所有。请勿转载和采集!