我想请求一些 api 并将响应设置为 nginx 变量。但它说"set_by_lua_block" directive is not allowed here
。我怎样才能做到这一点?
http {
set_by_lua_block $hostIp {
local http = require 'resty.http'
local httpc = http.new()
local res, err = httpc:request_uri('http://some-pai')
local body, err = res:read_body()
ngx.log(ngx.INFO, "Using ngx.INFO")
ngx.log(ngx.INFO, body)
return body
}
...
}