NutzCN Logo
短点 利用openresty中的http模块发送get请求问题【ip和域名请求结果不一样】_50ed312b
发布于 2837天前 作者 明天会吹什么风 2345 次浏览 复制 上一个帖子 下一个帖子
标签:

查看完整内容

local http = require "http"
   local httpc = http.new()


   token = "abc123"
   out_trade_no = "456"

   --这个接口是php写的

   --url = "http://【【IP地址】】/Control_center/api.php/Sself/get?token="..token.."&out_trade_no="..out_trade_no

   url = "http://【【域名】】/Control_center/api.php/Sself/get?token="..token.."&out_trade_no="..out_trade_no

   local res, err = httpc:request_uri(url, {
        method = "GET",
        headers = {
            ["Content-Type"] = "application/x-www-form-urlencoded",
        }
   })

   if not res then
        ngx.say("failed to request: ", err)
        return
   end

   ngx.status = res.status

   for k,v in pairs(res.headers) do
       ngx.say(k..'----'..v)
   end

   ngx.say(res.body)


结果:用ip拼接的地址,返回正常的数据
          用域名拼接的地址,返回的 no resolver defined to resolve 域名      比如 "www.baidu.com"
          我配置过resolver 8.8.8.8;  结果还是一样
          
1 回复

no resolver defined to resolve
所以你还是没定义resolver

目测是配了resolver 但不在同一个server内

添加回复
请先登陆
回到顶部