June 24, 2014 08:28AM
I found the issue(s). I am not sure why the error log did not have any logs after the lua thread got launched.

Here is the updated /etc/nginx/nginx.conf

location / {
set $dbKey "";

content_by_lua '
local a = ngx.var.http_cookie
local b = ngx.var.http_my_custom_auth

print(a)
print(b)

if ngx.var.http_my_custom_auth ~= nil then
local res = ngx.location.capture("/postgresquery",
{ args = {dbKey = b } }
)
print(res.status)
print(QueryResult)
if res.status == 200 then
return ngx.exec("@final")
else
ngx.status = 403
return
end
elseif ngx.var.http_cookie ~= nil then
return ngx.exec("@final")
else
ngx.status = 444
return
end
';
}

location /postgresquery {
internal;

postgres_pass testdb;
postgres_escape $escaped_dbKey $arg_dbKey;
postgres_query "select id from testtable where key = $escaped_dbKey;";
postgres_output value;
}

However, as you can see, I had to delete print(res.headers) and print(res.body), since lua was complaining that it expects a single value, but it got a table

-Vamshi
Subject Author Posted

content_by_lua not reading/printing header values

vamshi June 24, 2014 04:24AM

Re: content_by_lua not reading/printing header values

vamshi June 24, 2014 08:28AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 239
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready