49. resolver ip.to.dns.server;
location /http_client {
internal;
proxy_pass $arg_url;
}
location /web_iconv {
content_by_lua '
local from, to, url = ngx.var.arg_f, ngx.var.arg_t, ngx.var.arg_u
local capture = ngx.location.capture
local iconv = require "iconv"
local cd = iconv.new(to or "utf8", from or "gbk")
local res = capture("/http_client?url=" .. url)
if res.status == 200 then
local ostr, err = cd:iconv(res.body)
ngx.print(ostr)
else
ngx.say("error occured: rc=" .. res.status)
end
';
}