https sub request using pintsized/lua-resty-http

47 views
Skip to first unread message

artsy...@gmail.com

unread,
Jan 23, 2017, 7:15:09 PM1/23/17
to openresty-en
Hello everybody,
i'm starting to use openresty and lua and i would use pintsized/lua-resty-http to make subrequests.

nginx.conf

location /subreq {
resolver 8.8.8.8;
lua_code_cache off;
content_by_lua_file /usr/local/openresty/lua/capture.lua;
}


capture.lua



function req ()

local h = ngx.req.get_headers()
local params = {
method = "GET",
headers = {
["User-Agent"] = h["user-agent"],
["Accept-Encoding"] = h["accept-encoding"],
["Accept-Language"] = h["accept-language"],
["Accept"] = h["accept"]
}
}


local link = 'https://google.com'
local http = require "resty.http"
local httpc = http.new()
local res, err = httpc:request_uri(link, params)
if err then
httpc:close()
return ngx.print(err)
end
httpc:close()
ngx.print(res.status)
end

req ()



I get

"20: unable to get local issuer certificate"


Can somebody advise how can i fix it. Or get small code to understand how can i make https subreq, if it possible with resty.http.
Thank you in advance.

Andre

Hamish Forbes

unread,
Jan 24, 2017, 5:03:55 AM1/24/17
to openresty-en
Reply all
Reply to author
Forward
0 new messages