content_by_lua not reading/printing header values
vamshi
nginx-forum at nginx.us
Tue Jun 24 12:28:30 UTC 2014
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
Posted at Nginx Forum: http://forum.nginx.org/read.php?2,251127,251129#msg-251129
More information about the nginx
mailing list