openresty/lua-upstream-nginx-module

lua-resty-http module

NithishReddy opened this issue · 0 comments

I am using lua-resty-http module (i.e https://github.com/liseen/lua-resty-http).

In nginx.conf:

Server {

lua_package_path "/root/ngx_openresty-1.5.8.1/build/lua-resty-http/lib/?.lua;;";

location ~ /abc/ {

    set $allow "1";


    content_by_lua '

  local http = require "resty.http"
  local httpc = http.new()
  local res, err = httpc:request_uri("https://example.com/national/DetailPage/test", {
    method = "POST",
    body = "a=1&b=2",
    headers = {
      ["Content-Type"] = "application/x-www-form-urlencoded",
    }
  })

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

  ngx.status = res.status

  ngx.say(res.body)
';
  }

}

content_by_lua code is not executing . can you please help me to get out of this ??