Hi everyone,
I'm used http.resty module to mirror client request for my web server 192.168.4.13 to 192.168.10.51. After cloning I still want to return results to users early on. Now I have to clone the request, but not know how to return the original results.
Help me! my config below:
location / {
root html;
index index.html;
resolver 8.8.8.8; # use Google's open DNS server for an example
content_by_lua '
local uri = ngx.var.request_uri
local url_mirror = "http://192.168.10.51"
local http = require "resty.http"
local httpc = http.new()
httpc:set_timeout(100)
local res, err = httpc:request_uri(url_mirror, {
method = "POST",
body = "content log here", -- content TIME, IP_CLIENT, URI
headers = {
["Content-Type"] = "application/x-www-form-urlencoded",
["User-Agent"] = "kma-VN"
}
})
if not res then
ngx.say("failed to request ", err)
httpc:close()
else
httpc:close()
end
';
}